@@ -8,30 +8,30 @@ thousands), efficient test execution (parallel execution is supported), and
8
8
allows the test author to configure behavior and expected results of both
9
9
individual and groups of tests.
10
10
11
- ` compiletest ` tests may check test code for success, for failure or in some
12
- cases, even failure to compile . Tests are typically organized as a Rust source
13
- file with annotations in comments before and/or within the test code, which
14
- serve to direct ` compiletest ` on if or how to run the test, what behavior to
15
- expect, and more. If you are unfamiliar with the compiler testing framework,
11
+ ` compiletest ` tests may check test code for success, for runtime failure, or for
12
+ compile-time failure. Tests are typically organized as a Rust source file with
13
+ annotations in comments before and/or within the test code, which serve to
14
+ direct ` compiletest ` on if or how to run the test, what behavior to expect,
15
+ and more. If you are unfamiliar with the compiler testing framework,
16
16
see [ this chapter] ( ./tests/intro.html ) for additional background.
17
17
18
18
The tests themselves are typically (but not always) organized into
19
- "suites" – for example, ` run-fail ` ,
20
- a folder holding tests that should compile successfully,
21
- but return a failure (non-zero status), ` compile-fail ` , a folder holding tests
22
- that should fail to compile, and many more. The various suites are defined in
23
- [ src/tools/compiletest/src/common.rs] [ common ] in the ` pub enum Mode `
24
- declaration. And a very good introduction to the different suites of compiler
25
- tests along with details about them can be found in [ Adding new
26
- tests] ( ./tests/adding.html ) .
19
+ "suites" – for example, ` run-fail ` , a folder holding tests that should compile
20
+ successfully, but return a failure (non-zero status) at runtime, ` compile-fail ` ,
21
+ a folder holding tests that should fail to compile, and many more. The various
22
+ suites are defined in [ ` src/tools/compiletest/src/common.rs ` ] [ common ] in the
23
+ ` pub enum Mode ` declaration. And a good introduction to the different
24
+ suites of compiler tests along with details about them can be found in
25
+ [ Adding new tests] ( ./tests/adding.html ) .
27
26
28
27
## Adding a new test file
29
28
30
29
Briefly, simply create your new test in the appropriate location under
31
- [ src/test] [ test ] . No registration of test files is necessary as ` compiletest `
32
- will scan the [ src/test] [ test ] subfolder recursively, and will execute any Rust
33
- source files it finds as tests. See [ ` Adding new tests ` ] ( ./tests/adding.html )
34
- for a complete guide on how to adding new tests.
30
+ [ ` src/test ` ] . No registration of test files is necessary as ` compiletest `
31
+ will scan the [ ` src/test ` ] subfolder recursively, and will execute any
32
+ Rust source files it finds as tests.
33
+ See [ Adding new tests] ( ./tests/adding.html ) for a complete guide on how to add
34
+ new tests.
35
35
36
36
## Header Commands
37
37
@@ -46,7 +46,7 @@ described more fully
46
46
### Adding a new header command
47
47
48
48
Header commands are defined in the ` TestProps ` struct in
49
- [ src/tools/compiletest/src/header.rs] [ header ] . At a high level, there are
49
+ [ ` src/tools/compiletest/src/header.rs ` ] [ header ] . At a high level, there are
50
50
dozens of test properties defined here, all set to default values in the
51
51
` TestProp ` struct's ` impl ` block. Any test can override this default value by
52
52
specifying the property in question as header command as a comment (` // ` ) in
@@ -93,9 +93,9 @@ To add a new header command property:
93
93
94
94
When ` compiletest ` encounters a test file, it parses the file a line at a time
95
95
by calling every parser defined in the ` Config ` struct's implementation block,
96
- also in [ src/tools/compiletest/src/header.rs] [ header ] (note the ` Config `
96
+ also in [ ` src/tools/compiletest/src/header.rs ` ] [ header ] (note the ` Config `
97
97
struct's declaration block is found in
98
- [ src/tools/compiletest/src/common.rs] [ common ] . ` TestProps ` 's ` load_from() `
98
+ [ ` src/tools/compiletest/src/common.rs ` ] [ common ] . ` TestProps ` 's ` load_from() `
99
99
method will try passing the current line of text to each parser, which, in turn
100
100
typically checks to see if the line begins with a particular commented (` // ` )
101
101
header command such as ` // must-compile-successfully ` or ` // failure-status ` .
@@ -118,7 +118,7 @@ avoid writing additional parsing code unnecessarily.
118
118
119
119
As a concrete example, here is the implementation for the
120
120
` parse_failure_status() ` parser, in
121
- [ src/tools/compiletest/src/header.rs] [ header ] :
121
+ [ ` src/tools/compiletest/src/header.rs ` ] [ header ] :
122
122
123
123
``` diff
124
124
@@ -232,6 +232,7 @@ pub struct TestProps {
@@ -173,7 +173,7 @@ different implementation in order to invoke behavior change) perhaps it is
173
173
helpful to see the behavior change implementation of one case, simply as an
174
174
example. To implement ` failure-status ` , the ` check_correct_failure_status() `
175
175
function found in the ` TestCx ` implementation block, located in
176
- [ src/tools/compiletest/src/runtest.rs] ( https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/runtest.rs ) ,
176
+ [ ` src/tools/compiletest/src/runtest.rs ` ] ( https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/runtest.rs ) ,
177
177
was modified as per below:
178
178
179
179
``` diff
@@ -220,6 +220,6 @@ example, `// failure-status: 1`, `self.props.failure_status` will evaluate to
220
220
1, as ` parse_failure_status() ` will have overridden the ` TestProps ` default
221
221
value, for that test specifically.
222
222
223
- [ test ] : https://github.com/rust-lang/rust/tree/master/src/test
223
+ [ `src/ test` ] : https://github.com/rust-lang/rust/tree/master/src/test
224
224
[ header ] : https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/header.rs
225
225
[ common ] : https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/common.rs
0 commit comments