@@ -129,13 +129,15 @@ mod __doctest_mod {{
129
129
}}
130
130
131
131
#[allow(unused)]
132
- pub fn doctest_runner(bin: &std::path::Path, test_nb: usize) -> ExitCode {{
132
+ pub fn doctest_runner(bin: &std::path::Path, test_nb: usize, should_panic: bool ) -> ExitCode {{
133
133
let out = std::process::Command::new(bin)
134
134
.env(self::RUN_OPTION, test_nb.to_string())
135
135
.args(std::env::args().skip(1).collect::<Vec<_>>())
136
136
.output()
137
137
.expect(\" failed to run command\" );
138
- if !out.status.success() {{
138
+ if should_panic && out.status.code() != Some(101) {{
139
+ eprintln!(\" Test didn't panic, but it's marked `should_panic`.\" );
140
+ }} else if !out.status.success() {{
139
141
if let Some(code) = out.status.code() {{
140
142
eprintln!(\" Test executable failed (exit status: {{code}}).\" );
141
143
}} else {{
@@ -257,7 +259,7 @@ fn main() {returns_result} {{
257
259
"
258
260
mod {test_id} {{
259
261
pub const TEST: test::TestDescAndFn = test::TestDescAndFn::new_doctest(
260
- {test_name:?}, {ignore}, {file:?}, {line}, {no_run}, {should_panic} ,
262
+ {test_name:?}, {ignore}, {file:?}, {line}, {no_run}, false ,
261
263
test::StaticTestFn(
262
264
|| {{{runner}}},
263
265
));
@@ -266,7 +268,6 @@ test::StaticTestFn(
266
268
file = scraped_test. path( ) ,
267
269
line = scraped_test. line,
268
270
no_run = scraped_test. langstr. no_run,
269
- should_panic = !scraped_test. langstr. no_run && scraped_test. langstr. should_panic,
270
271
// Setting `no_run` to `true` in `TestDesc` still makes the test run, so we simply
271
272
// don't give it the function to run.
272
273
runner = if not_running {
@@ -275,11 +276,12 @@ test::StaticTestFn(
275
276
format!(
276
277
"
277
278
if let Some(bin_path) = crate::__doctest_mod::doctest_path() {{
278
- test::assert_test_result(crate::__doctest_mod::doctest_runner(bin_path, {id}))
279
+ test::assert_test_result(crate::__doctest_mod::doctest_runner(bin_path, {id}, {should_panic} ))
279
280
}} else {{
280
281
test::assert_test_result(doctest_bundle::{test_id}::__main_fn())
281
282
}}
282
283
" ,
284
+ should_panic = !scraped_test. langstr. no_run && scraped_test. langstr. should_panic,
283
285
)
284
286
} ,
285
287
)
0 commit comments