Skip to content
5 changes: 5 additions & 0 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could tell others that this is the opposite of should_test?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the opposite, they do different things (and no_run requires should_test to also be set).

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`.
Expand Down Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -658,6 +662,7 @@ impl Options {
enable_per_target_ignores,
test_builder,
run_check,
no_run,
render_options: RenderOptions {
output,
external_html,
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Comment thread
jyn514 marked this conversation as resolved.
Outdated
compiler.arg("--emit=metadata");
}
compiler.arg("--target").arg(match target {
Expand Down Expand Up @@ -361,7 +361,7 @@ fn run_test(
}
}

if no_run {
if no_run || options.no_run {
return Ok(());
}

Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Comment thread
ABouttefeux marked this conversation as resolved.
Outdated
]
}

Expand Down