From 731143f5b9c6601fbf1b6e4178039b24e2dc750b Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 11 Oct 2026 20:22:56 +0200 Subject: [PATCH] Fail the repo check when a listed store test did not run against the store (hq issue 459) A test that needs the store skips without one, and a skip passes unseen, so a change's store tests could pass the check without ever running. Tests named in testdata/store-tests must each run and pass, said by name. --- merge-check.sh | 27 +++++++++++++++++++++++++++ testdata/store-tests | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 testdata/store-tests diff --git a/merge-check.sh b/merge-check.sh index 296fe271..9f47924e 100755 --- a/merge-check.sh +++ b/merge-check.sh @@ -32,3 +32,30 @@ else echo "NOT RACE-CHECKED: the toolchain holds no C compiler; the suite runs without the race detector" CGO_ENABLED=0 go test -count=1 -timeout 30m ./... fi + +# **The store tests listed ran** (novox/hq issue 459): a test that needs the store skips without one, and a skip +# passes unseen. With the store this check is given, every test named in testdata/store-tests must have run against +# it and passed, each said by name; without one, that is said. A pull request adds its own store tests to the list. +listed=$(grep -v '^[[:space:]]*\(#\|$\)' testdata/store-tests || true) +if [ -z "$listed" ]; then + echo "store tests: none listed in testdata/store-tests" +elif [ -n "${MESH_TEST_POSTGRES:-}" ]; then + echo "store tests, each run against the store:" + missing=0 + for pkg in $(printf '%s\n' "$listed" | awk '{print $1}' | sort -u); do + names=$(printf '%s\n' "$listed" | awk -v p="$pkg" '$1 == p {print $2}') + pattern="^($(printf '%s\n' "$names" | paste -sd '|' -))\$" + ran=$(CGO_ENABLED=0 go test -count=1 -v -run "$pattern" "$pkg" 2>&1 | grep -E '^--- (PASS|FAIL|SKIP)' || true) + for name in $names; do + line=$(printf '%s\n' "$ran" | grep -E "^--- [A-Z]+: $name " || true) + echo " $pkg ${line:-"--- NOT RUN: $name"}" + case "$line" in "--- PASS: "*) ;; *) missing=$((missing + 1)) ;; esac + done + done + if [ "$missing" -ne 0 ]; then + echo "$missing store test(s) listed in testdata/store-tests did not run and pass against the store" + exit 1 + fi +else + echo "NOT STORE-CHECKED: no MESH_TEST_POSTGRES, so the store tests listed in testdata/store-tests skipped" +fi diff --git a/testdata/store-tests b/testdata/store-tests new file mode 100644 index 00000000..1a66198b --- /dev/null +++ b/testdata/store-tests @@ -0,0 +1,3 @@ +# The tests that need the throwaway store and must have run against it (novox/hq issue 459): merge-check.sh runs +# each one named here, by package, and fails unless every one passed — a test that needs the store skips without +# one, and a skip passes unseen. One per line: . Lines starting with # are said nothing of.