]> git.lizzy.rs Git - rust.git/commitdiff
Added `./x.py test --no-doc` option.
authorkennytm <kennytm@gmail.com>
Sat, 5 May 2018 16:04:06 +0000 (00:04 +0800)
committerkennytm <kennytm@gmail.com>
Sat, 5 May 2018 17:27:22 +0000 (01:27 +0800)
This enables `./x.py test --stage 0 src/libstd --no-doc` and ensures the
stage2-rustc and rustdoc need to be built.

src/bootstrap/builder.rs
src/bootstrap/flags.rs
src/bootstrap/lib.rs
src/bootstrap/test.rs

index 08bb8ab481513bbf803f3a657442cef390c0907f..408e61ef548691dd4523f4babc7d52b5d0f320ea 100644 (file)
@@ -25,7 +25,7 @@
 use install;
 use dist;
 use util::{exe, libdir, add_lib_path};
-use {Build, Mode};
+use {Build, Mode, DocTestsOption};
 use cache::{INTERNER, Interned, Cache};
 use check;
 use test;
@@ -591,6 +591,8 @@ pub fn cargo(&self,
                 format!("{} {}", env::var("RUSTFLAGS").unwrap_or_default(), extra_args));
         }
 
+        let want_rustdoc = self.doc_tests != DocTestsOption::No;
+
         // Customize the compiler we're running. Specify the compiler to cargo
         // as our shim and then pass it some various options used to configure
         // how the actual compiler itself is called.
@@ -607,7 +609,7 @@ pub fn cargo(&self,
              .env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
              .env("RUSTC_RPATH", self.config.rust_rpath.to_string())
              .env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
-             .env("RUSTDOC_REAL", if cmd == "doc" || cmd == "test" {
+             .env("RUSTDOC_REAL", if cmd == "doc" || (cmd == "test" && want_rustdoc) {
                  self.rustdoc(compiler.host)
              } else {
                  PathBuf::from("/path/to/nowhere/rustdoc/not/required")
@@ -624,7 +626,7 @@ pub fn cargo(&self,
         if let Some(ref error_format) = self.config.rustc_error_format {
             cargo.env("RUSTC_ERROR_FORMAT", error_format);
         }
-        if cmd != "build" && cmd != "check" {
+        if cmd != "build" && cmd != "check" && want_rustdoc {
             cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.config.build)));
         }
 
index 3eb9dca2aa835807fc663e85e88f736e4515087d..fb7c8ba1351392fd6cc4cb25b9290ad2099636d3 100644 (file)
@@ -19,7 +19,7 @@
 
 use getopts::Options;
 
-use Build;
+use {Build, DocTestsOption};
 use config::Config;
 use metadata;
 use builder::Builder;
@@ -62,7 +62,7 @@ pub enum Subcommand {
         test_args: Vec<String>,
         rustc_args: Vec<String>,
         fail_fast: bool,
-        doc_tests: bool,
+        doc_tests: DocTestsOption,
     },
     Bench {
         paths: Vec<PathBuf>,
@@ -171,7 +171,8 @@ pub fn parse(args: &[String]) -> Flags {
                     "extra options to pass the compiler when running tests",
                     "ARGS",
                 );
-                opts.optflag("", "doc", "run doc tests");
+                opts.optflag("", "no-doc", "do not run doc tests");
+                opts.optflag("", "doc", "only run doc tests");
             },
             "bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
             "clean" => { opts.optflag("", "all", "clean all build artifacts"); },
@@ -324,7 +325,13 @@ pub fn parse(args: &[String]) -> Flags {
                     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"),
+                    doc_tests: if matches.opt_present("doc") {
+                        DocTestsOption::Only
+                    } else if matches.opt_present("no-doc") {
+                        DocTestsOption::No
+                    } else {
+                        DocTestsOption::Yes
+                    }
                 }
             }
             "bench" => {
@@ -411,10 +418,10 @@ pub fn fail_fast(&self) -> bool {
         }
     }
 
-    pub fn doc_tests(&self) -> bool {
+    pub fn doc_tests(&self) -> DocTestsOption {
         match *self {
             Subcommand::Test { doc_tests, .. } => doc_tests,
-            _ => false,
+            _ => DocTestsOption::Yes,
         }
     }
 }
index 0a7f0e5ff4ee25c64116f80a23227dab368bf063..624319485be059b9894a14c61fab695f2a36653e 100644 (file)
@@ -210,6 +210,16 @@ pub struct Compiler {
     host: Interned<String>,
 }
 
+#[derive(PartialEq, Eq, Copy, Clone, Debug)]
+pub enum DocTestsOption {
+    // Default, run normal tests and doc tests.
+    Yes,
+    // Do not run any doc tests.
+    No,
+    // Only run doc tests.
+    Only,
+}
+
 /// Global configuration for the build system.
 ///
 /// This structure transitively contains all configuration for the build system.
@@ -233,7 +243,7 @@ pub struct Build {
     rustfmt_info: channel::GitInfo,
     local_rebuild: bool,
     fail_fast: bool,
-    doc_tests: bool,
+    doc_tests: DocTestsOption,
     verbosity: usize,
 
     // Targets for which to build.
index e8c40dfdb0ad2bcfdc877b9a269f26f6aca760e6..0d430c300368e2eb4da2b9f4b2b0872a0eb40684 100644 (file)
@@ -32,7 +32,7 @@
 use native;
 use tool::{self, Tool};
 use util::{self, dylib_path, dylib_path_var};
-use Mode;
+use {Mode, DocTestsOption};
 use toolstate::ToolState;
 
 const ADB_TEST_DIR: &str = "/data/tmp/work";
@@ -1519,8 +1519,14 @@ fn run(self, builder: &Builder) {
         if test_kind.subcommand() == "test" && !builder.fail_fast {
             cargo.arg("--no-fail-fast");
         }
-        if builder.doc_tests {
-            cargo.arg("--doc");
+        match builder.doc_tests {
+            DocTestsOption::Only => {
+                cargo.arg("--doc");
+            }
+            DocTestsOption::No => {
+                cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
+            }
+            DocTestsOption::Yes => {}
         }
 
         cargo.arg("-p").arg(krate);