Ten negations in tests/boot-test.bats assert nothing, including five of the six is_global_ipv6 refusals #10
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#10
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, so
! cmdon its own line decides the test when it is the final command of the body and is inert everywhere else.tests/boot-test.batshas ten inert negations, the largest group in one file in the organization.is_global_ipv6, five of six cases
Only the empty string ran. This is the predicate that picks the address the boot test then talks to, so link-local, loopback, multicast and an IPv4 address were all unchecked.
The rest
bt_is_container_namerefusing a leading dot and an empty string, the two LXC refuses.bt_is_appliance_name 9wordpress.bt_is_ssh_banner "220 ready"— the answer a mail server gives. The test is named "accepts an OpenSSH banner and nothing else" and the "nothing else" half did not run.bt_firstboot_done_inwith the flag stillRUN_FIRSTBOOT=true, which is the whole point of the predicate.bt_password_in_configwith the wrong password. The test read as though a mismatch was proven; only the empty file was.tests/hook.batsline 147 is in final position and does assert.What to do
Write every negation
run ! cmd, withbats_require_minimum_version 1.5.0, the seven in final position included, so that no line's meaning depends on its position.Test plan
shellcheck --severity=error --include=SC2314overtests/*.batsreports nothing.bats tests/*.batsgreen with the ten inert assertions live.tests/coverage.shat or above the committed threshold of 97.package / changelogpasses by reporting that nothing that ships changed.