Skip to content

Commit 5d5be50

Browse files
authored
Merge pull request rust-lang#2255 from tlyu/xtask-doctest
add xtask doctest
2 parents 184f872 + ffe4cfd commit 5d5be50

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

dev-guide/src/examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ When demonstrating success cases, multiple cases may be included in a single cod
2929

3030
## Testing examples
3131

32-
The Rust code blocks are tested in CI. You can verify that the samples pass by running [`mdbook test`].
32+
The Rust code blocks are tested in CI. You can verify that the samples pass by running [`cargo xtask mdbook-test`].
3333

34-
[`mdbook test`]: tests.md#inline-tests
34+
[`cargo xtask mdbook-test`]: tests.md#inline-tests
3535
[mdBook supported languages]: https://rust-lang.github.io/mdBook/format/theme/syntax-highlighting.html#supported-languages
3636
[rustdoc documentation]: https://doc.rust-lang.org/rustdoc/documentation-tests.html
3737
[tested via rustdoc]: tests.md#inline-tests

dev-guide/src/tests.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
There are several different kinds of tests you can run (these are enforced in CI):
44

55
- [`cargo xtask test-all`](#all-tests) --- Runs all tests.
6-
- [`mdbook test`](#inline-tests) --- Tests the inline Rust code blocks.
6+
- [`cargo xtask mdbook-test`](#inline-tests) --- Tests the inline Rust code blocks.
77
- [`cargo xtask linkcheck`](#linkcheck) --- Validates that Markdown links aren't broken.
88
- [`cargo xtask style-check`](#style-checks) --- Validates various style checks.
99
- [Code formatting](#code-formatting) --- Checks that all Rust tooling code is formatted.
@@ -22,11 +22,13 @@ We recommend running this as a last step before opening a PR. This runs most of
2222
## Inline tests
2323

2424
```sh
25-
mdbook test
25+
cargo xtask mdbook-test
2626
```
2727

2828
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 [Examples] for more.
2929

30+
Previous versions of this guide suggested `mdbook test`, but this only works reliably if your default toolchain is nightly.
31+
3032
## Linkcheck
3133

3234
```sh

dev-guide/src/tooling/building.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ First, ensure that you have a recent copy of the nightly Rust compiler installed
1717

1818
```sh
1919
rustup toolchain install nightly
20-
rustup override set nightly
2120
```
2221

2322
Now, ensure you have `mdbook` installed, as this is needed to build the Reference:

tools/xtask/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Result<T> = std::result::Result<T, Box<dyn Error>>;
88
fn main() -> Result<()> {
99
let mut args = std::env::args().skip(1);
1010
let cmd = args.next();
11-
const OPTIONS: &str = "linkcheck, style-check, test-all";
11+
const OPTIONS: &str = "mdbook-test, linkcheck, style-check, test-all";
1212
match cmd.as_deref() {
1313
Some("test-all") => {
1414
mdbook_test()?;
@@ -18,6 +18,7 @@ fn main() -> Result<()> {
1818
cargo_test()?;
1919
eprintln!("all tests passed!");
2020
}
21+
Some("mdbook-test") => mdbook_test()?,
2122
Some("linkcheck") => linkcheck(args)?,
2223
Some("style-check") => style_check()?,
2324
Some("-h" | "--help") => eprintln!("valid options: {OPTIONS}"),

0 commit comments

Comments
 (0)