Update compiletest directives to be in `ui_test` style `//@`

This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-02-22 10:48:42 +00:00 committed by Nilstrieb
parent b88a4c5275
commit 601180f306
2 changed files with 21 additions and 22 deletions

View File

@ -160,7 +160,7 @@ the current revision name.
For example, this will run twice, simulating changing a function: For example, this will run twice, simulating changing a function:
```rust,ignore ```rust,ignore
// revisions: rpass1 rpass2 //@ revisions: rpass1 rpass2
#[cfg(rpass1)] #[cfg(rpass1)]
fn foo() { fn foo() {
@ -224,11 +224,11 @@ breakpoint, launch the program, inspect a value, and check what the debugger
prints: prints:
```rust,ignore ```rust,ignore
// compile-flags: -g //@ compile-flags: -g
// lldb-command: run //@ lldb-command: run
// lldb-command: print foo //@ lldb-command: print foo
// lldb-check: $0 = 123 //@ lldb-check: $0 = 123
fn main() { fn main() {
let foo = 123; let foo = 123;
@ -480,7 +480,7 @@ There are two [headers](headers.md) to assist with that:
The source file should be in a directory called `auxiliary` beside the test file. The source file should be in a directory called `auxiliary` beside the test file.
```rust,ignore ```rust,ignore
// aux-build: my-helper.rs //@ aux-build: my-helper.rs
extern crate my_helper; extern crate my_helper;
// ... You can use my_helper. // ... You can use my_helper.
@ -507,8 +507,8 @@ Place the proc-macro itself in a file like `auxiliary/my-proc-macro.rs`
with the following structure: with the following structure:
```rust,ignore ```rust,ignore
// force-host //@ force-host
// no-prefer-dynamic //@ no-prefer-dynamic
#![crate_type = "proc-macro"] #![crate_type = "proc-macro"]
@ -529,7 +529,7 @@ The `#![crate_type]` attribute is needed to specify the correct crate-type.
Then in your test, you can build with `aux-build`: Then in your test, you can build with `aux-build`:
```rust,ignore ```rust,ignore
// aux-build: my-proc-macro.rs //@ aux-build: my-proc-macro.rs
extern crate my_proc_macro; extern crate my_proc_macro;
@ -545,7 +545,7 @@ Revisions allow a single test file to be used for multiple tests.
This is done by adding a special header at the top of the file: This is done by adding a special header at the top of the file:
```rust,ignore ```rust,ignore
// revisions: foo bar baz //@ revisions: foo bar baz
``` ```
This will result in the test being compiled (and tested) three times, This will result in the test being compiled (and tested) three times,
@ -560,7 +560,7 @@ comment, like so:
```rust,ignore ```rust,ignore
// A flag to pass in only for cfg `foo`: // A flag to pass in only for cfg `foo`:
//[foo]compile-flags: -Z verbose //@[foo]compile-flags: -Z verbose
#[cfg(foo)] #[cfg(foo)]
fn test_foo() { fn test_foo() {

View File

@ -8,15 +8,14 @@ They must appear before the Rust source in the test.
They may also appear in Makefiles for [run-make tests](compiletest.md#run-make-tests). They may also appear in Makefiles for [run-make tests](compiletest.md#run-make-tests).
They are normally put after the short comment that explains the point of this test. They are normally put after the short comment that explains the point of this test.
Some test suites use `//@` to signal that a comment is a header, but most are still Compiletest test suites use `//@` to signal that a comment is a header.
just using plain comments. For example, this test uses the `//@ compile-flags` command to specify a custom
For example, this test uses the `// compile-flags` command to specify a custom
flag to give to rustc when the test is compiled: flag to give to rustc when the test is compiled:
```rust,ignore ```rust,ignore
// Test the behavior of `0 - 1` when overflow checks are disabled. // Test the behavior of `0 - 1` when overflow checks are disabled.
// compile-flags: -C overflow-checks=off //@ compile-flags: -C overflow-checks=off
fn main() { fn main() {
let x = 0 - 1; let x = 0 - 1;
@ -24,8 +23,8 @@ fn main() {
} }
``` ```
Header commands can be standalone (like `// run-pass`) or take a value (like Header commands can be standalone (like `//@ run-pass`) or take a value (like
`// compile-flags: -C overflow-checks=off`). `//@ compile-flags: -C overflow-checks=off`).
## Header commands ## Header commands
@ -192,10 +191,10 @@ The following headers are generally available, and not specific to particular
test suites. test suites.
* `compile-flags` passes extra command-line args to the compiler, * `compile-flags` passes extra command-line args to the compiler,
e.g. `// compile-flags: -g` which forces debuginfo to be enabled. e.g. `//@ compile-flags: -g` which forces debuginfo to be enabled.
* `run-flags` passes extra args to the test if the test is to be executed. * `run-flags` passes extra args to the test if the test is to be executed.
* `edition` controls the edition the test should be compiled with * `edition` controls the edition the test should be compiled with
(defaults to 2015). Example usage: `// edition:2018`. (defaults to 2015). Example usage: `//@ edition:2018`.
* `failure-status` specifies the numeric exit code that should be expected for * `failure-status` specifies the numeric exit code that should be expected for
tests that expect an error. tests that expect an error.
If this is not set, the default is 1. If this is not set, the default is 1.
@ -239,7 +238,7 @@ For example, if you need to pass a compiler flag with a path to a specific
file, something like the following could work: file, something like the following could work:
```rust,ignore ```rust,ignore
// compile-flags: --remap-path-prefix={{src-base}}=/the/src //@ compile-flags: --remap-path-prefix={{src-base}}=/the/src
``` ```
Where the sentinel `{{src-base}}` will be replaced with the appropriate path Where the sentinel `{{src-base}}` will be replaced with the appropriate path
@ -285,8 +284,8 @@ also in [`src/tools/compiletest/src/header.rs`] (note that the `Config`
struct's declaration block is found in [`src/tools/compiletest/src/common.rs`]). struct's declaration block is found in [`src/tools/compiletest/src/common.rs`]).
`TestProps`'s `load_from()` method will try passing the current line of text to `TestProps`'s `load_from()` method will try passing the current line of text to
each parser, which, in turn typically checks to see if the line begins with a each parser, which, in turn typically checks to see if the line begins with a
particular commented (`//`) header command such as `// must-compile-successfully` particular commented (`//@`) header command such as `//@ must-compile-successfully`
or `// failure-status`. Whitespace after the comment marker is optional. or `//@ failure-status`. Whitespace after the comment marker is optional.
Parsers will override a given header command property's default value merely by Parsers will override a given header command property's default value merely by
being specified in the test file as a header command or by having a parameter being specified in the test file as a header command or by having a parameter