Skip to content

Commit 625a635

Browse files
Correctly handle should_panic on targets not supporting it
1 parent 030b664 commit 625a635

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/librustdoc/doctest/runner.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,15 @@ fn main() {returns_result} {{
266266
)
267267
.unwrap();
268268
}
269-
let not_running = ignore || scraped_test.no_run(opts);
269+
let should_panic = scraped_test.langstr.should_panic;
270+
// On some platforms, exit code can only be 0 or 1, preventing us to actually know if it's a
271+
// panic. In this case, we ignore the tests with `should_panic`.
272+
//
273+
// Emscripten can catch panics but other wasm targets cannot
274+
let ignore_because_no_process_support = should_panic
275+
&& (cfg!(target_family = "wasm") || cfg!(target_os = "zkvm"))
276+
&& !cfg!(target_os = "emscripten");
277+
let not_running = ignore_because_no_process_support || ignore || scraped_test.no_run(opts);
270278
writeln!(
271279
output_merged_tests,
272280
"
@@ -294,7 +302,6 @@ if let Some(bin_path) = crate::__doctest_mod::doctest_path() {{
294302
test::assert_test_result(doctest_bundle::{test_id}::__main_fn())
295303
}}
296304
",
297-
should_panic = scraped_test.langstr.should_panic,
298305
)
299306
},
300307
)

0 commit comments

Comments
 (0)