Skip to content

feat(cli): add --random-order and --seed to randomize test order#757

Merged
Chemaclass merged 2 commits into
mainfrom
feat/cli-random-order
Jul 10, 2026
Merged

feat(cli): add --random-order and --seed to randomize test order#757
Chemaclass merged 2 commits into
mainfrom
feat/cli-random-order

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #738

Tests that only pass in declaration order hide real bugs (leaked globals, shared temp files, ordering dependencies). Randomizing execution order surfaces that coupling, and a printed seed makes any failure reproducible.

💡 Changes

  • Add --random-order with --seed <n> / BASHUNIT_SEED to shuffle test-file order and per-file test order. Disabled by default.
  • A seeded Fisher-Yates makes the shuffle deterministic; each shuffle reseeds locally (seed mixed with a per-file checksum), so it is subshell-safe and works under --parallel.
  • The seed is printed in the run header (and generated when none is given) so a failing run can be replayed exactly. --seed alone is a no-op.
  • Docs (command-line + configuration) and CHANGELOG updated.

Shuffle test-file and per-file function execution order to surface hidden
inter-test coupling. A seeded Fisher-Yates (LCG) makes the shuffle reproducible;
each shuffle reseeds locally (mixing the seed with a per-file cksum), so it is
subshell-safe and works under --parallel. The seed is printed for replay and
generated when absent. --seed without --random-order is a no-op. Disabled by
default.

Closes #738
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 10, 2026
@Chemaclass Chemaclass self-assigned this Jul 10, 2026
The tests parsed colored console output, which varies by TTY/output-mode/locale
and failed in CI (empty capture; a color reset split 'seed:' from the number).
Record dispatch order to a file instead, and assert the seed label only.
@Chemaclass Chemaclass merged commit 8559caa into main Jul 10, 2026
31 checks passed
@Chemaclass Chemaclass deleted the feat/cli-random-order branch July 10, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant