Skip to content

Commit 2c6117b

Browse files
oli-obkcompiler-errors
authored andcommitted
Update docs about ui tests now using //@ headers
1 parent 91332ec commit 2c6117b

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

src/tests/headers.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ They must appear before the Rust source in the test.
88
They may also appear in Makefiles for [run-make tests](compiletest.md#run-make-tests).
99

1010
They are normally put after the short comment that explains the point of this test.
11+
Some test suites use `//@` to signal that a comment is a header, but most are still
12+
just using plain comments.
1113
For example, this test uses the `// compile-flags` command to specify a custom
1214
flag to give to rustc when the test is compiled:
1315

src/tests/ui.md

+20-17
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ the source file.
2929
See [Error annotations](#error-annotations) for more.
3030

3131
[Headers](headers.md) in the form of comments at the top of the file control
32-
how the test is compiled and what the expected behavior is.
32+
how the test is compiled and what the expected behavior is. Note that ui
33+
tests require the use of `//@ header-name` instead of `// header-name` like
34+
the other test suites do. The other test suites will be migrated to use the `//@`
35+
syntax, too, but that is in progress.
3336

3437
Tests are expected to fail to compile, since most tests are testing compiler
3538
errors.
@@ -126,7 +129,7 @@ more suitable for UI testing.
126129
For example, it will anonymize line numbers in the output (line numbers
127130
prefixing each source line are replaced with `LL`).
128131
In extremely rare situations, this mode can be disabled with the header
129-
command `// compile-flags: -Z ui-testing=no`.
132+
command `//@ compile-flags: -Z ui-testing=no`.
130133

131134
Note: The line and column numbers for `-->` lines pointing to the test are
132135
*not* normalized, and left as-is. This ensures that the compiler continues
@@ -139,9 +142,9 @@ Sometimes these built-in normalizations are not enough. In such cases, you
139142
may provide custom normalization rules using the header commands, e.g.
140143

141144
```rust,ignore
142-
// normalize-stdout-test: "foo" -> "bar"
143-
// normalize-stderr-32bit: "fn\(\) \(32 bits\)" -> "fn\(\) \($$PTR bits\)"
144-
// normalize-stderr-64bit: "fn\(\) \(64 bits\)" -> "fn\(\) \($$PTR bits\)"
145+
//@ normalize-stdout-test: "foo" -> "bar"
146+
//@ normalize-stderr-32bit: "fn\(\) \(32 bits\)" -> "fn\(\) \($$PTR bits\)"
147+
//@ normalize-stderr-64bit: "fn\(\) \(64 bits\)" -> "fn\(\) \($$PTR bits\)"
145148
```
146149

147150
This tells the test, on 32-bit platforms, whenever the compiler writes
@@ -291,7 +294,7 @@ We want to ensure this shows "index out of bounds" but we cannot use the
291294
Then it's time to use the `error-pattern` header:
292295

293296
```rust,ignore
294-
// error-pattern: index out of bounds
297+
//@ error-pattern: index out of bounds
295298
fn main() {
296299
let a: *const [_] = &[1, 2, 3];
297300
unsafe {
@@ -330,9 +333,9 @@ conditionally checked based on the current revision.
330333
This is done by placing the revision cfg name in brackets like this:
331334

332335
```rust,ignore
333-
// edition:2018
334-
// revisions: mir thir
335-
// [thir]compile-flags: -Z thir-unsafeck
336+
//@ edition:2018
337+
//@ revisions: mir thir
338+
//@ [thir]compile-flags: -Z thir-unsafeck
336339
337340
async unsafe fn f() {}
338341
@@ -363,20 +366,20 @@ and you can even run the resulting program.
363366
Just add one of the following [header commands](headers.md):
364367

365368
* Pass headers:
366-
* `// check-pass` — compilation should succeed but skip codegen
369+
* `//@ check-pass` — compilation should succeed but skip codegen
367370
(which is expensive and isn't supposed to fail in most cases).
368-
* `// build-pass` — compilation and linking should succeed but do
371+
* `//@ build-pass` — compilation and linking should succeed but do
369372
not run the resulting binary.
370-
* `// run-pass` — compilation should succeed and running the resulting
373+
* `//@ run-pass` — compilation should succeed and running the resulting
371374
binary should also succeed.
372375
* Fail headers:
373-
* `// check-fail` — compilation should fail (the codegen phase is skipped).
376+
* `//@ check-fail` — compilation should fail (the codegen phase is skipped).
374377
This is the default for UI tests.
375-
* `// build-fail` — compilation should fail during the codegen phase.
378+
* `//@ build-fail` — compilation should fail during the codegen phase.
376379
This will run `rustc` twice, once to verify that it compiles successfully
377380
without the codegen phase, then a second time the full compile should
378381
fail.
379-
* `// run-fail` — compilation should succeed, but running the resulting
382+
* `//@ run-fail` — compilation should succeed, but running the resulting
380383
binary should fail.
381384

382385
For `run-pass` and `run-fail` tests, by default the output of the program
@@ -466,8 +469,8 @@ and that the resulting changes compile correctly.
466469
This can be done with the `run-rustfix` header:
467470

468471
```rust,ignore
469-
// run-rustfix
470-
// check-pass
472+
//@ run-rustfix
473+
//@ check-pass
471474
#![crate_type = "lib"]
472475
473476
pub struct not_camel_case {}

0 commit comments

Comments
 (0)