libtest: expose --fail-fast

This commit is contained in:
Martin Pool 2025-06-20 13:18:05 -07:00
parent 9c4ff566ba
commit 4acf3baecd
2 changed files with 13 additions and 1 deletions

View file

@ -57,6 +57,7 @@ fn optgroups() -> getopts::Options {
.optflag("", "test", "Run tests and not benchmarks")
.optflag("", "bench", "Run benchmarks instead of tests")
.optflag("", "list", "List all tests and benchmarks")
.optflag("", "fail-fast", "Don't start new tests after the first failure")
.optflag("h", "help", "Display this message")
.optopt("", "logfile", "Write logs to the specified file (deprecated)", "PATH")
.optflag(
@ -270,6 +271,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes {
let exact = matches.opt_present("exact");
let list = matches.opt_present("list");
let skip = matches.opt_strs("skip");
let fail_fast = matches.opt_present("fail-fast");
let bench_benchmarks = matches.opt_present("bench");
let run_tests = !bench_benchmarks || matches.opt_present("test");
@ -307,7 +309,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes {
skip,
time_options,
options,
fail_fast: false,
fail_fast,
};
Ok(test_opts)

View file

@ -158,6 +158,16 @@ unstable-options` flag. See [tracking issue
The following options affect how tests are executed.
#### `--fail-fast`
Stops tests after the first failure.
If running tests in parallel (which is the default), then tests that have already been started on
other threads will be allowed to run to completion before the process exits.
Note that when running tests in parallel, the test execution order is non-deterministic:
if multiple tests would fail, the first failure encountered will be reported.
#### `--test-threads` _NUM_THREADS_
Sets the number of threads to use for running tests in parallel. By default,