Skip to content

Commit 4e6e1ec

Browse files
authored
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
2 parents e3c78d5 + d252ba3 commit 4e6e1ec

File tree

6 files changed

+10
-4
lines changed

6 files changed

+10
-4
lines changed

src/libsyntax_ext/test_harness.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ pub fn inject(
6767
PanicStrategy::Unwind
6868
}
6969
(PanicStrategy::Abort, false) => {
70-
span_diagnostic.err("building tests with panic=abort is not yet supported");
70+
span_diagnostic.err("building tests with panic=abort is not supported \
71+
without `-Zpanic_abort_tests`");
7172
PanicStrategy::Unwind
7273
}
7374
(PanicStrategy::Unwind, _) => PanicStrategy::Unwind,

src/libtest/cli.rs

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct TestOpts {
1313
pub list: bool,
1414
pub filter: Option<String>,
1515
pub filter_exact: bool,
16+
pub force_run_in_process: bool,
1617
pub exclude_should_panic: bool,
1718
pub run_ignored: RunIgnored,
1819
pub run_tests: bool,
@@ -46,6 +47,7 @@ fn optgroups() -> getopts::Options {
4647
let mut opts = getopts::Options::new();
4748
opts.optflag("", "include-ignored", "Run ignored and not ignored tests")
4849
.optflag("", "ignored", "Run only ignored tests")
50+
.optflag("", "force-run-in-process", "Forces tests to run in-process when panic=abort")
4951
.optflag("", "exclude-should-panic", "Excludes tests marked as should_panic")
5052
.optflag("", "test", "Run tests and not benchmarks")
5153
.optflag("", "bench", "Run benchmarks instead of tests")
@@ -233,6 +235,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes {
233235
let allow_unstable = get_allow_unstable(&matches)?;
234236

235237
// Unstable flags
238+
let force_run_in_process = unstable_optflag!(matches, allow_unstable, "force-run-in-process");
236239
let exclude_should_panic = unstable_optflag!(matches, allow_unstable, "exclude-should-panic");
237240
let include_ignored = unstable_optflag!(matches, allow_unstable, "include-ignored");
238241
let time_options = get_time_options(&matches, allow_unstable)?;
@@ -259,6 +262,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes {
259262
list,
260263
filter,
261264
filter_exact: exact,
265+
force_run_in_process,
262266
exclude_should_panic,
263267
run_ignored,
264268
run_tests,

src/libtest/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ where
254254
let mut pending = 0;
255255

256256
let (tx, rx) = channel::<CompletedTest>();
257-
let run_strategy = if opts.options.panic_abort {
257+
let run_strategy = if opts.options.panic_abort && !opts.force_run_in_process {
258258
RunStrategy::SpawnPrimary
259259
} else {
260260
RunStrategy::InProcess

src/libtest/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ impl TestOpts {
2424
list: false,
2525
filter: None,
2626
filter_exact: false,
27+
force_run_in_process: false,
2728
exclude_should_panic: false,
2829
run_ignored: RunIgnored::No,
2930
run_tests: false,

src/test/ui/test-panic-abort-disabled.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:building tests with panic=abort is not yet supported
1+
// error-pattern:building tests with panic=abort is not supported
22
// no-prefer-dynamic
33
// compile-flags: --test -Cpanic=abort
44
// run-flags: --test-threads=1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: building tests with panic=abort is not yet supported
1+
error: building tests with panic=abort is not supported without `-Zpanic_abort_tests`
22

33
error: aborting due to previous error
44

0 commit comments

Comments
 (0)