Negations that assert, and a gate so the class cannot come back #14
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/.github!14
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?
Nine inert negations here, and the gate that stops the class coming back anywhere.
Closes #13. 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:Measured over every default branch in the organization that carries a bats file, 19 of them: 57 inert negations in 8 repositories, beside 45 in final position that do assert.
What was not being checked here
tests/boot-test-nodes.bats, overlib/boot-test-nodes.sh— the node topology this repository lends to every appliance gate:Primary,data_node,node.one,1node). Only""ran.Keel,-leading-dash).localhost,127.0.0.1,fc42::1/64. Only""ran.A role name becomes part of a container name and part of an environment variable name; a node base is what LXC is handed as
--name. All nine arerun !now, with the three that were in final position and did assert, because a line whose meaning depends on its position is the trap itself.Every predicate was run against every one of its cases by hand before the conversion, and each answers as its test believed. The assertions were dead, not wrong.
The gate
A new step in
test-shell.yml,Negations that assert (SC2314):--include=SC2314with--severity=errorreports exactly the inert set: the final-position negations come back asnoteand are filtered out, so a suite that is merely fragile is not a failure.git ls-filesalso means an untracked second clone inside a working tree is not scanned. Findings go to the step summary and the job fails.It runs straight after checkout, before the kcov build, and it is not gated on the coverage script existing: it needs only a checkout, and a suite that is not asserting is not worth measuring. It installs shellcheck only if the runner has none.
The existing advisory shellcheck step is left exactly as it is.
Why here rather than in each repository
Every repository with a bats suite already calls
test-shell.yml@main—apt,common,inithooks,keel-apache-php,keel-core,keel-mariadb,keel-nodebb,keel-postgresql,keel-redis,keel-transition,keel-wordpress,unit-mariadb,unit-postgresql,unit-redis, and this repository. One step covers fifteen repositories and cannot drift out of step with itself. The alternative is the same lines in fifteen workflows, and "copying a test library instead of sharing it" is already indocs/traps.mdas a mistake this project made and then had to pay for twice.lib/boot-test-nodes.shlives here for the same reason.The gap it does not close:
keelhas a bats suite that it runs from pytest throughtest-python.yml, so this step does not reach it. It is clean today. (keel-lamp,keel-lappandtkldevdo calltest-shell.yml, so they are covered: eighteen repositories with a bats suite, not fifteen.)Review addendum (
6372ac2). The step as first written saw only what shellcheck's SC2314 sees. It now also includes SC2315 (! [[ ... ]]), and a short awk program reports the negations shellcheck cannot see, one level down in a test body:a && ! b,! cmdin a loop, a branch, a case arm, a group or a substitution, on any line but the body's last. Each of those forms was written into a bats file and run: bats passed all of them and shellcheck reported none. Over every default branch and every open pull request head in the organization, the awk program reports exactly the lines shellcheck reports (57 on the default branches) and nothing more. The step is renamedNegations that assert. Note that this repository's owntests / coveragecallstest-shell.yml@main, so the green check on this pull request does not run the new step; it was run locally, extracted from the workflow, against every repository.profile/WORKFLOWS.mdrecords the step, anddocs/traps.mdin the handbook gets the entry (separate pull request).Test plan
The step's script extracted and run against
keel-wordpressbefore its fix — reports its ten findings and exits non-zero — and against this repository after the fix, which exits 0.The script is shellcheck-clean at
-S warning, which is whatactionlintruns over arunblock.test-shell.ymlparses as YAML.shellcheck -f gcc --shell=bash --severity=error --include=SC2314 tests/*.batsreports nothing.bats tests/green, 55 tests.tests/coverage.sh: 100.00 percent, threshold 100. Unchanged.actionlinton this pull request, which is this repository's own gate..github/ships nothing, so no changelog entry.Review: the gate missed
! [[ ]](SC2315) and every negation nested in a list, loop, branch or group, which shellcheck does not see and bats passes.6372ac2adds both. Across every default branch and open PR head it reports exactly the 57 and nothing else. Also merged main (#12). This repository's own check calls test-shell.yml@main, so it did not run the new step; I ran it locally against all 19 repositories. Merge after the eight repository PRs.