Skip to content

Commit 0d300d4

Browse files
committed
Split test::Docs into one Step for each book.
The *.md at the root directory in src/doc are no longer tested, but this should be fine since all files there are deprecated.
1 parent 51238c7 commit 0d300d4

File tree

2 files changed

+57
-14
lines changed

2 files changed

+57
-14
lines changed

src/bootstrap/builder.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ pub struct ShouldRun<'a> {
231231
paths: BTreeSet<PathSet>,
232232

233233
// If this is a default rule, this is an additional constraint placed on
234-
// it's run. Generally something like compiler docs being enabled.
234+
// its run. Generally something like compiler docs being enabled.
235235
is_really_default: bool,
236236
}
237237

@@ -326,7 +326,9 @@ impl<'a> Builder<'a> {
326326
test::RunPassPretty, test::RunFailPretty, test::RunPassValgrindPretty,
327327
test::RunPassFullDepsPretty, test::RunFailFullDepsPretty, test::RunMake,
328328
test::Crate, test::CrateLibrustc, test::Rustdoc, test::Linkcheck, test::Cargotest,
329-
test::Cargo, test::Rls, test::Docs, test::ErrorIndex, test::Distcheck,
329+
test::Cargo, test::Rls, test::ErrorIndex, test::Distcheck,
330+
test::Nomicon, test::Reference, test::RustdocBook, test::RustByExample,
331+
test::TheBook, test::UnstableBook,
330332
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme),
331333
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
332334
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,

src/bootstrap/test.rs

+53-12
Original file line numberDiff line numberDiff line change
@@ -994,23 +994,19 @@ impl Step for Compiletest {
994994
}
995995

996996
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
997-
pub struct Docs {
997+
struct DocTest {
998998
compiler: Compiler,
999+
path: &'static str,
1000+
name: &'static str,
1001+
is_ext_doc: bool,
9991002
}
10001003

1001-
impl Step for Docs {
1004+
impl Step for DocTest {
10021005
type Output = ();
1003-
const DEFAULT: bool = true;
10041006
const ONLY_HOSTS: bool = true;
10051007

10061008
fn should_run(run: ShouldRun) -> ShouldRun {
1007-
run.path("src/doc")
1008-
}
1009-
1010-
fn make_run(run: RunConfig) {
1011-
run.builder.ensure(Docs {
1012-
compiler: run.builder.compiler(run.builder.top_stage, run.host),
1013-
});
1009+
run.never()
10141010
}
10151011

10161012
/// Run `rustdoc --test` for all documentation in `src/doc`.
@@ -1026,9 +1022,9 @@ impl Step for Docs {
10261022

10271023
// Do a breadth-first traversal of the `src/doc` directory and just run
10281024
// tests for all files that end in `*.md`
1029-
let mut stack = vec![build.src.join("src/doc")];
1025+
let mut stack = vec![build.src.join(self.path)];
10301026
let _time = util::timeit();
1031-
let _folder = build.fold_output(|| "test_docs");
1027+
let _folder = build.fold_output(|| format!("test_{}", self.name));
10321028

10331029
while let Some(p) = stack.pop() {
10341030
if p.is_dir() {
@@ -1051,6 +1047,51 @@ impl Step for Docs {
10511047
}
10521048
}
10531049

1050+
macro_rules! test_book {
1051+
($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => {
1052+
$(
1053+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1054+
pub struct $name {
1055+
compiler: Compiler,
1056+
}
1057+
1058+
impl Step for $name {
1059+
type Output = ();
1060+
const DEFAULT: bool = $default;
1061+
const ONLY_HOSTS: bool = true;
1062+
1063+
fn should_run(run: ShouldRun) -> ShouldRun {
1064+
run.path($path)
1065+
}
1066+
1067+
fn make_run(run: RunConfig) {
1068+
run.builder.ensure($name {
1069+
compiler: run.builder.compiler(run.builder.top_stage, run.host),
1070+
});
1071+
}
1072+
1073+
fn run(self, builder: &Builder) {
1074+
builder.ensure(DocTest {
1075+
compiler: self.compiler,
1076+
path: $path,
1077+
name: $book_name,
1078+
is_ext_doc: !$default,
1079+
});
1080+
}
1081+
}
1082+
)+
1083+
}
1084+
}
1085+
1086+
test_book!(
1087+
Nomicon, "src/doc/nomicon", "nomicon", default=false;
1088+
Reference, "src/doc/reference", "reference", default=false;
1089+
RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
1090+
RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
1091+
TheBook, "src/doc/book", "book", default=false;
1092+
UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
1093+
);
1094+
10541095
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
10551096
pub struct ErrorIndex {
10561097
compiler: Compiler,

0 commit comments

Comments
 (0)