A bare ! in a bats body asserts nothing unless it is last: nine here, and no gate anywhere #13
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/.github#13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
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 — that exemption is in the shell by design, so a script can test a command without dying — so
! cmdon its own line decides the test when it is the final command of the body and is inert everywhere else. The line reads as a refutation either way.Measured 2026-09-28 over every default branch in the organization that carries a bats file (19 of them):
57 inert negations in 8 repositories, beside 45 that are in final position and do assert. shellcheck grades the two apart,
error:for the inert ones andnote:for the rest. Keel-Linux/tracker#19 has the full table.Two things are wanted here.
1. Nine inert negations in tests/boot-test-nodes.bats
lib/boot-test-nodes.shis the node topology this repository lends to every appliance gate, which is why it is tested here rather than copied. Its refusal cases mostly did not run:Primary,data_node,node.one,1node). Only the empty string ran.Keel,-leading-dash).localhost,127.0.0.1andfc42::1/64. Only the empty string ran.A role name becomes part of a container name and part of an environment variable name, and a node base is what LXC is handed as
--name, so these are the predicates that keep a malformed topology out of the runner.2. A gate, so the class cannot come back
test-shell.ymlalready runs shellcheck, but advisory (-S warning || true) and over a file list that excludes*.bats, so nothing has ever looked at this.Wanted: a step that runs shellcheck over
*.batswith SC2314 at error severity only, and fails the job. Severityerroris exactly the inert set; the final-position ones come back asnoteand must not be failures.Why here and not in each repository
Every repository with a bats suite already calls
test-shell.yml@main:apt,common,inithooks,keel-apache-php,keel-core,keel-mariadb,keel-nodebb,keel-postgresql,keel-redis,keel-transition,keel-wordpress,unit-mariadb,unit-postgresql,unit-redisand this repository itself. One step covers all of them, at once, and cannot drift. The alternative is the same few lines in fourteen workflows, and "copying a test library instead of sharing it" is already written down indocs/traps.mdas a mistake this project made and paid for twice.It should also run before the coverage work and without needing a coverage script: it needs nothing but a checkout, and a suite that is not asserting is not worth measuring.
keel-lampandkeel-lapphave bats suites and no workflows at all; both are clean today, but they will not be covered until they call the gate. Out of scope here.Merge order
This is
@main. The moment it lands, every repository that still has an inert negation goes red. It should merge after the eight repository pull requests in Keel-Linux/tracker#19.Test plan
shellcheck --severity=error --include=SC2314overtests/*.batshere reports nothing.actionlintgreen, including the shellcheck it runs over the newrunblock.bats tests/green andtests/coverage.shat the committed threshold of 100.