about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-04-04 16:53:59 +0200
committerAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-04-04 21:02:40 +0200
commitdb6a916804ff7402ba70ca635e5071ac3b1a8f13 (patch)
treedf3b77139d25e117b0593551f232310cf3c6e69e
parentf98135b7a24a54964f83ca1dc2dfb6bd1d35b1bd (diff)
downloadrust-db6a916804ff7402ba70ca635e5071ac3b1a8f13.tar.gz
rust-db6a916804ff7402ba70ca635e5071ac3b1a8f13.zip
added --no-run option
-rw-r--r--src/librustdoc/config.rs5
-rw-r--r--src/librustdoc/doctest.rs4
-rw-r--r--src/librustdoc/lib.rs1
3 files changed, 8 insertions, 2 deletions
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 246e0ebbb2b..b70baff5511 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -121,6 +121,8 @@ crate struct Options {
     /// For example, using ignore-foo to ignore running the doctest on any target that
     /// contains "foo" as a substring
     crate enable_per_target_ignores: bool,
+    /// Compile test but do not run them.
+    crate no_run: bool,
 
     /// The path to a rustc-like binary to build tests with. If not set, we
     /// default to loading from `$sysroot/bin/rustc`.
@@ -196,6 +198,7 @@ impl fmt::Debug for Options {
             .field("runtool_args", &self.runtool_args)
             .field("enable-per-target-ignores", &self.enable_per_target_ignores)
             .field("run_check", &self.run_check)
+            .field("no_run", &self.no_run)
             .finish()
     }
 }
@@ -622,6 +625,7 @@ impl Options {
         let document_hidden = matches.opt_present("document-hidden-items");
         let run_check = matches.opt_present("check");
         let generate_redirect_map = matches.opt_present("generate-redirect-map");
+        let no_run = matches.opt_present("no-run");
 
         let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
 
@@ -658,6 +662,7 @@ impl Options {
             enable_per_target_ignores,
             test_builder,
             run_check,
+            no_run,
             render_options: RenderOptions {
                 output,
                 external_html,
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index 3d0ef028902..eded40916b5 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -291,7 +291,7 @@ fn run_test(
     for debugging_option_str in &options.debugging_opts_strs {
         compiler.arg("-Z").arg(&debugging_option_str);
     }
-    if no_run && !compile_fail {
+    if (no_run || options.no_run) && !compile_fail {
         compiler.arg("--emit=metadata");
     }
     compiler.arg("--target").arg(match target {
@@ -361,7 +361,7 @@ fn run_test(
         }
     }
 
-    if no_run {
+    if no_run || options.no_run {
         return Ok(());
     }
 
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index c6262f5873e..3a965101123 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -536,6 +536,7 @@ fn opts() -> Vec<RustcOptGroup> {
                 "[unversioned-shared-resources,toolchain-shared-resources,invocation-specific]",
             )
         }),
+        unstable("no-run", |o| o.optflag("", "no-run", "Compile, but don't run doc tests")),
     ]
 }