Skip to content

A broken bootstrap runs no tests and exits 0 #1179

Description

@Chemaclass

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions