Every negation in the bats suites asserts wherever it stands #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/inithooks!16
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 this suite now asserts wherever it stands. Twenty-two of the thirty-one did not.
Closes #15. 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 — that exemption is in the shell by design, so a script can test a command without dying — so
! cmddecides the test in final position and is inert everywhere else. The line reads as a refutation either way.shellcheck grades the two cases apart, which is what made an exact sweep possible:
error:is an inert one.note:is one in final position, which asserts today and stops asserting the moment a line is added after it.The headline: twelve of thirteen IPv6 rejection cases
tests/test-ipconfig.bats, "ip6_syntax rejects what is not an IPv6 address": thirteen cases, lines 324–336. Twelve were inert. Only1:2:3:4:5:6:7::8decided anything.Before changing them, each of the thirteen was run against
ipconfig_ip6_syntaxby hand, so that a green suite afterwards would be evidence rather than a coincidence. All thirteen are refused, and all eight of the acceptance cases are accepted. The validator is correct; it was the tests that were not running.That matters for what this PR claims: nothing shipped broken here. It is also luck, not evidence, and it is the reason the gate in
Keel-Linux/.githubexists rather than a note in a review.The rest
valid_configrefusingbogusand'',unchangedrefusing an absent stanza, the lxc build leaving noeth0,unchangedrefusing a mismatched inet6 confignat_availablefor a family with no nat table — the case the predicate exists for — and two processes that must be dead afterstop_mini_server@APP_NAME@does not survive the copy into the writable htdocsWhat changed
Every SC2314 site becomes
run ! cmd, the nine that were already in final position included, and each file declaresbats_require_minimum_version 1.5.0as the other suites in the organization do. Leaving half of them in the old shape would leave a reader to work out which half is real, and the guard reports severityerroronly, so a final-position!is not a failure — it is simply a line that will go inert when somebody appends to the body.One site was a pipeline and could not be prefixed:
runtakes a command, not a pipeline. The here-string is expanded beforerunexecutes, so it reads the output ofrun "$FENCE" startabove it.Test plan
The thirteen IPv6 rejection cases verified against the validator by hand, before the conversion. All refused.
shellcheck -f gcc --shell=bash --severity=error --include=SC2314 tests/*.batsreports nothing.Each converted assertion proven to bite: replacing one case with a valid address fails the test at that line.
bats tests/green, 112 tests. No assertion changed its verdict.tests/coverage.sh: 99.55 percent of measured lines, threshold 98. Unchanged.Tests ship nothing, so
package / changelogpasses by reporting that nothing that ships changed. No changelog entry and no version bump.Reviewed: all 31 converted refutations go red when the code under test accepts that call (the 13 ip6_syntax cases included), and none reads $output or $status from the run it replaced. One fails with status 3, from the stub, by design. No changes needed. Note: #18 and #14 still carry the old bare negations and will need the same conversion after a merge with master.