A negated command only asserts in final position #10
No reviewers
Labels
No labels
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/common!10
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?
The three negations in
tests/postfix-local.batsnow assert wherever they stand. One of them did not assert at all.Closes #9. 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
Line 96, in "stops at the first failing postconf". The test is named for stopping at the first failure, and
! logged smtpd_banneris the assertion that says it stopped — a script that carried on past the failingpostconfand set the banner anyway would have passed. Lines 66 and 97 are last in their bodies and did assert.All three are
run !now, the two that already asserted included: a line whose meaning depends on its position is the trap itself.The COVERAGE.md correction
COVERAGE.mdonfix/keel-apt-identity(#8) states:That is wrong about two of the three: 66 and 97 are in final position and do assert. This PR puts the accurate statement on
19.x, in the same place, so the branch is the record:That will conflict with #8, deliberately: the same paragraph in the same position, so whoever rebases #8 has to reconcile it rather than silently restore the wrong sentence. #8's version should be dropped on rebase.
Test plan
shellcheck -f gcc --shell=bash --severity=error --include=SC2314 tests/*.batsreports nothing.bats tests/postfix-local.batsgreen, 7 tests, with the inert assertion live. No assertion changed its verdict.tests/coverage.sh:postfix-local: 100.00 percent (17 of 17 lines) covered, threshold 100. Unchanged.COVERAGE.mdship nothing, sopackage / changelogpasses by reporting that nothing that ships changed. No changelog entry and no version bump.Reviewed: the three refutations go red when postfix-local is made to carry on past the failing postconf, and each fails with status 1. Merged 19.x (#8 landed) and folded its paragraph on bare negations in COVERAGE.md into this one, so the file says it once (
f858258).