Skip to content

Add skip_test and --no-skip; fix a suite that reported green while dying - #25

Merged
helly25 merged 2 commits into
mainfrom
feat/skip-test
Aug 16, 2026
Merged

helly25 merged 2 commits into
mainfrom
feat/skip-test

Conversation

@helly25

@helly25 helly25 commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Add skip_test and --no-skip; fix a suite that reported green while dying

skip_test ends the test it is called from. Callers previously wrote
probe_capability && return at every site, because a bash function can
only return from itself - a skip helper that merely returns leaves the rest
of the body running. Test bodies now run in a SUBSHELL whose exit code
carries the verdict out (77 = skipped), which is what makes an immediate
abandon possible. Expectation errors live in a variable the subshell cannot
write back, so they are folded into that exit code inside it.

--no-skip turns every skip into a failure, for an environment that
GUARANTEES the capability a test probes for. That is not hypothetical: a
FUSE test suite skipped every mount and reported "PASSED in 0.1s" on a
machine that could mount, hiding the whole kernel path.

Adding the subshell surfaced something worse, which this also fixes. THIS
REPOSITORY'S OWN TEST SUITE WAS DYING AT CASE 5 OF 12 AND REPORTING PASS.
Two independent bugs stacked:

  • The EXIT trap's own last command became the script's exit status, so a
    rm returning 0 turned a fatal abort into success. The trap now
    captures the status first and re-exits with it.
  • bash 3.2 - which macOS ships - treats "${@}" and "${array[@]}" as
    unbound under set -u when empty, so passing an EMPTY array to
    expect_contains aborted the shell. Fixed in the library and in the
    tests that exercise it.

The suite now genuinely runs 10 of 10 rather than 4. A test framework
reporting green for tests it did not run is the worst bug it can have, so
this is the more important half of the change.

Verified: all 5 targets pass; skip counters asserted after test_runner
(a skipped test cannot assert about itself); the body-continues-past-skip
case fails loudly if the subshell ever goes away; --no-skip exercised
through the real flag parser, not just the variable.

Note on the version: bumped 0.5.1 -> 0.6.0. The subshell means a test body can no longer leak variables into later tests, which is a behaviour change even though it is the safer semantics.

skip_test ends the test it is called from. Callers previously wrote
`probe_capability && return` at every site, because a bash function can
only return from itself - a skip helper that merely returns leaves the rest
of the body running. Test bodies now run in a SUBSHELL whose exit code
carries the verdict out (77 = skipped), which is what makes an immediate
abandon possible. Expectation errors live in a variable the subshell cannot
write back, so they are folded into that exit code inside it.

--no-skip turns every skip into a failure, for an environment that
GUARANTEES the capability a test probes for. That is not hypothetical: a
FUSE test suite skipped every mount and reported "PASSED in 0.1s" on a
machine that could mount, hiding the whole kernel path.

Adding the subshell surfaced something worse, which this also fixes. THIS
REPOSITORY'S OWN TEST SUITE WAS DYING AT CASE 5 OF 12 AND REPORTING PASS.
Two independent bugs stacked:

  - The EXIT trap's own last command became the script's exit status, so a
    `rm` returning 0 turned a fatal abort into success. The trap now
    captures the status first and re-exits with it.
  - bash 3.2 - which macOS ships - treats "${@}" and "${array[@]}" as
    unbound under `set -u` when empty, so passing an EMPTY array to
    expect_contains aborted the shell. Fixed in the library and in the
    tests that exercise it.

The suite now genuinely runs 10 of 10 rather than 4. A test framework
reporting green for tests it did not run is the worst bug it can have, so
this is the more important half of the change.

Verified: all 5 targets pass; skip counters asserted after test_runner
(a skipped test cannot assert about itself); the body-continues-past-skip
case fails loudly if the subshell ever goes away; --no-skip exercised
through the real flag parser, not just the variable.
@helly25
helly25 enabled auto-merge (squash) August 16, 2026 20:27
@helly25
helly25 requested a review from Fab-Cat August 16, 2026 20:46
@helly25
helly25 merged commit 2f2aa78 into main Aug 16, 2026
4 checks passed
@helly25
helly25 deleted the feat/skip-test branch August 16, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants