Skip to content

Commit

Permalink
Rollup merge of rust-lang#48194 - GuillaumeGomez:doc-test-command, r=…
Browse files Browse the repository at this point in the history
…Mark-Simulacrum

Doc test command

r? @Mark-Simulacrum
  • Loading branch information
GuillaumeGomez authored Feb 18, 2018
2 parents 1ad094d + 8e46927 commit 8093b20
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub enum Subcommand {
test_args: Vec<String>,
rustc_args: Vec<String>,
fail_fast: bool,
doc_tests: bool,
},
Bench {
paths: Vec<PathBuf>,
Expand Down Expand Up @@ -164,6 +165,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
"extra options to pass the compiler when running tests",
"ARGS",
);
opts.optflag("", "doc", "run doc tests");
},
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
"clean" => { opts.optflag("", "all", "clean all build artifacts"); },
Expand Down Expand Up @@ -320,6 +322,7 @@ Arguments:
test_args: matches.opt_strs("test-args"),
rustc_args: matches.opt_strs("rustc-args"),
fail_fast: !matches.opt_present("no-fail-fast"),
doc_tests: matches.opt_present("doc"),
}
}
"bench" => {
Expand Down Expand Up @@ -410,6 +413,13 @@ impl Subcommand {
_ => false,
}
}

pub fn doc_tests(&self) -> bool {
match *self {
Subcommand::Test { doc_tests, .. } => doc_tests,
_ => false,
}
}
}

fn split(s: Vec<String>) -> Vec<String> {
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ pub struct Build {
rustfmt_info: channel::GitInfo,
local_rebuild: bool,
fail_fast: bool,
doc_tests: bool,
verbosity: usize,

// Targets for which to build.
Expand Down Expand Up @@ -326,6 +327,7 @@ impl Build {
initial_cargo: config.initial_cargo.clone(),
local_rebuild: config.local_rebuild,
fail_fast: config.cmd.fail_fast(),
doc_tests: config.cmd.doc_tests(),
verbosity: config.verbose,

build: config.build,
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,9 @@ impl Step for Crate {
if test_kind.subcommand() == "test" && !build.fail_fast {
cargo.arg("--no-fail-fast");
}
if build.doc_tests {
cargo.arg("--doc");
}

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

Expand Down

0 comments on commit 8093b20

Please sign in to comment.