Skip to content

investigation: audit acceptance suite for reclassification — 272 nested runs, ~28% of suite CPU is boot cost #831

Description

@Chemaclass

Context

Follow-up to #798 (closed) — the two structural directions it left unexplored, now with fresh numbers after #801-#818 and #830.

Current acceptance suite (61 files, macOS Bash 3.2, 2026-07-19):

Metric Value
Wall, --parallel (CI mode) 17.7s
Wall, sequential 94s
CPU, --parallel run ~90s
Nested ./bashunit spawn sites ~272
Cold start (--version) 53ms
Minimal nested run (1 noop test, --no-parallel) 91ms

Fixed floor: 272 × 91ms ≈ 25s CPU (~28% of the suite's CPU) is nested-run boot cost, before any fixture test executes. The rest is fixture bodies + parent overhead.

Task: audit, don't optimize (yet)

Phase 1 — categorize all 61 tests/acceptance/*_test.sh files. For each, decide:

  • A. True CLI-surface test — asserts on process-level behavior: exit codes, rendered console output/snapshots, flag parsing, env-file loading, signal handling, parallel worker behavior. Must stay acceptance. (Fork-census tests, snapshot tests, exit-code tests are all A.)
  • B. Function-level test in disguise — spawns ./bashunit but really asserts logic reachable by calling bashunit::* functions directly (like tests/functional/ and tests/unit/ do). Candidate for reclassification; each converted spawn saves ≥91ms CPU plus its fixture body cost.
  • C. Mixed — file contains both; note which tests are B.

Output: a table in this issue (file → A/B/C, spawn count, rough per-file wall time, notes). Per-file timing:

for f in tests/acceptance/*_test.sh; do
  s=$(python3 -c 'import time;print(int(time.time()*1e9))')
  ./bashunit "$f" >/dev/null 2>&1
  e=$(python3 -c 'import time;print(int(time.time()*1e9))')
  echo "$(( (e-s)/1000000 ))ms $f"
done | sort -rn

Phase 2 — file follow-up issues (one per coherent batch of B/C conversions, biggest measured win first). Do NOT convert anything in this issue's PR — the audit table and follow-up issues are the deliverable. A conversion batch only proceeds if Phase 1 shows ≥2s wall or ≥10s CPU win for the batch.

Secondary direction (measure only, likely reject)

Artifact sharing: sourcing src/ is ~31ms of the 53ms cold start; cap across 272 runs ≈ 8.4s CPU. Prior finding (#798/#761): the single-file bin/bashunit build is NOT faster to source (parse time dominates), and lazy-sourcing complicates the release build. Only pursue if Phase 1 leaves it as the dominant remaining cost — record the decision either way.

Constraints

  • Audit PR touches no runtime code; conversions (follow-ups) are strict TDD, one batch per PR
  • Reclassified tests must keep asserting the same behavior — no coverage loss; anything asserting on rendered output/exit codes stays acceptance
  • Fixture naming gotcha: files under tests/acceptance/fixtures/ must not match *[tT]est.sh (discovery-scan snapshots)
  • Bash 3.0+; full quality gate on every PR (./bashunit tests/, --parallel, --parallel --simple --strict, make sa, make lint)

Acceptance criteria

  • All 61 files categorized A/B/C with spawn counts and per-file timings, posted as a table on this issue
  • Measured estimate of total reclaimable wall/CPU from B+C conversions
  • Follow-up conversion issues filed (or explicit "not worth it" verdict with numbers)
  • Artifact-sharing direction: pursue/reject decision recorded with measurements

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions