Skip to content

Commit 9300f56

Browse files
committed
test(docker): probe repo-update by alias, with aborting guards
1 parent de2e22a commit 9300f56

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

‎.github/workflows/exp-opensuse.yml‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Throwaway experiment (deleted after it runs): proves the fix in
2-
# docker/Dockerfile by forcing openSUSE-Tumbleweed-Update unreachable.
2+
# docker/Dockerfile by forcing the Update repo (alias repo-update) unreachable.
33
# A dup --dry-run before the install forces the code path that failed:
44
# "fixed" must build; "mutant" (the pre-fix Dockerfile) must fail.
55
name: exp-opensuse
@@ -27,7 +27,7 @@ jobs:
2727
s = open(p).read()
2828
key = '\t\tzretry zypper --non-interactive --gpg-auto-import-keys refresh'
2929
assert s.count(key) == 1, 'anchor missing'
30-
bad = ('\t\tzypper lr; f=$(grep -l "^\\[openSUSE-Tumbleweed-Update\\]" '
30+
bad = ('\t\tzypper lr; f=$(grep -l "^\\[repo-update\\]" '
3131
'/etc/zypp/repos.d/*.repo); test -n "$f"; '
3232
'sed -i "s|^baseurl=.*|baseurl=http://invalid.invalid/|" $f; '
3333
'grep baseurl $f; \\\n')
@@ -43,8 +43,17 @@ jobs:
4343
--build-arg BASE=opensuse/tumbleweed --build-arg CC=gcc \
4444
--build-arg BUILD_FLAGS='OPT=1 SAFE=1' . > build.log 2>&1
4545
rc=$?
46-
grep -vE "Retrieving|^#[0-9]+ [0-9.]+ +[0-9]+ " build.log | tail -150
46+
grep -v Retrieving build.log | tail -150
4747
echo "docker build rc=$rc for ${{ matrix.v }}"
48-
# The sabotage itself must have run, or a failure proves nothing.
49-
grep -qE "^#[0-9]+ [0-9.]+ baseurl=http://invalid.invalid/" build.log
50-
if [ "${{ matrix.v }}" = fixed ]; then test "$rc" -eq 0; else test "$rc" -ne 0; fi
48+
# Each guard aborts on its own (set +e is on): a failure for the
49+
# wrong reason, or a pass that skipped the sabotage, proves nothing.
50+
need() { grep -qE "$1" build.log || { echo "missing: $1"; exit 1; }; }
51+
need "^#[0-9]+ [0-9.]+ baseurl=http://invalid.invalid/"
52+
need "Failed to retrieve new repository metadata"
53+
need "^#[0-9]+ [0-9.]+ \+ zypper --non-interactive dup --dry-run"
54+
if [ "${{ matrix.v }}" = fixed ]; then
55+
need "modifyrepo --disable repo-update"
56+
test "$rc" -eq 0
57+
else
58+
test "$rc" -ne 0
59+
fi

0 commit comments

Comments
 (0)