From b8dca6c82714d04a26071a48cd671ad707249950 Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Thu, 14 Nov 2019 07:26:22 -0800 Subject: [PATCH 1/2] Add --force-run-in-process unstable libtest option --- src/libtest/cli.rs | 4 ++++ src/libtest/lib.rs | 2 +- src/libtest/tests.rs | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libtest/cli.rs b/src/libtest/cli.rs index a34426305be2e..c97cb0e0605a2 100644 --- a/src/libtest/cli.rs +++ b/src/libtest/cli.rs @@ -13,6 +13,7 @@ pub struct TestOpts { pub list: bool, pub filter: Option, pub filter_exact: bool, + pub force_run_in_process: bool, pub exclude_should_panic: bool, pub run_ignored: RunIgnored, pub run_tests: bool, @@ -46,6 +47,7 @@ fn optgroups() -> getopts::Options { let mut opts = getopts::Options::new(); opts.optflag("", "include-ignored", "Run ignored and not ignored tests") .optflag("", "ignored", "Run only ignored tests") + .optflag("", "force-run-in-process", "Forces tests to run in-process when panic=abort") .optflag("", "exclude-should-panic", "Excludes tests marked as should_panic") .optflag("", "test", "Run tests and not benchmarks") .optflag("", "bench", "Run benchmarks instead of tests") @@ -233,6 +235,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes { let allow_unstable = get_allow_unstable(&matches)?; // Unstable flags + let force_run_in_process = unstable_optflag!(matches, allow_unstable, "force-run-in-process"); let exclude_should_panic = unstable_optflag!(matches, allow_unstable, "exclude-should-panic"); let include_ignored = unstable_optflag!(matches, allow_unstable, "include-ignored"); let time_options = get_time_options(&matches, allow_unstable)?; @@ -259,6 +262,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes { list, filter, filter_exact: exact, + force_run_in_process, exclude_should_panic, run_ignored, run_tests, diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 341a2e18db5fc..7647978b3d975 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -254,7 +254,7 @@ where let mut pending = 0; let (tx, rx) = channel::(); - let run_strategy = if opts.options.panic_abort { + let run_strategy = if opts.options.panic_abort && !opts.force_run_in_process { RunStrategy::SpawnPrimary } else { RunStrategy::InProcess diff --git a/src/libtest/tests.rs b/src/libtest/tests.rs index e0e211444cff5..5f55b647f5e78 100644 --- a/src/libtest/tests.rs +++ b/src/libtest/tests.rs @@ -24,6 +24,7 @@ impl TestOpts { list: false, filter: None, filter_exact: false, + force_run_in_process: false, exclude_should_panic: false, run_ignored: RunIgnored::No, run_tests: false, From d252ba35d490f16d2efefdedc581b1c9d6d64ecb Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Thu, 14 Nov 2019 07:26:41 -0800 Subject: [PATCH 2/2] Improve error message for tests with panic=abort --- src/libsyntax_ext/test_harness.rs | 3 ++- src/test/ui/test-panic-abort-disabled.rs | 2 +- src/test/ui/test-panic-abort-disabled.stderr | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libsyntax_ext/test_harness.rs b/src/libsyntax_ext/test_harness.rs index 1492f6f575ff7..659780d7a434b 100644 --- a/src/libsyntax_ext/test_harness.rs +++ b/src/libsyntax_ext/test_harness.rs @@ -67,7 +67,8 @@ pub fn inject( PanicStrategy::Unwind } (PanicStrategy::Abort, false) => { - span_diagnostic.err("building tests with panic=abort is not yet supported"); + span_diagnostic.err("building tests with panic=abort is not supported \ + without `-Zpanic_abort_tests`"); PanicStrategy::Unwind } (PanicStrategy::Unwind, _) => PanicStrategy::Unwind, diff --git a/src/test/ui/test-panic-abort-disabled.rs b/src/test/ui/test-panic-abort-disabled.rs index f24046ff0e8d2..4adb161d9ee4b 100644 --- a/src/test/ui/test-panic-abort-disabled.rs +++ b/src/test/ui/test-panic-abort-disabled.rs @@ -1,4 +1,4 @@ -// error-pattern:building tests with panic=abort is not yet supported +// error-pattern:building tests with panic=abort is not supported // no-prefer-dynamic // compile-flags: --test -Cpanic=abort // run-flags: --test-threads=1 diff --git a/src/test/ui/test-panic-abort-disabled.stderr b/src/test/ui/test-panic-abort-disabled.stderr index a8d9bad43ed3c..9c65c7360c108 100644 --- a/src/test/ui/test-panic-abort-disabled.stderr +++ b/src/test/ui/test-panic-abort-disabled.stderr @@ -1,4 +1,4 @@ -error: building tests with panic=abort is not yet supported +error: building tests with panic=abort is not supported without `-Zpanic_abort_tests` error: aborting due to previous error