From 5b340ca48a0104f899fbf6afba151e4972db5d0c Mon Sep 17 00:00:00 2001 From: navigator Date: Tue, 29 Sep 2026 04:00:10 +0000 Subject: [PATCH] test: the three refutations in wrappers.bats that asserted nothing tests/wrappers.bats came in with #6 after the sweep of tracker#19, and three of its seven bare negations were not the last command of their test, so bash did not apply errexit to them and they asserted nothing: that USER=root in the environment does not hand wp-content to root, that WPROOT=/ in the environment does not make the updater chown / , and that a refused update target is never chowned. All seven are `run !` now, with bats_require_minimum_version 1.5.0, the four in final position included, so no line's meaning depends on its position. Each of the seven goes red when the command it refutes is made to succeed, and each fails with status 1 (grep found nothing), not 2 (no file). --- tests/wrappers.bats | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/wrappers.bats b/tests/wrappers.bats index e6ca635..eb96c70 100644 --- a/tests/wrappers.bats +++ b/tests/wrappers.bats @@ -25,6 +25,8 @@ # it is run through a copy of the overlay made the way the build makes it # (`cp -TdR`, which is what fab-apply-overlay executes). +bats_require_minimum_version 1.5.0 + setup() { REPO="$BATS_TEST_DIRNAME/.." BIN="$REPO/overlay/usr/local/bin" @@ -256,7 +258,7 @@ _runuser_command() { KEEL_TEST_UID=1000 run "$UPDATE" [ "$status" -eq 1 ] [[ "$output" == *"keel-wordpress-update must run as root"* ]] - ! grep -q '^wp ' "$CALLS" + run ! grep -q '^wp ' "$CALLS" } @test "keel-wordpress-update refuses a target that is not a WordPress" { @@ -264,8 +266,8 @@ _runuser_command() { run "$UPDATE" [ "$status" -eq 1 ] [[ "$output" == *"is not a WordPress installation"* ]] - ! grep -q '^wp ' "$CALLS" - ! grep -q '^chown ' "$CALLS" + run ! grep -q '^wp ' "$CALLS" + run ! grep -q '^chown ' "$CALLS" } @test "keel-wordpress-update updates core and then verifies the checksums" { @@ -280,7 +282,7 @@ _runuser_command() { run "$UPDATE" [ "$status" -eq 1 ] grep -q "^wp --allow-root --path=$WPROOT core update\$" "$CALLS" - ! grep -q 'verify-checksums' "$CALLS" + run ! grep -q 'verify-checksums' "$CALLS" } @test "keel-wordpress-update stops when the checksums do not verify" { @@ -288,7 +290,7 @@ _runuser_command() { run "$UPDATE" [ "$status" -eq 1 ] grep -q "^wp --allow-root --path=$WPROOT core verify-checksums\$" "$CALLS" - ! grep -q '^chown -R root:root' "$CALLS" + run ! grep -q '^chown -R root:root' "$CALLS" } @test "keel-wordpress-update puts the ownership boundary back" { @@ -322,7 +324,7 @@ _runuser_command() { USER=root run "$UPDATE" [ "$status" -eq 0 ] grep -q "^chown -R $WEB_USER:$WEB_USER $WPROOT/wp-content/uploads\$" "$CALLS" - ! grep -q '^chown -R root:root .*wp-content' "$CALLS" + run ! grep -q '^chown -R root:root .*wp-content' "$CALLS" grep -q "^chown root:$WEB_USER $WPROOT/wp-config.php\$" "$CALLS" } @@ -334,6 +336,6 @@ _runuser_command() { WPROOT=/ WP_USER=root WP_CLI=/bin/true run "$UPDATE" [ "$status" -eq 0 ] grep -q "^chown -R root:root $KEEL_TEST_WPROOT\$" "$CALLS" - ! grep -qx 'chown -R root:root /' "$CALLS" + run ! grep -qx 'chown -R root:root /' "$CALLS" grep -q "^wp --allow-root --path=$KEEL_TEST_WPROOT core update\$" "$CALLS" }