A negated command only asserts in final position #5

Merged
marcos-mendez merged 1 commit from test/negations-that-assert into main 2026-09-29 00:59:18 -03:00
marcos-mendez commented 2026-09-28 05:32:09 -03:00 (Migrated from github.com)

Every negation in these suites now asserts wherever it stands. Four did not assert at all, and they were the refutations this component exists to make.

Closes #4. 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

Where Was not asserting
conf.bats 253 that the bind fragment never says localhost. That is the exact line docs/traps.md records the PostgreSQL appliance getting wrong — "On Debian, localhost is not an IPv6 name" — and the test written to stop it happening again did not run.
conf.bats 263, 264 that the acl fragment declares no admin user and no requirepass. Those two are what make the duplicate user declaration impossible and keep the password off the disk at build time, which is the other docs/traps.md entry. Only the third refusal, +@all, ran.
unit.bats 77 that no requirepass line is anywhere in the shipped overlay. The comment above it calls this "the one property the whole design rests on".

Two traps had a test each, and in both cases the test was inert. That is the shape of this defect: the refutation is the part a reader trusts most and the part the shell runs least.

All four become run !, together with the six that were in final position and did assert: a line whose meaning depends on its position is the trap itself. tests/unit.bats gains the bats_require_minimum_version 1.5.0 declaration the other two files already had.

What was found

Nothing broken. Both fragments were rendered and read directly before the conversion: the bind fragment is bind ::1 127.0.0.1 and names no host, the acl fragment declares user default on nopass +info and nothing else, and the overlay carries no requirepass and no masterauth. The assertions were dead, not wrong.

Test plan

  • Both rendered fragments and the shipped overlay read directly, before the conversion.

  • shellcheck -f gcc --shell=bash --severity=error --include=SC2314 tests/*.bats reports nothing.

  • Every converted site audited for run clobbering $output/$status/$lines; none here does.

  • bats tests/*.bats green, 70 tests. No assertion changed its verdict.

  • tests/coverage.sh: 100.00 percent, threshold 100. Unchanged.

    100.00  31/31  35redispass
    100.00  56/56  redis.sh
    
  • Tests ship nothing, so no changelog entry and no version bump.

Every negation in these suites now asserts wherever it stands. Four did not assert at all, and they were the refutations this component exists to make. Closes #4. 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 | Where | Was not asserting | |---|---| | conf.bats 253 | that the bind fragment never says `localhost`. **That is the exact line `docs/traps.md` records the PostgreSQL appliance getting wrong** — "On Debian, `localhost` is not an IPv6 name" — and the test written to stop it happening again did not run. | | conf.bats 263, 264 | that the acl fragment declares no `admin` user and no `requirepass`. Those two are what make the duplicate user declaration impossible and keep the password off the disk at build time, which is the other `docs/traps.md` entry. Only the third refusal, `+@all`, ran. | | unit.bats 77 | that no `requirepass` line is anywhere in the shipped overlay. The comment above it calls this "the one property the whole design rests on". | Two traps had a test each, and in both cases the test was inert. That is the shape of this defect: the refutation is the part a reader trusts most and the part the shell runs least. All four become `run !`, together with the six that were in final position and did assert: a line whose meaning depends on its position is the trap itself. `tests/unit.bats` gains the `bats_require_minimum_version 1.5.0` declaration the other two files already had. ## What was found Nothing broken. Both fragments were rendered and read directly before the conversion: the bind fragment is `bind ::1 127.0.0.1` and names no host, the acl fragment declares `user default on nopass +info` and nothing else, and the overlay carries no `requirepass` and no `masterauth`. The assertions were dead, not wrong. ## Test plan - [x] Both rendered fragments and the shipped overlay read directly, before the conversion. - [x] `shellcheck -f gcc --shell=bash --severity=error --include=SC2314 tests/*.bats` reports nothing. - [x] Every converted site audited for `run` clobbering `$output`/`$status`/`$lines`; none here does. - [x] `bats tests/*.bats` green, 70 tests. No assertion changed its verdict. - [x] `tests/coverage.sh`: **100.00 percent**, threshold 100. Unchanged. 100.00 31/31 35redispass 100.00 56/56 redis.sh - [x] Tests ship nothing, so no changelog entry and no version bump.
marcos-mendez commented 2026-09-29 00:45:55 -03:00 (Migrated from github.com)

Reviewed: every converted refutation goes red when its property is broken; adding bind localhost to the bind fragment turns this branch red and leaves main green. Each fails with status 1. No changes needed.

Reviewed: every converted refutation goes red when its property is broken; adding `bind localhost` to the bind fragment turns this branch red and leaves main green. Each fails with status 1. No changes needed.
Sign in to join this conversation.
No description provided.