A negated command only asserts in final position #19
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-mariadb!19
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 four refusals of
bt_is_sql_literalnow assert wherever they stand. Three of them did not assert at all.Closes #18. 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
tests/boot-test.batslines 516–518: the empty string, a value with a single quote in it, and a value with a backslash. Onlytwo words, last in the body, decided anything.bt_is_sql_literalis the predicate that keeps the boot test from putting a value it did not generate inside single quotes in a statement — "a test that has to escape is a test building SQL out of something it did not generate", as the function's own comment puts it. Its quote and backslash cases are exactly the two that make that claim true, and neither was being run.All four become
run !, and so does the one intests/hook.bats, which was in final position and did assert: a line whose meaning depends on its position is the trap itself. The file already usedrun !at line 510, so the form and the 1.5.0 declaration were already here.What was found
Nothing broken. The four values were run against
bt_is_sql_literalby hand before the conversion, and all four are refused:[[ $value =~ ^[A-Za-z0-9:%._-]+$ ]]admits neither a quote, nor a backslash, nor a space, and the empty string is refused explicitly above it. The assertions were dead, not wrong.Test plan
The four values verified against the predicate by hand, before the conversion.
shellcheck -f gcc --shell=bash --severity=error --include=SC2314 tests/*.batsreports nothing.bats tests/*.batsgreen, 127 tests. No assertion changed its verdict.tests/coverage.sh, threshold 95, unchanged:Tests ship nothing, so
package / changelogpasses by reporting that nothing that ships changed. No changelog entry and no version bump.appliance / build-and-bootis gated onKEEL_LXC_RUNNERand is unaffected: nothing outsidetests/*.batschanged.Reviewed: every converted refutation goes red when the code under test accepts that call, and each fails with status 1. No changes needed; merged main so the renamed appliance check runs on this head.