Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a test until it fails

Tags:

bazel

In Bazel, you can re-run a test multiple times with:

bazel test --runs_per_test=<n> <target>

This is useful to reproduce conditions that lead a flaky test to fail.

The shortcoming of this approach, though, is that the tests will be run n times regardless of the results.

For tests that are flaky in very rare conditions, this means that you have to set n high, but this means you may have to scroll through a lot of text before you find the failing test's output.

Is there a built-in way in Bazel to run a test until it fails? Right now I'm using a while loop in Bash, which is good enough for my use case but not portable:

while bazel test --test_output=errors -t- <target_name>; do :; done
like image 270
stefanobaghino Avatar asked Oct 25 '25 03:10

stefanobaghino


1 Answers

Passing --notest_keep_going will cause Bazel to exit as soon as a test fails. So, you could use --notest_keep_going in combination with an absurdly high --runs_per_test.

like image 59
Benjamin Peterson Avatar answered Oct 27 '25 01:10

Benjamin Peterson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!