Skip to content

Commit 71010bd

Browse files
Correctly handle --no-run rustdoc test option
1 parent 855e0fe commit 71010bd

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/librustdoc/doctest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ pub(crate) fn run_tests(
312312
);
313313

314314
for (doctest, scraped_test) in &doctests {
315-
tests_runner.add_test(doctest, scraped_test, &target_str);
315+
tests_runner.add_test(doctest, scraped_test, &target_str, rustdoc_options);
316316
}
317317
if let Ok(success) = tests_runner.run_merged_tests(
318318
rustdoc_test_options,

src/librustdoc/doctest/runner.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl DocTestRunner {
3838
doctest: &DocTestBuilder,
3939
scraped_test: &ScrapedDocTest,
4040
target_str: &str,
41+
opts: &RustdocOptions,
4142
) {
4243
let ignore = match scraped_test.langstr.ignore {
4344
Ignore::All => true,
@@ -61,6 +62,7 @@ impl DocTestRunner {
6162
self.nb_tests,
6263
&mut self.output,
6364
&mut self.output_merged_tests,
65+
opts,
6466
),
6567
));
6668
self.supports_color &= doctest.supports_color;
@@ -218,6 +220,7 @@ fn generate_mergeable_doctest(
218220
id: usize,
219221
output: &mut String,
220222
output_merged_tests: &mut String,
223+
opts: &RustdocOptions,
221224
) -> String {
222225
let test_id = format!("__doctest_{id}");
223226

@@ -251,7 +254,7 @@ fn main() {returns_result} {{
251254
)
252255
.unwrap();
253256
}
254-
let not_running = ignore || scraped_test.langstr.no_run;
257+
let not_running = ignore || scraped_test.no_run(opts);
255258
writeln!(
256259
output_merged_tests,
257260
"
@@ -265,7 +268,7 @@ test::StaticTestFn(
265268
test_name = scraped_test.name,
266269
file = scraped_test.path(),
267270
line = scraped_test.line,
268-
no_run = scraped_test.langstr.no_run,
271+
no_run = scraped_test.no_run(opts),
269272
should_panic = !scraped_test.langstr.no_run && scraped_test.langstr.should_panic,
270273
// Setting `no_run` to `true` in `TestDesc` still makes the test run, so we simply
271274
// don't give it the function to run.

0 commit comments

Comments
 (0)