Repeated Bazel test runs and cached results
Recorded November 19, 2026. Bazel 9.2.0, macOS arm64, local execution.

This is a deliberately constructed test-run example, not a naturally flaky test,
a production workload, a performance benchmark, or a Hermetiq detection result.
fails_run_two reads Bazel's TEST_RUN_NUMBER and deliberately exits nonzero for
run 2. passes always exits successfully. The rule generates a shell executable;
it needs a POSIX shell. No remote cache, remote execution, or Hermetiq service
was used. Bazel may fetch its built-in module dependencies on first use.

Extract the ZIP into a new directory. With Bazelisk installed, .bazelversion
selects 9.2.0. These commands ignore machine/user rc files to keep this example
independent of your normal build endpoints. Run from the extracted directory:

bazel --ignore_all_rc_files test //:passes --nocache_test_results --test_output=all
bazel --ignore_all_rc_files test //:passes --test_output=all
bazel --ignore_all_rc_files test //:passes --nocache_test_results --test_output=all
bazel --ignore_all_rc_files test //:fails_run_two --nocache_test_results --runs_per_test=3 --flaky_test_attempts=1 --test_output=all

Expected and observed in the recorded run:
1. stable-fresh: exit 0, one passing test result, cachedLocally false.
2. stable-cached: exit 0, one passing test result, cachedLocally true.
3. stable-forced: exit 0, one passing test result, cachedLocally false.
4. repeated-failure: exit 3, runs 1 and 3 pass, run 2 fails; none cached locally.

The second command reports a previous result rather than a new execution.
Use BEP cachedLocally and test timing to identify that reuse; cached stdout may
still be displayed. --nocache_test_results forces new test execution without
turning off build-action caching. Setting --flaky_test_attempts=1 prevents
additional attempts for a failed run in this diagnostic example.

recorded/results.json is a summary checked against the saved BEP events.
recorded/*.bep.json contains selected original testResult, testSummary, and
buildFinished events, not the complete invocation stream. Paths in those events
refer to the original machine; the text logs are included separately. The local
output root used to record the example was /private/tmp/hermetiq-test-runs-root.
No timing improvement or production failure rate is inferred from this sample.

References:
https://bazel.build/reference/command-line-reference
https://bazel.build/reference/test-encyclopedia
