Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit db6a916

Browse files
committed
added --no-run option
1 parent f98135b commit db6a916

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/librustdoc/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ crate struct Options {
121121
/// For example, using ignore-foo to ignore running the doctest on any target that
122122
/// contains "foo" as a substring
123123
crate enable_per_target_ignores: bool,
124+
/// Compile test but do not run them.
125+
crate no_run: bool,
124126

125127
/// The path to a rustc-like binary to build tests with. If not set, we
126128
/// default to loading from `$sysroot/bin/rustc`.
@@ -196,6 +198,7 @@ impl fmt::Debug for Options {
196198
.field("runtool_args", &self.runtool_args)
197199
.field("enable-per-target-ignores", &self.enable_per_target_ignores)
198200
.field("run_check", &self.run_check)
201+
.field("no_run", &self.no_run)
199202
.finish()
200203
}
201204
}
@@ -622,6 +625,7 @@ impl Options {
622625
let document_hidden = matches.opt_present("document-hidden-items");
623626
let run_check = matches.opt_present("check");
624627
let generate_redirect_map = matches.opt_present("generate-redirect-map");
628+
let no_run = matches.opt_present("no-run");
625629

626630
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
627631

@@ -658,6 +662,7 @@ impl Options {
658662
enable_per_target_ignores,
659663
test_builder,
660664
run_check,
665+
no_run,
661666
render_options: RenderOptions {
662667
output,
663668
external_html,

src/librustdoc/doctest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ fn run_test(
291291
for debugging_option_str in &options.debugging_opts_strs {
292292
compiler.arg("-Z").arg(&debugging_option_str);
293293
}
294-
if no_run && !compile_fail {
294+
if (no_run || options.no_run) && !compile_fail {
295295
compiler.arg("--emit=metadata");
296296
}
297297
compiler.arg("--target").arg(match target {
@@ -361,7 +361,7 @@ fn run_test(
361361
}
362362
}
363363

364-
if no_run {
364+
if no_run || options.no_run {
365365
return Ok(());
366366
}
367367

src/librustdoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ fn opts() -> Vec<RustcOptGroup> {
536536
"[unversioned-shared-resources,toolchain-shared-resources,invocation-specific]",
537537
)
538538
}),
539+
unstable("no-run", |o| o.optflag("", "no-run", "Compile, but don't run doc tests")),
539540
]
540541
}
541542

0 commit comments

Comments
 (0)