Skip to content

Commit 03d6512

Browse files
committed
Add a contributor tests chapter
1 parent 63cbb46 commit 03d6512

File tree

3 files changed

+61
-9
lines changed

3 files changed

+61
-9
lines changed

contributor-guide/src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- [Reference tooling]()
77
- [Building the Reference](tooling/building.md)
88
- [mdbook-spec](tooling/mdbook-spec.md)
9-
- [Tests]()
9+
- [Tests](tests.md)
1010
- [Formatting](formatting/index.md)
1111
- [Markdown](formatting/markdown.md)
1212
- [Admonitions](formatting/admonitions.md)

contributor-guide/src/tests.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Running tests
2+
3+
There are several different kinds of tests you can run (these are enforced in CI):
4+
5+
- [`cargo xtask test-all`](#all-tests) --- Runs all tests.
6+
- [`mdbook test`](#inline-tests) --- Tests the inline Rust codeblocks.
7+
- [`cargo xtask linkcheck`](#linkcheck) --- Validates that markdown links aren't broken.
8+
- [`cargo xtask style-check`](#style-checks) --- Validates various style checks.
9+
- [Code formatting](#code-formatting) --- Checks that all Rust tooling code is formatted.
10+
- [mdbook-spec tests](#mdbook-spec-tests) --- Internal tests for `mdbook-spec`.
11+
12+
## All tests
13+
14+
```sh
15+
cargo xtask test-all
16+
```
17+
18+
This command runs all the tests listed below.
19+
20+
We recommend running this as a last step before opening a PR. This runs most of the tests required for CI to pass. See [`xtask/src/main.rs`](https://github.com/rust-lang/reference/blob/master/xtask/src/main.rs) for details on what this does.
21+
22+
## Inline tests
23+
24+
```sh
25+
mdbook test
26+
```
27+
28+
This command runs all tests that are inline in the Markdown. Internally, this uses [`rustdoc`](https://doc.rust-lang.org/rustdoc/) to run the tests and supports all the same features. Any code block with the `rust` language will be compiled unless it is ignored. See the [Examples chapter](examples.md) for more.
29+
30+
## Linkcheck
31+
32+
```sh
33+
cargo xtask linkcheck
34+
```
35+
36+
This command verifies that links are not broken. It downloads and uses the [`linkchecker`](https://github.com/rust-lang/rust/tree/main/src/tools/linkchecker) script hosted in the `rust-lang/rust` repository.
37+
38+
This requires a recent nightly installed via `rustup` and the `rust-docs` component.
39+
40+
After compiling the script, it builds the Reference using `mdbook` and then scans all local links to verify that they are valid, particularly between various books. This does not check any network links.
41+
42+
## Style checks
43+
44+
```sh
45+
cargo xtask style-check
46+
```
47+
48+
This uses the [`style-check`](https://github.com/rust-lang/reference/tree/master/style-check) tool to enforce various formatting rules.
49+
50+
## Code formatting
51+
52+
CI uses `cargo fmt --check` to verify that all Rust sources for the tools (like `mdbook-spec`) are properly formatted. All code must be formatted with `rustfmt`.
53+
54+
## mdbook-spec tests
55+
56+
```sh
57+
cargo test --manifest-path mdbook-spec/Cargo.toml
58+
```
59+
60+
CI runs `cargo test` on `mdbook-spec` to execute any tests for the tool itself.

docs/authoring.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ This document serves as a guide for editors and reviewers. Some conventions and
44

55
[introduction]: ../src/introduction.md
66

7-
### Linkcheck
8-
9-
To verify that links are not broken, run `cargo xtask linkcheck`.
10-
11-
### Running all tests
12-
13-
As a last step before opening a PR, it is recommended to run `cargo xtask test-all`. This will go through and run most of the tests that are required for CI to pass. See `xtask/src/main.rs` for what all this does.
14-
157
## Style
168

179
Idioms and styling:

0 commit comments

Comments
 (0)