Skip to content

Run tests in parallel with isolated per-test tmp locations for speed - #218

Merged
jmurty merged 1 commit into
elasticdog:mainfrom
mattmc3:parallel-tests
Jul 13, 2026
Merged

Run tests in parallel with isolated per-test tmp locations for speed#218
jmurty merged 1 commit into
elasticdog:mainfrom
mattmc3:parallel-tests

Conversation

@mattmc3

@mattmc3 mattmc3 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Addresses #217:

Makes the bats suite isolated and parallel-safe, per the approach
outlined in the issue I just opened:

  • Each test builds its git repo in $BATS_TEST_TMPDIR instead of the
    shared tests/ directory; bats owns cleanup, so nuke_git_repo,
    cleanup_all, and the flag-file guard are removed.
  • Tests call the script via absolute $TRANSCRYPT rather than
    cwd-relative ../transcrypt.
  • The helper exports GIT_CONFIG_GLOBAL=/dev/null and
    GIT_CONFIG_SYSTEM=/dev/null (git 2.32+), superseding the
    merge.conflictStyle workaround.
  • The crypt-dir tests use per-test paths instead of shared /tmp/crypt.
  • CI installs GNU parallel and runs bats --jobs 4 tests/.

No changes to the transcrypt script itself. Serial bats tests/ still
work, but new runs can specify bats --jobs 4 tests or however many make sense.

Local test timing: 95s serial → 26s with --jobs 16; 79/79 tests pass.

Note that the macOS users and GH runners needed to brew install parallel

Build each test's git repository in the bats-managed BATS_TEST_TMPDIR
instead of sharing the tests/ directory, and reference the transcrypt
script via an absolute $TRANSCRYPT path instead of cwd-relative
../transcrypt. Every test is now independent of the others, so the
suite can runs in parallel (eg: `bats --jobs 16` runs in 1/3 the time in testing).

Isolate tests from developer and system git config by exporting
GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM=/dev/null in the test helper,
which supersedes the per-setting merge.conflictStyle workaround and
protects against other leaking settings such as commit.gpgsign.

Also fix a latent race the parallel runs exposed: the crypt-dir tests
shared a hardcoded /tmp/crypt path and deleted it at start; each now
uses a path under BATS_TEST_TMPDIR. CI installs GNU parallel and runs
with --jobs 4.
@mattmc3

mattmc3 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

I'm happy to also submit on the transcript-v3 branch depending on how you decide to merge/rebase/cherry-pick/whatever.

@jmurty
jmurty merged commit a8c30fd into elasticdog:main Jul 13, 2026
7 checks passed
@jmurty

jmurty commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

This is a tremendous improvement @mattmc3, thanks very much!

@jmurty

jmurty commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Thanks for offering to deal with the transcrypt-v3 branch, but I have already merged main to that branch to get your test improvements along with other recent changes and that went smoothly enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants