Skip to content

perf(runner): unset each file's test functions after processing#830

Merged
Chemaclass merged 1 commit into
mainfrom
feat/829-unset-test-functions-per-file
Jul 19, 2026
Merged

perf(runner): unset each file's test functions after processing#830
Chemaclass merged 1 commit into
mainfrom
feat/829-unset-test-functions-per-file

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #829

Test files are sourced into the main shell and their functions stayed defined for the whole run. Every test executes in a $() subshell, so each fork copied an ever-growing shell — multi-file runs slowed down quadratically (last 18 unit files: 8.7s standalone, ~38s as the tail of the full run).

💡 Changes

  • Unset each file's test functions once the file has been processed, next to the existing hook cleanup; full pre-tag/rerun list, so filtered-out functions are cleaned too
  • Race-free in parallel mode: workers have already forked with their own copy when the parent unsets
  • unset -f is a builtin — no new forks, Bash 3.0-safe, fork-budget tests untouched
  • Unit suite ~64s → ~21.5s sequential, ~26s → ~7s parallel; full suite ~55s → ~24.5s parallel
  • Regression test: second fixture file asserts the first file's test functions are gone (sequential + parallel)

https://claude.ai/code/session_01JSeB8UzLCpqst55hAK6dED

Test files are sourced into the main shell and their functions stayed
defined for the whole run. Every test executes in a $() subshell, so
each fork copied an ever-growing shell and multi-file runs slowed down
quadratically: bashunit's own unit suite spent ~2s/file on its last
files vs 0.3s/file on its first (the last 18 files take 8.7s standalone
but ~38s as the tail of the full run).

Unset a file's test functions (full pre-tag/rerun list) next to the
existing hook cleanup. In parallel mode the file's workers have already
forked with their own copy by the time the parent unsets, so it is
race-free. unset -f is a builtin: no new forks, Bash 3.0-safe.

Unit suite: ~64s -> ~21.5s sequential, ~26s -> ~7s parallel.
Full suite: ~2m48s -> ~2m07s sequential, ~55s -> ~24.5s parallel.

Closes #829
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 19, 2026
@Chemaclass Chemaclass self-assigned this Jul 19, 2026
@Chemaclass
Chemaclass merged commit dd722c3 into main Jul 19, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the feat/829-unset-test-functions-per-file branch July 19, 2026 14:26
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