test: remove tests that repeat another test #73
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "test/drop-duplicate-tests"
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?
Why
The project is tested by a Bash suite that runs the launcher and the
installer against a stub container engine: 352 tests in two levels,
unit and integration. Its rule is one test per behavior at each level,
so that whoever changes a behavior edits one test.
An audit of the suite found 30 tests that repeat another of the same
level and seven that repeat a case inside themselves. A contributor
changing, say, how a launcher setting is read met the same assertion in
three files. Three of the copies were worse than redundant: they passed
with the code they name removed, so they read as guards and guarded
nothing.
The suite's speed is not the reason: it runs in about six seconds
before and after.
What changed
Before, 352 tests. Now 323, or 325 on top of the lint pull request,
which adds two: 15 tests are removed because another test asserts the
same behavior through the same code path, and 14 are merged into the
test that keeps the behavior, which gains every assertion the other
had. Seven tests lose a case another test already asserts. Each removal
was read against its survivor twice, by the implementer and by a
reviewer.
Only files under
tests/change; the launcher and the installer areuntouched. Two removals the audit proposed stay out because they would
have dropped a guard nothing else holds: OpenCode's test that the
identity's env file is never mounted, and the scan that checks where
--cidfilesits among the engine's options. Twelve surviving tests arerenamed for what they now assert.
How to verify
Have Git, GNU Make, Bash 4.4 or newer, and
scriptfrom util-linux, onLinux. No container engine is needed.
The
sedline breaks the launcher on purpose: it deletes the handlingof
--no-tty. Onmasterthe count is352, and of the two tests ofthat option one still passes,
ok test_common_no_tty_cli_control_is_always_accepted, while theother fails: the first guards nothing. After
git switch test/drop-duplicate-teststhe count is325, the testthat passed is gone, and the one that fails is the only one left,
FAIL: test_common_no_tty_cli_control_wins_under_a_real_terminal.Then
make testpasses withbin/azkabanrestored.Checks run on the tip:
make lint && .agents/hooks/shellcheck.sh repo && make testpasses, 325 tests. Since no code under test changes, every surviving
test passes on
master's code as it does here. Not tried: the audit'sother mutation checks were not repeated on the final tip.
Considerations
This branch sits on top of #69, #70, #72, and #71, in that order, so it
merges last; until they merge, this page lists their commits too. The
audit's proposals that add or reshape shared test helpers are left for
a decision of their own.
"${a[@]+"${a[@]}"}" protects an empty array from set -u in Bash older than 4.4, which the launcher's gate refuses before this code runs. install.sh already expands empty arrays plainly.