Search code examples
bazel

Avoid printing cached test passes in Bazel


In a mid-size monorepo, the bazel test //... run for a simple change prints almost a thousand lines of (cached) PASSED lines before finally printing:

Executed 0 out of 914 tests: 914 tests pass.

This is pretty harmless but annoying when a test does fail and you're trying to find out which one, especially as the GitHub Actions log viewer is sluggish when the logs are long.

Is there some way to omit (cached) PASSED lines from the output and only print the list of tests affected by this change?

One approach I've (briefly) considered is to use bazel-diff in the CI to avoid testing //... but instead calculate the list of affected tests - but this seems like it would be slower and more complex than relying on the RBE cache to track which tests need to be re-run. I've also considered piping the bazel output into grep but I'm hoping to avoid that.


Solution

  • You might be looking for --test_summary=terse.. "to print information only about unsuccessful tests that were run".