A negated command only asserts in final position #5
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/unit-redis!5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "test/negations-that-assert"
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?
Every negation in these suites now asserts wherever it stands. Four did not assert at all, and they were the refutations this component exists to make.
Closes #4. Part of Keel-Linux/tracker#19, which has the organization-wide sweep.
Why a bare
!is inertA 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. shellcheck grades the two apart,error:for the inert ones andnote:for the rest:What was not being checked
localhost. That is the exact linedocs/traps.mdrecords the PostgreSQL appliance getting wrong — "On Debian,localhostis not an IPv6 name" — and the test written to stop it happening again did not run.adminuser and norequirepass. Those two are what make the duplicate user declaration impossible and keep the password off the disk at build time, which is the otherdocs/traps.mdentry. Only the third refusal,+@all, ran.requirepassline is anywhere in the shipped overlay. The comment above it calls this "the one property the whole design rests on".Two traps had a test each, and in both cases the test was inert. That is the shape of this defect: the refutation is the part a reader trusts most and the part the shell runs least.
All four become
run !, together with the six that were in final position and did assert: a line whose meaning depends on its position is the trap itself.tests/unit.batsgains thebats_require_minimum_version 1.5.0declaration the other two files already had.What was found
Nothing broken. Both fragments were rendered and read directly before the conversion: the bind fragment is
bind ::1 127.0.0.1and names no host, the acl fragment declaresuser default on nopass +infoand nothing else, and the overlay carries norequirepassand nomasterauth. The assertions were dead, not wrong.Test plan
Both rendered fragments and the shipped overlay read directly, before the conversion.
shellcheck -f gcc --shell=bash --severity=error --include=SC2314 tests/*.batsreports nothing.Every converted site audited for
runclobbering$output/$status/$lines; none here does.bats tests/*.batsgreen, 70 tests. No assertion changed its verdict.tests/coverage.sh: 100.00 percent, threshold 100. Unchanged.Tests ship nothing, so no changelog entry and no version bump.
Reviewed: every converted refutation goes red when its property is broken; adding
bind localhostto the bind fragment turns this branch red and leaves main green. Each fails with status 1. No changes needed.