Skip to content

Commit 8e46927

Browse files
Add command to launch only doc tests
1 parent b85bd51 commit 8e46927

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/bootstrap/flags.rs

+10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub enum Subcommand {
6060
test_args: Vec<String>,
6161
rustc_args: Vec<String>,
6262
fail_fast: bool,
63+
doc_tests: bool,
6364
},
6465
Bench {
6566
paths: Vec<PathBuf>,
@@ -164,6 +165,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
164165
"extra options to pass the compiler when running tests",
165166
"ARGS",
166167
);
168+
opts.optflag("", "doc", "run doc tests");
167169
},
168170
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
169171
"clean" => { opts.optflag("", "all", "clean all build artifacts"); },
@@ -320,6 +322,7 @@ Arguments:
320322
test_args: matches.opt_strs("test-args"),
321323
rustc_args: matches.opt_strs("rustc-args"),
322324
fail_fast: !matches.opt_present("no-fail-fast"),
325+
doc_tests: matches.opt_present("doc"),
323326
}
324327
}
325328
"bench" => {
@@ -410,6 +413,13 @@ impl Subcommand {
410413
_ => false,
411414
}
412415
}
416+
417+
pub fn doc_tests(&self) -> bool {
418+
match *self {
419+
Subcommand::Test { doc_tests, .. } => doc_tests,
420+
_ => false,
421+
}
422+
}
413423
}
414424

415425
fn split(s: Vec<String>) -> Vec<String> {

src/bootstrap/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ pub struct Build {
226226
rustfmt_info: channel::GitInfo,
227227
local_rebuild: bool,
228228
fail_fast: bool,
229+
doc_tests: bool,
229230
verbosity: usize,
230231

231232
// Targets for which to build.
@@ -326,6 +327,7 @@ impl Build {
326327
initial_cargo: config.initial_cargo.clone(),
327328
local_rebuild: config.local_rebuild,
328329
fail_fast: config.cmd.fail_fast(),
330+
doc_tests: config.cmd.doc_tests(),
329331
verbosity: config.verbose,
330332

331333
build: config.build,

src/bootstrap/test.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,9 @@ impl Step for Crate {
13551355
if test_kind.subcommand() == "test" && !build.fail_fast {
13561356
cargo.arg("--no-fail-fast");
13571357
}
1358+
if build.doc_tests {
1359+
cargo.arg("--doc");
1360+
}
13581361

13591362
cargo.arg("-p").arg(krate);
13601363

0 commit comments

Comments
 (0)