diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2019-09-19 19:33:38 -0700 |
|---|---|---|
| committer | Tyler Mandry <tmandry@gmail.com> | 2019-09-28 13:52:18 -0700 |
| commit | 3f0254e3cf7656bd3726372106e98532b1575e2d (patch) | |
| tree | e2cf06f66e1845663d511f82b70a9b90093e5ad4 /src/libsyntax_ext/test_harness.rs | |
| parent | 88376842a0592937bb807c8ec7a685946db96ea7 (diff) | |
| download | rust-3f0254e3cf7656bd3726372106e98532b1575e2d.tar.gz rust-3f0254e3cf7656bd3726372106e98532b1575e2d.zip | |
Put panic=abort test support behind -Z panic_abort_tests
Diffstat (limited to 'src/libsyntax_ext/test_harness.rs')
| -rw-r--r-- | src/libsyntax_ext/test_harness.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libsyntax_ext/test_harness.rs b/src/libsyntax_ext/test_harness.rs index dcaf07341e5..f79ad1419e0 100644 --- a/src/libsyntax_ext/test_harness.rs +++ b/src/libsyntax_ext/test_harness.rs @@ -43,6 +43,8 @@ pub fn inject( span_diagnostic: &errors::Handler, features: &Features, panic_strategy: PanicStrategy, + platform_panic_strategy: PanicStrategy, + enable_panic_abort_tests: bool, ) { // Check for #![reexport_test_harness_main = "some_name"] which gives the // main test function the name `some_name` without hygiene. This needs to be @@ -56,6 +58,20 @@ pub fn inject( let test_runner = get_test_runner(span_diagnostic, &krate); if should_test { + let panic_strategy = match (panic_strategy, enable_panic_abort_tests) { + (PanicStrategy::Abort, true) => + PanicStrategy::Abort, + (PanicStrategy::Abort, false) if panic_strategy == platform_panic_strategy => { + // Silently allow compiling with panic=abort on these platforms, + // but with old behavior (abort if a test fails). + PanicStrategy::Unwind + } + (PanicStrategy::Abort, false) => { + span_diagnostic.err("building tests with panic=abort is not yet supported"); + PanicStrategy::Unwind + } + (PanicStrategy::Unwind, _) => PanicStrategy::Unwind, + }; generate_test_harness(sess, resolver, reexport_test_harness_main, krate, features, panic_strategy, test_runner) } |
