提交 8e469272 编写于 作者: G Guillaume Gomez

Add command to launch only doc tests

上级 b85bd51c
...@@ -60,6 +60,7 @@ pub enum Subcommand { ...@@ -60,6 +60,7 @@ pub enum Subcommand {
test_args: Vec<String>, test_args: Vec<String>,
rustc_args: Vec<String>, rustc_args: Vec<String>,
fail_fast: bool, fail_fast: bool,
doc_tests: bool,
}, },
Bench { Bench {
paths: Vec<PathBuf>, paths: Vec<PathBuf>,
...@@ -164,6 +165,7 @@ pub fn parse(args: &[String]) -> Flags { ...@@ -164,6 +165,7 @@ pub fn parse(args: &[String]) -> Flags {
"extra options to pass the compiler when running tests", "extra options to pass the compiler when running tests",
"ARGS", "ARGS",
); );
opts.optflag("", "doc", "run doc tests");
}, },
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); }, "bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
"clean" => { opts.optflag("", "all", "clean all build artifacts"); }, "clean" => { opts.optflag("", "all", "clean all build artifacts"); },
...@@ -320,6 +322,7 @@ pub fn parse(args: &[String]) -> Flags { ...@@ -320,6 +322,7 @@ pub fn parse(args: &[String]) -> Flags {
test_args: matches.opt_strs("test-args"), test_args: matches.opt_strs("test-args"),
rustc_args: matches.opt_strs("rustc-args"), rustc_args: matches.opt_strs("rustc-args"),
fail_fast: !matches.opt_present("no-fail-fast"), fail_fast: !matches.opt_present("no-fail-fast"),
doc_tests: matches.opt_present("doc"),
} }
} }
"bench" => { "bench" => {
...@@ -410,6 +413,13 @@ pub fn fail_fast(&self) -> bool { ...@@ -410,6 +413,13 @@ pub fn fail_fast(&self) -> bool {
_ => false, _ => false,
} }
} }
pub fn doc_tests(&self) -> bool {
match *self {
Subcommand::Test { doc_tests, .. } => doc_tests,
_ => false,
}
}
} }
fn split(s: Vec<String>) -> Vec<String> { fn split(s: Vec<String>) -> Vec<String> {
......
...@@ -226,6 +226,7 @@ pub struct Build { ...@@ -226,6 +226,7 @@ pub struct Build {
rustfmt_info: channel::GitInfo, rustfmt_info: channel::GitInfo,
local_rebuild: bool, local_rebuild: bool,
fail_fast: bool, fail_fast: bool,
doc_tests: bool,
verbosity: usize, verbosity: usize,
// Targets for which to build. // Targets for which to build.
...@@ -326,6 +327,7 @@ pub fn new(config: Config) -> Build { ...@@ -326,6 +327,7 @@ pub fn new(config: Config) -> Build {
initial_cargo: config.initial_cargo.clone(), initial_cargo: config.initial_cargo.clone(),
local_rebuild: config.local_rebuild, local_rebuild: config.local_rebuild,
fail_fast: config.cmd.fail_fast(), fail_fast: config.cmd.fail_fast(),
doc_tests: config.cmd.doc_tests(),
verbosity: config.verbose, verbosity: config.verbose,
build: config.build, build: config.build,
......
...@@ -1355,6 +1355,9 @@ fn run(self, builder: &Builder) { ...@@ -1355,6 +1355,9 @@ fn run(self, builder: &Builder) {
if test_kind.subcommand() == "test" && !build.fail_fast { if test_kind.subcommand() == "test" && !build.fail_fast {
cargo.arg("--no-fail-fast"); cargo.arg("--no-fail-fast");
} }
if build.doc_tests {
cargo.arg("--doc");
}
cargo.arg("-p").arg(krate); cargo.arg("-p").arg(krate);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册