Problem
A bootstrap file that fails to load leaves the run with no tests, no summary,
and exit 0 — CI passes having executed nothing.
$ printf 'function broken( {\n' > boot.sh
$ BASHUNIT_BOOTSTRAP=boot.sh bashunit tests/
boot.sh: line 1: syntax error near unexpected token `{'
$ echo $?
0
A bootstrap containing a bare exit 3 is worse still: completely silent, exit 3,
no indication of the cause.
Why nothing caught it
[ -f "$BASHUNIT_BOOTSTRAP" ] && source "$BASHUNIT_BOOTSTRAP" cannot detect
this. source is a POSIX special builtin: a syntax error in the sourced
file, or a bare exit, terminates the shell at that point, so || status=$?
never runs and nothing after the call executes.
The --env/--boot flag path validates its file (#875, same bug class); the
BASHUNIT_BOOTSTRAP env path never did.
Fix
bash -n pre-validation would cost an interpreter fork on every invocation,
which bashunit_coldstart_forks_test.sh caps at 1 — and this repo has a
bootstrap, so all ~258 nested acceptance runs would pay it.
Instead: set a marker before sourcing, clear it after, and let the existing
EXIT trap report a marker that was never cleared. Fork-free, and it catches
both failure modes.
An absent bootstrap stays silent: BASHUNIT_BOOTSTRAP defaults to
tests/bootstrap.sh, which most projects do not have, so failing on it would
break every one of them.
Problem
A bootstrap file that fails to load leaves the run with no tests, no summary,
and exit 0 — CI passes having executed nothing.
A bootstrap containing a bare
exit 3is worse still: completely silent, exit 3,no indication of the cause.
Why nothing caught it
[ -f "$BASHUNIT_BOOTSTRAP" ] && source "$BASHUNIT_BOOTSTRAP"cannot detectthis.
sourceis a POSIX special builtin: a syntax error in the sourcedfile, or a bare
exit, terminates the shell at that point, so|| status=$?never runs and nothing after the call executes.
The
--env/--bootflag path validates its file (#875, same bug class); theBASHUNIT_BOOTSTRAPenv path never did.Fix
bash -npre-validation would cost an interpreter fork on every invocation,which
bashunit_coldstart_forks_test.shcaps at 1 — and this repo has abootstrap, so all ~258 nested acceptance runs would pay it.
Instead: set a marker before sourcing, clear it after, and let the existing
EXIT trap report a marker that was never cleared. Fork-free, and it catches
both failure modes.
An absent bootstrap stays silent:
BASHUNIT_BOOTSTRAPdefaults totests/bootstrap.sh, which most projects do not have, so failing on it wouldbreak every one of them.