Skip to content

Commit 1d76ccd

Browse files
committed
Update COMPILER_TESTS.md documentation to discuss revisions
1 parent 3fb80e3 commit 1d76ccd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

COMPILER_TESTS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,34 @@ whole, instead of just a few lines inside the test.
4242
* `ignore-test` always ignores the test
4343
* `ignore-lldb` and `ignore-gdb` will skip the debuginfo tests
4444
* `min-{gdb,lldb}-version`
45+
46+
## Revisions
47+
48+
Certain classes of tests support "revisions" (as of the time of this
49+
writing, this includes run-pass, compile-fail, run-fail, and
50+
incremental, though incremental tests are somewhat
51+
different). Revisions allow a single test file to be used for multiple
52+
tests. This is done by adding a special header at the top of the file:
53+
54+
```
55+
// revisions: foo bar baz
56+
```
57+
58+
This will result in the test being compiled (and tested) three times,
59+
once with `--cfg foo`, once with `--cfg bar`, and once with `--cfg
60+
baz`. You can therefore use `#[cfg(foo)]` etc within the test to tweak
61+
each of these results.
62+
63+
You can also customize headers and expected error messages to a particular
64+
revision. To do this, add `[foo]` (or `bar`, `baz`, etc) after the `//`
65+
comment, like so:
66+
67+
```
68+
// A flag to pass in only for cfg `foo`:
69+
//[foo]compile-flags: -Z verbose
70+
71+
#[cfg(foo)]
72+
fn test_foo() {
73+
let x: usize = 32_u32; //[foo]~ ERROR mismatched types
74+
}
75+
```

0 commit comments

Comments
 (0)