From b8dca6c82714d04a26071a48cd671ad707249950 Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Thu, 14 Nov 2019 07:26:22 -0800 Subject: [PATCH] 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 a34426305be..c97cb0e0605 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 341a2e18db5..7647978b3d9 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -254,7 +254,7 @@ pub fn run_tests( 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 e0e211444cf..5f55b647f5e 100644 --- a/src/libtest/tests.rs +++ b/src/libtest/tests.rs @@ -24,6 +24,7 @@ fn new() -> TestOpts { list: false, filter: None, filter_exact: false, + force_run_in_process: false, exclude_should_panic: false, run_ignored: RunIgnored::No, run_tests: false, -- 2.44.0