about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-02-18 13:20:57 +0100
committerGitHub <noreply@github.com>2018-02-18 13:20:57 +0100
commit8093b2020151643a2dcba71044afcf28c48a006d (patch)
tree4665f66ef37e31a3f1beed520321a84f8e696b9a
parent1ad094d81c97b3d2dd8e980ccd1475a80647540d (diff)
parent8e46927235f27e097707674d7837faa52f92d874 (diff)
downloadrust-8093b2020151643a2dcba71044afcf28c48a006d.tar.gz
rust-8093b2020151643a2dcba71044afcf28c48a006d.zip
Rollup merge of #48194 - GuillaumeGomez:doc-test-command, r=Mark-Simulacrum
Doc test command

r? @Mark-Simulacrum
-rw-r--r--src/bootstrap/flags.rs10
-rw-r--r--src/bootstrap/lib.rs2
-rw-r--r--src/bootstrap/test.rs3
3 files changed, 15 insertions, 0 deletions
diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs
index 42b949527e0..eb5c3b8ce14 100644
--- a/src/bootstrap/flags.rs
+++ b/src/bootstrap/flags.rs
@@ -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>,
@@ -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"); },
@@ -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" => {
@@ -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> {
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index afd740ce548..90f50275b6b 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -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.
@@ -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,
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 64ede4f4ecc..c969f102471 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -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);