test: smoke scripts fail when they stop before their last check

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-26 18:44:10 +02:00
co-authored by Claude Opus 5.5
parent 3a5f658f35
commit 314b3d0756
6 changed files with 24 additions and 10 deletions
+2 -2
View File
@@ -18,7 +18,7 @@ cleanup() {
done
cleanup_app_passwords_for "$ADMIN_LOGIN"
}
trap cleanup EXIT
trap 'rc=$?; cleanup; guard_exit "$rc" || exit $?' EXIT
# Creates a draft page from a fixture file as the admin (no kses re-serialization) and prints its ID.
create_page() { # $1 = fixture file, $2 = title
@@ -98,4 +98,4 @@ pass "content-get points to the Divi tools; Divi 4 content is refused"
[ "$(content_hash "$PAGE_ID")" = "$BEFORE" ] || fail "reading changed post_content"
pass "post_content unchanged after reading"
echo "ALL CHECKS PASSED"
finish
+2 -2
View File
@@ -37,7 +37,7 @@ foreach (array_filter(explode(" ", (string) getenv("LIT_IDS"))) as $id) {
wp role delete lit_smoke_editor >/dev/null 2>&1 || true
wp option update lit_mcp_allowed_roles "$ORIGINAL_ROLES" --format=json >/dev/null 2>&1 || true
}
trap cleanup EXIT
trap 'rc=$?; cleanup; guard_exit "$rc" || exit $?' EXIT
create_page() { # $1 = fixture file ("" = empty page), $2 = title -> prints the ID
LIT_FILE="${1:+$FIXTURES/$1}" LIT_TITLE="$2" wp --user="$ADMIN_LOGIN" eval '
@@ -361,4 +361,4 @@ echo "$AGAIN" | jq -e '.ok == true and (.warnings | any(contains("beim Speichern
|| fail "8b: follow-up write with the new tree_rev: $AGAIN"
pass "Divi save filters, other byte form: normalized with CHANGED_ON_SAVE, tree_rev = stored state, page valid, then stable"
echo "ALL CHECKS PASSED"
finish
+14
View File
@@ -20,6 +20,20 @@ INIT_RESPONSE=""
REQUEST_ID=100
fail() { echo "FAIL: $*"; exit 1; }
# A smoke script must reach its last line: finish() marks that and prints the verdict.
# guard_exit (called first in every EXIT trap) turns any other exit – including a silent
# stop that still returns 0 – into a failure, so a run can never pass without all checks.
SMOKE_FINISHED=0
finish() { SMOKE_FINISHED=1; echo "ALL CHECKS PASSED"; }
guard_exit() {
local rc=$1
if [ "$rc" -eq 0 ] && [ "$SMOKE_FINISHED" != 1 ]; then
echo "FAIL: script stopped before its last check (exit 0 without finish)"
return 1
fi
return "$rc"
}
pass() { echo "ok - $*"; }
# Removes every "lit-mcp-integration-test" application password of a user.
+2 -2
View File
@@ -18,7 +18,7 @@ cleanup() {
cleanup_app_passwords_for lit-smoke-sub
wp user delete lit-smoke-sub --yes >/dev/null 2>&1 || true
}
trap cleanup EXIT
trap 'rc=$?; cleanup; guard_exit "$rc" || exit $?' EXIT
# 0. Booting REST triggers no _doing_it_wrong(). A regression in the
# unhook-before-create ordering (ServerRegistrar::createServer()) would
@@ -156,4 +156,4 @@ echo "$SUB_META" | grep -Eq 'lacks required capability|nicht freigegeben' \
|| fail "execute-ability denial lacks role-gate message: $SUB_META"
pass "role gate blocks subscriber (direct tool and meta-tool)"
echo "ALL CHECKS PASSED"
finish
+2 -2
View File
@@ -27,7 +27,7 @@ cleanup() {
cleanup_app_passwords_for lit-smoke-sub2
wp user delete lit-smoke-sub2 --yes >/dev/null 2>&1 || true
}
trap cleanup EXIT
trap 'rc=$?; cleanup; guard_exit "$rc" || exit $?' EXIT
connect "$ADMIN_LOGIN"
@@ -149,4 +149,4 @@ echo (int) $wpdb->get_var($wpdb->prepare(
[ "$ROWS" -ge 2 ] || fail "media changes not logged (found $ROWS)"
pass "media changes logged"
echo "ALL CHECKS PASSED"
finish
+2 -2
View File
@@ -35,7 +35,7 @@ cleanup() {
[ "$PODS_WAS_ACTIVE" = "no" ] && wp plugin deactivate pods >/dev/null 2>&1 || true
cleanup_app_passwords_for "$ADMIN_LOGIN"
}
trap cleanup EXIT
trap 'rc=$?; cleanup; guard_exit "$rc" || exit $?' EXIT
wp plugin activate pods >/dev/null
wp eval-file "$PLUGIN/tests/Integration/pods-fixture.php" create >/dev/null
@@ -223,4 +223,4 @@ ROWS=$(wp db query "SELECT COUNT(*) FROM ${PREFIX}lit_mcp_log WHERE ability = 'l
[ "$ROWS" -ge 2 ] || fail "change log rows missing (found $ROWS)"
pass "change log records ability and client"
echo "ALL CHECKS PASSED"
finish