diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2019-09-11 17:13:34 -0700 |
|---|---|---|
| committer | Tyler Mandry <tmandry@gmail.com> | 2019-09-28 13:52:18 -0700 |
| commit | 8ae1ec60cc16e5d2a3d522a2e3fdddd27e5fb4c9 (patch) | |
| tree | a2764361c43fe99fb568cd8c671d77883a1c7819 /src/libsyntax_ext | |
| parent | 76b12bd8fdd8c512cf9685a8ec51e76643f2f86f (diff) | |
| download | rust-8ae1ec60cc16e5d2a3d522a2e3fdddd27e5fb4c9.tar.gz rust-8ae1ec60cc16e5d2a3d522a2e3fdddd27e5fb4c9.zip | |
Spawn one subprocess per unit test when panic=abort
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/test_harness.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libsyntax_ext/test_harness.rs b/src/libsyntax_ext/test_harness.rs index fc1daa7d9b2..dcaf07341e5 100644 --- a/src/libsyntax_ext/test_harness.rs +++ b/src/libsyntax_ext/test_harness.rs @@ -2,6 +2,7 @@ use log::debug; use smallvec::{smallvec, SmallVec}; +use rustc_target::spec::PanicStrategy; use syntax::ast::{self, Ident}; use syntax::attr; use syntax::entry::{self, EntryPointType}; @@ -25,6 +26,7 @@ struct Test { struct TestCtxt<'a> { ext_cx: ExtCtxt<'a>, + panic_strategy: PanicStrategy, def_site: Span, test_cases: Vec<Test>, reexport_test_harness_main: Option<Symbol>, @@ -40,6 +42,7 @@ pub fn inject( krate: &mut ast::Crate, span_diagnostic: &errors::Handler, features: &Features, + panic_strategy: PanicStrategy, ) { // Check for #![reexport_test_harness_main = "some_name"] which gives the // main test function the name `some_name` without hygiene. This needs to be @@ -54,7 +57,7 @@ pub fn inject( if should_test { generate_test_harness(sess, resolver, reexport_test_harness_main, - krate, features, test_runner) + krate, features, panic_strategy, test_runner) } } @@ -183,6 +186,7 @@ fn generate_test_harness(sess: &ParseSess, reexport_test_harness_main: Option<Symbol>, krate: &mut ast::Crate, features: &Features, + panic_strategy: PanicStrategy, test_runner: Option<ast::Path>) { let mut econfig = ExpansionConfig::default("test".to_string()); econfig.features = Some(features); @@ -203,6 +207,7 @@ fn generate_test_harness(sess: &ParseSess, let cx = TestCtxt { ext_cx, + panic_strategy, def_site, test_cases: Vec::new(), reexport_test_harness_main, @@ -248,9 +253,14 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> { let ecx = &cx.ext_cx; let test_id = Ident::new(sym::test, sp); + let runner_name = match cx.panic_strategy { + PanicStrategy::Unwind => "test_main_static", + PanicStrategy::Abort => "test_main_static_abort", + }; + // test::test_main_static(...) let mut test_runner = cx.test_runner.clone().unwrap_or( - ecx.path(sp, vec![test_id, ecx.ident_of("test_main_static", sp)])); + ecx.path(sp, vec![test_id, ecx.ident_of(runner_name, sp)])); test_runner.span = sp; |
