Skip to content

Commit 03386c9

Browse files
committed
Clean up compiletest chapter
* Improve wording * Improve formatting
1 parent bd82b75 commit 03386c9

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- [The compiler testing framework](./tests/intro.md)
2121
- [Running tests](./tests/running.md)
2222
- [Adding new tests](./tests/adding.md)
23-
- [Using `compiletest` + commands to control test execution](./compiletest.md)
23+
- [Using `compiletest` commands to control test execution](./compiletest.md)
2424
- [Debugging the Compiler](./compiler-debugging.md)
2525
- [Profiling the compiler](./profiling.md)
2626
- [with the linux perf tool](./profiling/with_perf.md)

src/compiletest.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@ thousands), efficient test execution (parallel execution is supported), and
88
allows the test author to configure behavior and expected results of both
99
individual and groups of tests.
1010

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,
1616
see [this chapter](./tests/intro.html) for additional background.
1717

1818
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).
2726

2827
## Adding a new test file
2928

3029
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.
3535

3636
## Header Commands
3737

@@ -46,7 +46,7 @@ described more fully
4646
### Adding a new header command
4747

4848
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
5050
dozens of test properties defined here, all set to default values in the
5151
`TestProp` struct's `impl` block. Any test can override this default value by
5252
specifying the property in question as header command as a comment (`//`) in
@@ -93,9 +93,9 @@ To add a new header command property:
9393

9494
When `compiletest` encounters a test file, it parses the file a line at a time
9595
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`
9797
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()`
9999
method will try passing the current line of text to each parser, which, in turn
100100
typically checks to see if the line begins with a particular commented (`//`)
101101
header command such as `// must-compile-successfully` or `// failure-status`.
@@ -118,7 +118,7 @@ avoid writing additional parsing code unnecessarily.
118118

119119
As a concrete example, here is the implementation for the
120120
`parse_failure_status()` parser, in
121-
[src/tools/compiletest/src/header.rs][header]:
121+
[`src/tools/compiletest/src/header.rs`][header]:
122122

123123
```diff
124124
@@ -232,6 +232,7 @@ pub struct TestProps {
@@ -173,7 +173,7 @@ different implementation in order to invoke behavior change) perhaps it is
173173
helpful to see the behavior change implementation of one case, simply as an
174174
example. To implement `failure-status`, the `check_correct_failure_status()`
175175
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),
177177
was modified as per below:
178178

179179
```diff
@@ -220,6 +220,6 @@ example, `// failure-status: 1`, `self.props.failure_status` will evaluate to
220220
1, as `parse_failure_status()` will have overridden the `TestProps` default
221221
value, for that test specifically.
222222

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
224224
[header]: https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/header.rs
225225
[common]: https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/common.rs

0 commit comments

Comments
 (0)