A negated command only asserts in final position #11
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/keel-wordpress!11
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. Ten did not assert at all, the largest group in one file in the organization.
Closes #10. 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
fe80::1,FE80::1,::1,ff02::1and an IPv4 address were unchecked. This is the predicate that picks the address the boot test then talks to.bt_is_container_namerefusing a leading dot and an empty string, the two LXC refusesbt_is_appliance_name 9wordpressbt_is_ssh_banner "220 ready"— the answer a mail server gives. The test is named "accepts an OpenSSH banner and nothing else"; the "nothing else" half did not run.bt_firstboot_done_inwith the flag stillRUN_FIRSTBOOT=true, which is the whole point of the predicatebt_password_in_configwith the wrong password. The test read as though a mismatch was proven and only the empty file was.All of them are
run !now, together with the seven that were in final position and did assert: a line whose meaning depends on its position is the trap itself.What was found
Nothing broken. Every predicate was run against every one of its cases by hand before the conversion, and each answers as its test believed:
bt_is_global_ipv6refuses all five refusal cases and accepts all three acceptance cases,bt_is_ssh_bannerrefuses220 ready,bt_password_in_configrefuses the wrong password, and so on. The assertions were dead, not wrong.That is luck rather than evidence, which is why the sweep comes with a gate in
Keel-Linux/.githuband adocs/traps.mdentry.Test plan
Every predicate verified against every one of its cases by hand, 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, 196 tests. No assertion changed its verdict.tests/coverage.sh, threshold 97, unchanged:Tests ship nothing, so
package / changelogpasses by reporting that nothing that ships changed. No changelog entry and no version bump.Reviewed: every converted refutation goes red when the code under test accepts that call (all six is_global_ipv6 cases included), and each fails with status 1. No changes needed; merged main so the renamed appliance check runs on this head. Note: #6 adds tests/wrappers.bats with three new bare negations, which the gate will refuse.