You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement the hybrid coverage engine recommended by ADR-009 (spike #859): use set -x β a dedicated BASH_XTRACEFD, parsed offline, on Bash 4.1+; keep the current DEBUG-trap engine as the fallback on the Bash 3.0β4.0 floor. Selected via BASHUNIT_COVERAGE_ENGINE=auto|xtrace|trap (auto = xtrace iff BASH_XTRACEFD exists).
Measured payoff (ADR-009): ~6Γ lower per-line cost (bash 3.2 +0.855sβ+0.127s; bash 5 +0.730sβ+0.131s) β enough to make --coverage a candidate for a gating CI job instead of nightly-only.
xtrace engine: per-run (and per-worker) trace file on a dedicated fd; PS4='@@${BASH_SOURCE}:${LINENO} '; offline parser producing the same covered-line set + branch inputs the trap path feeds today.
Per-test attribution: emit a sentinel line into the trace at each test boundary (replaces _BASHUNIT_COVERAGE_CURRENT_TEST_*); partition the parse by sentinel.
Sandbox self-instrumentation: save/restore PS4/BASH_XTRACEFD/set -x around test bodies so a test using set -x doesn't corrupt (or get corrupted by) the engine.
--parallel: one trace file per worker, merged like the per-$$ data files.
Framework-line filtering via the existing should_track path rules.
β Acceptance criteria
Byte-for-byte identical coverage output (covered-line set, branch arms, per-test attribution, LCOV) between xtrace and trap engines across the coverage fixture suite β pin this as the RED test (engine equivalence oracle).
auto selects trap on Bash <4.1 and xtrace on β₯4.1; all three modes forced-selectable.
--parallel coverage correct under both engines.
No regression to the Bash 3.0 floor (trap path unchanged there).
Only after equivalence is proven: consider promoting --coverage to a gating workflow.
βοΈ Constraints
Bash 3.0+ core; xtrace path is strictly a 4.1+ fast path with the trap fallback intact.
Do not flip the default engine until equivalence is green on all platforms (Linux/macOS/Windows-bash, Bash 3.2β5).
π― Goal
Implement the hybrid coverage engine recommended by ADR-009 (spike #859): use
set -xβ a dedicatedBASH_XTRACEFD, parsed offline, on Bash 4.1+; keep the currentDEBUG-trap engine as the fallback on the Bash 3.0β4.0 floor. Selected viaBASHUNIT_COVERAGE_ENGINE=auto|xtrace|trap(auto= xtrace iffBASH_XTRACEFDexists).Measured payoff (ADR-009): ~6Γ lower per-line cost (bash 3.2 +0.855sβ+0.127s; bash 5 +0.730sβ+0.131s) β enough to make
--coveragea candidate for a gating CI job instead of nightly-only.π Context
DEBUGtrap βbashunit::coverage::record_lineper line (src/coverage.sh:126). The trap dispatch dominates cost (proven by perf(coverage): dedup line hits at source in the DEBUG trapΒ #853: dedup was break-even).adrs/adr-009-coverage-tracing-engine.md. Reproducible benchmark:adrs/assets/adr-009-cov-engine-bench.sh.π§ Scope
BASHUNIT_COVERAGE_ENGINE(defaultauto);autoprobesBASH_XTRACEFDavailability once.PS4='@@${BASH_SOURCE}:${LINENO} '; offline parser producing the same covered-line set + branch inputs the trap path feeds today._BASHUNIT_COVERAGE_CURRENT_TEST_*); partition the parse by sentinel.PS4/BASH_XTRACEFD/set -xaround test bodies so a test usingset -xdoesn't corrupt (or get corrupted by) the engine.--parallel: one trace file per worker, merged like the per-$$data files.should_trackpath rules.β Acceptance criteria
xtraceandtrapengines across the coverage fixture suite β pin this as the RED test (engine equivalence oracle).autoselects trap on Bash <4.1 and xtrace on β₯4.1; all three modes forced-selectable.--parallelcoverage correct under both engines.--coverageto a gating workflow.βοΈ Constraints
Follow-up to the #854 spike / ADR-009.