From 893ff1f653a1fd97031e1f4ce4d945f2fe4a4aef Mon Sep 17 00:00:00 2001 From: Hasan Basbunar Date: Thu, 24 Sep 2026 18:39:14 +0200 Subject: [PATCH] CI: a cockpit test file that fails on its own fails the step The per-file loop ran each dashboard test file directly with || true and compared the 'Ran N' count only, so a file that failed alone, and passed in the full run after the modules that set its environment, went through. Its exit status is checked now (a mutant test that only passes after the modules before it: green before, red now). Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57a2f263..9809973e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,10 +67,13 @@ jobs: [ "$ran" = "$declared" ] || { echo "unittest ran $ran of $declared declared tests"; exit 1; } # Each file must also RUN its tests when invoked directly, the way a # human and the old CI step do. A file without a __main__ block exits 0 - # having run nothing, so only the reported count proves anything. + # having run nothing, so the reported count is checked; and a file that + # fails on its own, but passes after the modules that run before it in + # the full run (an environment they leave set), fails here: its exit + # status was dropped until 2026-09-24. for f in $(cd tests && ls test_*.py | sed 's/\.py$//' | sort); do d=$(grep -c 'def test_' "tests/$f.py") - o=$(python3 "tests/$f.py" 2>&1 || true) + o=$(python3 "tests/$f.py" 2>&1) || { echo "$f.py fails when run on its own:"; echo "$o" | tail -20; exit 1; } r=$(echo "$o" | grep -oE 'Ran [0-9]+' | grep -oE '[0-9]+' || echo 0) echo " $f.py run directly: ran $r of $d" [ "$r" = "$d" ] || { echo "$f.py ran $r of its $d tests when invoked directly"; exit 1; }