]> git.lizzy.rs Git - rust.git/commitdiff
Add --force-run-in-process unstable libtest option
authorTyler Mandry <tmandry@gmail.com>
Thu, 14 Nov 2019 15:26:22 +0000 (07:26 -0800)
committerTyler Mandry <tmandry@gmail.com>
Fri, 15 Nov 2019 13:52:06 +0000 (05:52 -0800)
src/libtest/cli.rs
src/libtest/lib.rs
src/libtest/tests.rs

index a34426305be2e82a87ac6d209b973f78a86bff1d..c97cb0e0605a220ba4afb255356de3f45493fb21 100644 (file)
@@ -13,6 +13,7 @@ pub struct TestOpts {
     pub list: bool,
     pub filter: Option<String>,
     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,
index 341a2e18db5fcfd50f449851647a41f74512c12f..7647978b3d975dfd0f69667ecf4a95bc6953caf9 100644 (file)
@@ -254,7 +254,7 @@ pub fn run_tests<F>(
     let mut pending = 0;
 
     let (tx, rx) = channel::<CompletedTest>();
-    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
index e0e211444cff5a2bfe02f340713dbe5a2afeae08..5f55b647f5e78f6470ce34621df048bfbfd217eb 100644 (file)
@@ -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,