Skip to content

Add --force-run-in-process unstable option to libtest #66415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/libsyntax_ext/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/libtest/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)?;
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/libtest/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/test-panic-abort-disabled.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/test-panic-abort-disabled.stderr
Original file line number Diff line number Diff line change
@@ -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