Context
bashunit::helper::generate_id (src/helpers.sh:440) fires on every test export and every script load:
src/runner.sh:29 (per test)
src/runner.sh:192 (per file load)
src/runner.sh:317 (per bench file load)
Each call invokes bashunit::helper::normalize_variable_name plus, in parallel mode, bashunit::random_str (src/globals.sh:30) which loops $RANDOM 6 times for chars. Cheap per call, but multiplied across 800+ tests it adds noticeable overhead and one subshell capture per use (\$(bashunit::helper::generate_id ...)).
Proposal
- Cache normalized script id once per file load — reuse across tests in the same script.
- For per-test id, append a monotonic counter to the cached script id instead of recomputing:
: \$((_BASHUNIT_TEST_ID_SEQ += 1))
export BASHUNIT_CURRENT_TEST_ID=\"\${BASHUNIT_CURRENT_SCRIPT_ID}_\${_BASHUNIT_TEST_ID_SEQ}\"
- For parallel uniqueness, include
\$\$ (already done) — counter + PID guarantees uniqueness without random_str.
- Eliminate the
\$(...) capture at runner.sh:29 by writing directly to the env var.
Acceptance
Risk
- Test IDs used in
temp_file/temp_dir naming (src/globals.sh:41+). Verify no consumer expects random suffix.
Context
bashunit::helper::generate_id(src/helpers.sh:440) fires on every test export and every script load:src/runner.sh:29(per test)src/runner.sh:192(per file load)src/runner.sh:317(per bench file load)Each call invokes
bashunit::helper::normalize_variable_nameplus, in parallel mode,bashunit::random_str(src/globals.sh:30) which loops$RANDOM6 times for chars. Cheap per call, but multiplied across 800+ tests it adds noticeable overhead and one subshell capture per use (\$(bashunit::helper::generate_id ...)).Proposal
\$\$(already done) — counter + PID guarantees uniqueness withoutrandom_str.\$(...)capture atrunner.sh:29by writing directly to the env var.Acceptance
generate_idnot called per test in hot path (only per script)tests/unit/posted in PRRisk
temp_file/temp_dirnaming (src/globals.sh:41+). Verify no consumer expects random suffix.