Skip to content

Commit 63916d6

Browse files
committed
Document all the things
1 parent 54b6b03 commit 63916d6

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

ui_test/README.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,37 @@ A smaller version of compiletest-rs
77

88
## Supported magic comment annotations
99

10-
* `// ignore-XXX` avoids running the test on targets whose triple contains `XXX`
10+
If your test tests for failure, you need to add a `//~` annotation where the error is happening
11+
to make sure that the test will always keep failing with a specific message at the annotated line.
12+
13+
`//~ ERROR: XXX` make sure the stderr output contains `XXX` for an error in the line where this comment is written
14+
15+
* Also supports `HELP`, `WARN` or `NOTE` for different kind of message
16+
* if one of those levels is specified explicitly, *all* diagnostics of this level or higher need an annotation. If you want to avoid this, just leave out the all caps level note entirely.
17+
* If the all caps note is left out, a message of any level is matched. Leaving it out is not allowed for `ERROR` levels.
18+
* This checks the output *before* normalization, so you can check things that get normalized away, but need to
19+
be careful not to accidentally have a pattern that differs between platforms.
20+
21+
In order to change how a single test is tested, you can add various `//@` comments to the test.
22+
Any other comments will be ignored, and all `//@` comments must be formatted precisely as
23+
their command specifies, or the test will fail without even being run.
24+
25+
* `//@ignore-XXX` avoids running the test on targets whose triple contains `XXX`
1126
* `XXX` can also be one of `64bit`, `32bit` or `16bit`
12-
* `// only-XXX` avoids running the test on targets whose triple **does not** contain `XXX`
27+
* `//@only-XXX` avoids running the test on targets whose triple **does not** contain `XXX`
1328
* `XXX` can also be one of `64bit`, `32bit` or `16bit`
14-
* `// stderr-per-bitwidth` produces one stderr file per bitwidth, as they may differ significantly sometimes
29+
* `//@stderr-per-bitwidth` produces one stderr file per bitwidth, as they may differ significantly sometimes
1530
* `//@error-pattern: XXX` make sure the stderr output contains `XXX`
16-
* `//~ ERROR: XXX` make sure the stderr output contains `XXX` for an error in the line where this comment is written
17-
* Also supports `HELP`, `WARN` or `NOTE` for different kind of message
18-
* if one of those levels is specified explicitly, *all* diagnostics of this level or higher need an annotation. If you want to avoid this, just leave out the all caps level note entirely.
19-
* If the all caps note is left out, a message of any level is matched. Leaving it out is not allowed for `ERROR` levels.
20-
* This checks the output *before* normalization, so you can check things that get normalized away, but need to
21-
be careful not to accidentally have a pattern that differs between platforms.
22-
* `// revisions: XXX YYY` runs the test once for each space separated name in the list
31+
* `//@revisions: XXX YYY` runs the test once for each space separated name in the list
2332
* emits one stderr file per revision
2433
* `//~` comments can be restricted to specific revisions by adding the revision name before the `~` in square brackets: `//[XXX]~`
25-
* `// compile-flags: XXX` appends `XXX` to the command line arguments passed to the rustc driver
26-
* `// rustc-env: XXX=YYY` sets the env var `XXX` to `YYY` for the rustc driver execution.
34+
* `//@compile-flags: XXX` appends `XXX` to the command line arguments passed to the rustc driver
35+
* you can specify this multiple times, and all the flags will accumulate
36+
* `//@rustc-env: XXX=YYY` sets the env var `XXX` to `YYY` for the rustc driver execution.
2737
* for Miri these env vars are used during compilation via rustc and during the emulation of the program
28-
* `// normalize-stderr-test: "REGEX" -> "REPLACEMENT"` replaces all matches of `REGEX` in the stderr with `REPLACEMENT`. The replacement may specify `$1` and similar backreferences to paste captures.
38+
* you can specify this multiple times, accumulating all the env vars
39+
* `//@normalize-stderr-test: "REGEX" -> "REPLACEMENT"` replaces all matches of `REGEX` in the stderr with `REPLACEMENT`. The replacement may specify `$1` and similar backreferences to paste captures.
40+
* you can specify multiple such commands, there is no need to create a single regex that handles multiple replacements that you want to perform.
2941

3042
## Significant differences to compiletest-rs
3143

ui_test/src/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Comments {
7575
/// Parse comments in `content`.
7676
/// `path` is only used to emit diagnostics if parsing fails.
7777
///
78-
/// This function will only parse `//@` and `//~` style comments
78+
/// This function will only parse `//@` and `//~` style comments (and the `//[xxx]~` variant)
7979
/// and ignore all others
8080
fn parse_checked(path: &Path, content: &str) -> Result<Self> {
8181
let mut this = Self::default();

0 commit comments

Comments
 (0)