Skip to content

added --no-run option for rustdoc #83857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 1, 2021
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
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
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 @@ -198,6 +200,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 @@ -626,6 +629,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 @@ -662,6 +666,7 @@ impl Options {
enable_per_target_ignores,
test_builder,
run_check,
no_run,
render_options: RenderOptions {
output,
external_html,
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,13 +940,14 @@ impl Tester for Collector {
let report_unused_externs = |uext| {
unused_externs.lock().unwrap().push(uext);
};
let option_no_run = options.no_run;
let res = run_test(
&test,
&cratename,
line,
options,
config.should_panic,
config.no_run,
config.no_run || option_no_run,
config.test_harness,
runtool,
runtool_args,
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 doc tests without running it")),
]
}

Expand Down