docs: the trap of a bats negation that is not the last command #16
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Keel-Linux/handbook!16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "docs/trap-inert-negation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
One entry in
docs/traps.md: a negative test that passes whatever the code does.Closes #15. Part of Keel-Linux/tracker#19, which has the organization-wide sweep.
Why it earns an entry
A bats test body has no assertions of its own: its verdict is the exit status of the last command it ran. Bash does not apply errexit to a negated command, so
! cmddecides the test in final position and is inert everywhere else. The broken shape and the working shape are one word apart, the broken one reads correctly, and which one a line is depends only on where it sits — so a reviewer cannot see it and a passing suite does not reveal it.Measured 2026-09-28 across every default branch in the organization that carries a bats file, 19 of them: 57 inert negations in 8 repositories, out of 102.
Two entries already in this file had a regression test written for them, and both tests were inert:
unit-redis's refutation that the bind fragment never sayslocalhost(the entry "On Debian,localhostis not an IPv6 name") and its refutation that noadminaccount is declared at build time (the entry about a Redis ACL user being declared once). A trap with a dead test is a trap with no test.The entry follows the shape of the others
Signature, cause, fix, where it is enforced, and what it cost — plus the shellcheck invocation and the distinction shellcheck draws between
error:(inert) andnote:(final position, still asserting), which is what makes a sweep exact rather than a judgement call.It also carries the two things that bite while converting, because both were hit:
runreplaces$output,$statusand$lines, so a body that refutes something and then reads the output of what it was refuting has to keep that output in a local first — otherwise the second refutation greps an empty string and passes for a new reason. That happened inkeel-nodebband is green by construction, so the suite cannot catch it.runtakes a command, not a pipeline:! a | grep -q bhas to be rewritten, not prefixed. That happened ininithooks.And it says plainly that every predicate turned out to be correct, so nothing shipped broken, and that this is luck rather than evidence — naming the one assertion that did fail when it was turned on,
keel-nodebb's unanchored! grep -q set_real_ip_fromagainst a file whose own comment names the directive, which could never have passed for any input.Where it sits
Last of the numbered traps, before "Things we did wrong and would do again unless written down", in the file's own order of addition.
Test plan
docs/traps.mdentries it cross-references checked to exist and to say what the new entry says they say.Merged main (the entry now follows the three that landed there), removed the four em dashes, and described the gate as it is after Keel-Linux/.github#14 6372ac2 (SC2315 and nested negations). Added one more thing to check when converting:
run !passes on 127 and on grep's 2.