fix(test): bail correctly halts current run in watch mode

AB
1y ago
+42-5

What & Why

Running `bun test --watch --bail N` exited the process after N failures, killing watch mode.

This patch makes bail cooperative in watch mode:

  • When the failure threshold is hit the reporter sets `TestRunner.should_abort`.
  • Execution loops break early; the process stays alive waiting for file changes.
  • Outside watch mode the behaviour is unchanged (still exits non-zero).

Implementation Highlights

  • Added `should_abort` flag to `TestRunner` (renamed from `stop_current_run`).
  • Guard checks inserted in main loops; flag reset each run.
  • Doc-comments and minor DRY clean-ups.

Ready for review 🚀