about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-11-15 18:02:01 +0100
committerGitHub <noreply@github.com>2019-11-15 18:02:01 +0100
commit4e6e1eccf1e512d1dee42ddad007b94f17b6e2de (patch)
tree8f889a71b3af7e66bd8722fedd8b79d6fa640ae0
parente3c78d549e0d8cdd3c05190e93f4ec7ff09a9ed1 (diff)
parentd252ba35d490f16d2efefdedc581b1c9d6d64ecb (diff)
downloadrust-4e6e1eccf1e512d1dee42ddad007b94f17b6e2de.tar.gz
rust-4e6e1eccf1e512d1dee42ddad007b94f17b6e2de.zip
Rollup merge of #66415 - tmandry:force-test-in-process, r=alexcrichton
Add --force-run-in-process unstable option to libtest

When running tests with `-Zpanic_abort_tests`, it's sometimes desirable to fall back to the old behavior of only running tests in-process. This comes in handy if the system process launcher is unavailable, or the test code somehow expects all tests to be run in the same process.

For example, in Fuchsia we have unit tests that actually test the process launcher itself, in which case we can't use the process launcher to run the tests :).

r? @alexcrichton
cc @cramertj,@petrhosek
-rw-r--r--src/libsyntax_ext/test_harness.rs3
-rw-r--r--src/libtest/cli.rs4
-rw-r--r--src/libtest/lib.rs2
-rw-r--r--src/libtest/tests.rs1
-rw-r--r--src/test/ui/test-panic-abort-disabled.rs2
-rw-r--r--src/test/ui/test-panic-abort-disabled.stderr2
6 files changed, 10 insertions, 4 deletions
diff --git a/src/libsyntax_ext/test_harness.rs b/src/libsyntax_ext/test_harness.rs
index 1492f6f575f..659780d7a43 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/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<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,
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 @@ where
     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
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 @@ 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,
diff --git a/src/test/ui/test-panic-abort-disabled.rs b/src/test/ui/test-panic-abort-disabled.rs
index f24046ff0e8..4adb161d9ee 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 a8d9bad43ed..9c65c7360c1 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