From ded593dc529916f1bf23f2df38f975db1c1e69e8 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 25 Sep 2026 10:05:08 +0200 Subject: test-build: add --pull to refresh a stale local image require_image pulled only when the image was missing, so once the image-builder rebuilt a registry tag the local copy went stale with no warning. --pull runs `docker pull` first, which compares digests itself and costs one manifest request when nothing changed. If the registry is unreachable it falls back to the local copy with a warning, and still fails when there is none. The README documents a daily cron pull for machines that run test-build, and the skill notes that local images are not refreshed automatically. Co-Authored-By: Claude Opus 5.5 --- test-logic.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test-logic.sh') diff --git a/test-logic.sh b/test-logic.sh index 563eb30..a46b582 100644 --- a/test-logic.sh +++ b/test-logic.sh @@ -234,6 +234,36 @@ if depends_on_failed "$T/cat/a" dead; then bad "a blocked with empty dead"; else dead=("%README%") if depends_on_failed "$T/cat/a" dead; then bad "%README% treated as dep"; else ok "%README% not treated as dep"; fi +# --- require_image / --pull --------------------------------------------------- +# Stub docker: records "pull"/"inspect" calls; STUB_PULL / STUB_LOCAL set outcomes. +echo "require_image:" +docker() { + CALLS+="$1 " + case "$1" in + pull) [[ $STUB_PULL -eq 0 ]] ;; + image) [[ $STUB_LOCAL -eq 1 ]] ;; + esac +} +ACTIVE_IMAGE="reg/img:current" +PULL_IMAGE=0; parse_args --pull pkg >/dev/null 2>&1 +[[ $PULL_IMAGE -eq 1 ]] && ok "--pull sets PULL_IMAGE" || bad "--pull not parsed" +TARGET_ARG="" + +PULL_IMAGE=0; STUB_LOCAL=1; STUB_PULL=0; CALLS="" +require_image 2>/dev/null +[[ $CALLS == "image " ]] && ok "no --pull + local: no pull" || bad "no --pull + local: calls '$CALLS'" + +PULL_IMAGE=1; STUB_LOCAL=1; STUB_PULL=0; CALLS="" +require_image 2>/dev/null +[[ $CALLS == "pull " ]] && ok "--pull: pulls even when local" || bad "--pull: calls '$CALLS'" + +PULL_IMAGE=1; STUB_LOCAL=1; STUB_PULL=1; CALLS="" +( require_image ) 2>/dev/null && ok "--pull fails + local: falls back" || bad "--pull fails + local: exited" + +PULL_IMAGE=1; STUB_LOCAL=0; STUB_PULL=1; CALLS="" +( require_image ) 2>/dev/null && bad "--pull fails + no local: should exit" || ok "--pull fails + no local: exits" +unset -f docker; PULL_IMAGE=0 + echo echo "$pass passed, $fail failed" [[ $fail -eq 0 ]] || exit 1 -- cgit v1.2.3