Skip to content

Commit 4acf3ba

Browse files
committed
libtest: expose --fail-fast
1 parent 9c4ff56 commit 4acf3ba

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

library/test/src/cli.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn optgroups() -> getopts::Options {
5757
.optflag("", "test", "Run tests and not benchmarks")
5858
.optflag("", "bench", "Run benchmarks instead of tests")
5959
.optflag("", "list", "List all tests and benchmarks")
60+
.optflag("", "fail-fast", "Don't start new tests after the first failure")
6061
.optflag("h", "help", "Display this message")
6162
.optopt("", "logfile", "Write logs to the specified file (deprecated)", "PATH")
6263
.optflag(
@@ -270,6 +271,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes {
270271
let exact = matches.opt_present("exact");
271272
let list = matches.opt_present("list");
272273
let skip = matches.opt_strs("skip");
274+
let fail_fast = matches.opt_present("fail-fast");
273275

274276
let bench_benchmarks = matches.opt_present("bench");
275277
let run_tests = !bench_benchmarks || matches.opt_present("test");
@@ -307,7 +309,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes {
307309
skip,
308310
time_options,
309311
options,
310-
fail_fast: false,
312+
fail_fast,
311313
};
312314

313315
Ok(test_opts)

src/doc/rustc/src/tests/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ unstable-options` flag. See [tracking issue
158158

159159
The following options affect how tests are executed.
160160

161+
#### `--fail-fast`
162+
163+
Stops tests after the first failure.
164+
165+
If running tests in parallel (which is the default), then tests that have already been started on
166+
other threads will be allowed to run to completion before the process exits.
167+
168+
Note that when running tests in parallel, the test execution order is non-deterministic:
169+
if multiple tests would fail, the first failure encountered will be reported.
170+
161171
#### `--test-threads` _NUM_THREADS_
162172

163173
Sets the number of threads to use for running tests in parallel. By default,

0 commit comments

Comments
 (0)