You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/compiletest.md
+16-14
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
1
# `compiletest`
2
2
## Introduction
3
-
`compiletest` is the main test harness of the Rust test suite. It allows test authors to organize large numbers of tests (the
4
-
Rust compiler has many thousands), efficient test execution (parallel execution is supported), and allows the test author to
5
-
configure behavior and expected results of both individual and groups of tests.
3
+
`compiletest` is the main test harness of the Rust test suite. It allows
4
+
test authors to organize large numbers of tests (the Rust compiler has many
5
+
thousands), efficient test execution (parallel execution is supported), and
6
+
allows the test author to configure behavior and expected results of both
7
+
individual and groups of tests.
6
8
7
9
`compiletest` tests may check test code for success, for failure or in some cases, even failure to compile. Tests are
8
10
typically organized as a Rust source file with annotations in comments before and/or within the test code, which serve to
@@ -12,17 +14,17 @@ testing framework, see [`this chapter`](./tests/intro.html) for additional backg
12
14
The tests themselves are typically (but not always) organized into "suites"--for example, `run-pass`, a folder
13
15
representing tests that should succeed, `run-fail`, a folder holding tests that should compile successfully, but return
14
16
a failure (non-zero status), `compile-fail`, a folder holding tests that should fail to compile, and many more. The various
15
-
suites are defined in [src/tools/compiletest/src/common.rs](https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/common.rs) in the `pub struct Config` declaration. And a very good
17
+
suites are defined in [src/tools/compiletest/src/common.rs](https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/common.rs) in the `pub struct Config` declaration. And a very good
16
18
introduction to the different suites of compiler tests along with details about them can be found in [`Adding new tests`](./tests/adding.html).
17
19
18
20
## Adding a new test file
19
-
Briefly, simply create your new test in the appropriate location under [src/test](https://github.com/rust-lang/rust/tree/master/src/test). No registration of test files is necessary as
21
+
Briefly, simply create your new test in the appropriate location under [src/test](https://github.com/rust-lang/rust/tree/master/src/test). No registration of test files is necessary as
20
22
`compiletest` will scan the [src/test](https://github.com/rust-lang/rust/tree/master/src/test) subfolder recursively, and will execute any Rust source files it finds as tests.
21
-
See [`Adding new tests`](./tests/adding.html) for a complete guide on how to adding new tests.
23
+
See [`Adding new tests`](./tests/adding.html) for a complete guide on how to adding new tests.
22
24
23
25
## Header Commands
24
26
Source file annotations which appear in comments near the top of the source file *before* any test code are known as header
25
-
commands. These commands can instruct `compiletest` to ignore this test, set expectations on whether it is expected to
27
+
commands. These commands can instruct `compiletest` to ignore this test, set expectations on whether it is expected to
26
28
succeed at compiling, or what the test's return code is expected to be. Header commands (and their inline counterparts,
27
29
Error Info commands) are described more fully [here](./tests/adding.html#header-commands-configuring-rustc).
28
30
@@ -96,7 +98,7 @@ As a concrete example, here is the implementation for the `parse_failure_status(
96
98
pub normalize_stderr: Vec<(String, String)>,
97
99
+ pub failure_status: i32,
98
100
}
99
-
101
+
100
102
impl TestProps {
101
103
@@ -260,6 +261,7 @@ impl TestProps {
102
104
run_pass: false,
@@ -105,7 +107,7 @@ As a concrete example, here is the implementation for the `parse_failure_status(
105
107
+ failure_status: 101,
106
108
}
107
109
}
108
-
110
+
109
111
@@ -383,6 +385,10 @@ impl TestProps {
110
112
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stderr") {
111
113
self.normalize_stderr.push(rule);
@@ -115,12 +117,12 @@ As a concrete example, here is the implementation for the `parse_failure_status(
115
117
+ self.failure_status = code;
116
118
+ }
117
119
});
118
-
120
+
119
121
for key in &["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
0 commit comments