A negated command only asserts in final position #10

Merged
marcos-mendez merged 3 commits from test/negations-that-assert into 19.x 2026-09-29 00:58:53 -03:00
marcos-mendez commented 2026-09-28 05:26:36 -03:00 (Migrated from github.com)

The three negations in tests/postfix-local.bats now assert wherever they stand. One of them did not assert at all.

Closes #9. Part of Keel-Linux/tracker#19, which has the organization-wide sweep.

Why a bare ! is inert

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 ! cmd decides the test in final position and is inert everywhere else. shellcheck grades the two apart, error: for the inert ones and note: for the rest:

shellcheck -f gcc --shell=bash tests/*.bats | grep SC2314

What was not being checked

Line 96, in "stops at the first failing postconf". The test is named for stopping at the first failure, and ! logged smtpd_banner is the assertion that says it stopped — a script that carried on past the failing postconf and set the banner anyway would have passed. Lines 66 and 97 are last in their bodies and did assert.

All three are run ! now, the two that already asserted included: a line whose meaning depends on its position is the trap itself.

The COVERAGE.md correction

COVERAGE.md on fix/keel-apt-identity (#8) states:

tests/postfix-local.bats still has three of them (lines 66, 96 and 97) and they are left for the pull request that owns that file.

That is wrong about two of the three: 66 and 97 are in final position and do assert. This PR puts the accurate statement on 19.x, in the same place, so the branch is the record:

tests/postfix-local.bats had three bare negations: line 96 was inert and lines 66 and 97 did assert, because they were last. All three are run ! now […]

That will conflict with #8, deliberately: the same paragraph in the same position, so whoever rebases #8 has to reconcile it rather than silently restore the wrong sentence. #8's version should be dropped on rebase.

Test plan

  • shellcheck -f gcc --shell=bash --severity=error --include=SC2314 tests/*.bats reports nothing.
  • bats tests/postfix-local.bats green, 7 tests, with the inert assertion live. No assertion changed its verdict.
  • tests/coverage.sh: postfix-local: 100.00 percent (17 of 17 lines) covered, threshold 100. Unchanged.
  • Tests and COVERAGE.md ship nothing, so package / changelog passes by reporting that nothing that ships changed. No changelog entry and no version bump.
The three negations in `tests/postfix-local.bats` now assert wherever they stand. One of them did not assert at all. Closes #9. Part of Keel-Linux/tracker#19, which has the organization-wide sweep. ## Why a bare `!` is inert 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 `! cmd` decides the test in final position and is inert everywhere else. shellcheck grades the two apart, `error:` for the inert ones and `note:` for the rest: shellcheck -f gcc --shell=bash tests/*.bats | grep SC2314 ## What was not being checked Line 96, in "stops at the first failing postconf". The test is named for stopping at the first failure, and `! logged smtpd_banner` is the assertion that says it stopped — a script that carried on past the failing `postconf` and set the banner anyway would have passed. Lines 66 and 97 are last in their bodies and did assert. All three are `run !` now, the two that already asserted included: a line whose meaning depends on its position is the trap itself. ## The COVERAGE.md correction `COVERAGE.md` on `fix/keel-apt-identity` (#8) states: > `tests/postfix-local.bats` still has three of them (lines 66, 96 and 97) and they are left for the pull request that owns that file. That is wrong about two of the three: 66 and 97 are in final position and do assert. This PR puts the accurate statement on `19.x`, in the same place, so the branch is the record: > `tests/postfix-local.bats` had three bare negations: line 96 was inert and lines 66 and 97 did assert, because they were last. All three are `run !` now […] **That will conflict with #8**, deliberately: the same paragraph in the same position, so whoever rebases #8 has to reconcile it rather than silently restore the wrong sentence. #8's version should be dropped on rebase. ## Test plan - [x] `shellcheck -f gcc --shell=bash --severity=error --include=SC2314 tests/*.bats` reports nothing. - [x] `bats tests/postfix-local.bats` green, 7 tests, with the inert assertion live. No assertion changed its verdict. - [x] `tests/coverage.sh`: `postfix-local: 100.00 percent (17 of 17 lines) covered, threshold 100`. Unchanged. - [x] Tests and `COVERAGE.md` ship nothing, so `package / changelog` passes by reporting that nothing that ships changed. No changelog entry and no version bump.
marcos-mendez commented 2026-09-29 00:45:52 -03:00 (Migrated from github.com)

Reviewed: the three refutations go red when postfix-local is made to carry on past the failing postconf, and each fails with status 1. Merged 19.x (#8 landed) and folded its paragraph on bare negations in COVERAGE.md into this one, so the file says it once (f858258).

Reviewed: the three refutations go red when postfix-local is made to carry on past the failing postconf, and each fails with status 1. Merged 19.x (#8 landed) and folded its paragraph on bare negations in COVERAGE.md into this one, so the file says it once (f858258).
Sign in to join this conversation.
No description provided.