@@ -152,17 +152,16 @@ jobs:
152152 python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')"
153153 if [ "${TEST_MODE}" = "selected" ] && [ -s /tmp/pr_selected_nodeids.txt ]; then
154154 status=0
155- mapfile -t FILTERED_NODEIDS < <(
156- while IFS= read -r nodeid; do
157- if [ -z "$nodeid" ]; then
158- continue
159- fi
160- path="${nodeid%%::*}"
161- if [ -f "$path" ]; then
162- printf '%s\n' "$nodeid"
163- fi
164- done < /tmp/pr_selected_nodeids.txt
165- )
155+ FILTERED_NODEIDS=()
156+ while IFS= read -r nodeid; do
157+ if [ -z "$nodeid" ]; then
158+ continue
159+ fi
160+ path="${nodeid%%::*}"
161+ if [ -f "$path" ]; then
162+ FILTERED_NODEIDS+=("$nodeid")
163+ fi
164+ done < /tmp/pr_selected_nodeids.txt
166165 echo "FILTERED_NODEIDS_BASE_COUNT=${#FILTERED_NODEIDS[@]}"
167166 if [ "${#FILTERED_NODEIDS[@]}" -eq 0 ]; then
168167 echo "No valid nodeids found on base; skipping baseline generation."
@@ -211,19 +210,45 @@ jobs:
211210 python -c "import ultraplot as plt; plt.config.Configurator()._save_yaml('ultraplot.yml')"
212211 echo "TEST_MODE=${TEST_MODE}"
213212 echo "TEST_NODEIDS=${TEST_NODEIDS}"
213+ parse_junit_counts() {
214+ python - "$1" <<'PY'
215+ import sys
216+ from xml.etree import ElementTree as ET
217+
218+ failures = 0
219+ errors = 0
220+ path = sys.argv[1]
221+ try :
222+ root = ET.parse(path).getroot()
223+ if root.tag == "testsuite" :
224+ failures = int(root.attrib.get("failures", 0))
225+ errors = int(root.attrib.get("errors", 0))
226+ elif root.tag == "testsuites" :
227+ suites = root.findall("testsuite")
228+ if suites :
229+ failures = sum(int(suite.attrib.get("failures", 0)) for suite in suites)
230+ errors = sum(int(suite.attrib.get("errors", 0)) for suite in suites)
231+ else :
232+ failures = int(root.attrib.get("failures", 0))
233+ errors = int(root.attrib.get("errors", 0))
234+ except Exception :
235+ failures = 0
236+ errors = 0
237+ print(f"{failures} {errors}")
238+ PY
239+ }
214240 if [ "${TEST_MODE}" = "selected" ] && [ -s /tmp/pr_selected_nodeids.txt ]; then
215241 status=0
216- mapfile -t FILTERED_NODEIDS < <(
217- while IFS= read -r nodeid; do
218- if [ -z "$nodeid" ]; then
219- continue
220- fi
221- path="${nodeid%%::*}"
222- if [ -f "$path" ]; then
223- printf '%s\n' "$nodeid"
224- fi
225- done < /tmp/pr_selected_nodeids.txt
226- )
242+ FILTERED_NODEIDS=()
243+ while IFS= read -r nodeid; do
244+ if [ -z "$nodeid" ]; then
245+ continue
246+ fi
247+ path="${nodeid%%::*}"
248+ if [ -f "$path" ]; then
249+ FILTERED_NODEIDS+=("$nodeid")
250+ fi
251+ done < /tmp/pr_selected_nodeids.txt
227252 echo "FILTERED_NODEIDS_PR_COUNT=${#FILTERED_NODEIDS[@]}"
228253 if [ "${#FILTERED_NODEIDS[@]}" -eq 0 ]; then
229254 echo "No valid nodeids found on PR branch; skipping image comparison."
@@ -243,14 +268,15 @@ jobs:
243268 status=$?
244269 set -e
245270 echo "=== Memory after image comparison ===" && free -h
246- junit_failures=-1
247- junit_errors=-1
271+ junit_failures=0
272+ junit_errors=0
248273 if [ -f ./results/junit.xml ]; then
249- junit_failures=$(sed -n 's/.*failures="\([0-9][0-9]*\)".*/\1/p' ./results/junit.xml | head -n 1)
250- junit_errors=$(sed -n 's/.*errors="\([0-9][0-9]*\)".*/\1/p' ./results/junit.xml | head -n 1)
251- junit_failures=${junit_failures:-0}
252- junit_errors=${junit_errors:-0}
274+ junit_counts="$(parse_junit_counts ./results/junit.xml || echo '0 0')"
275+ junit_failures="${junit_counts%% *}"
276+ junit_errors="${junit_counts##* }"
253277 fi
278+ case "$junit_failures" in ''|*[!0-9]*) junit_failures=0 ;; esac
279+ case "$junit_errors" in ''|*[!0-9]*) junit_errors=0 ;; esac
254280 echo "pytest_status=$status junit_failures=$junit_failures junit_errors=$junit_errors"
255281 if [ "$status" -ne 0 ] && [ "$junit_failures" -eq 0 ] && [ "$junit_errors" -eq 0 ]; then
256282 echo "pytest exited with $status but junit reports no failures/errors; overriding exit status to 0."
@@ -277,14 +303,15 @@ jobs:
277303 status=$?
278304 set -e
279305 echo "=== Memory after image comparison ===" && free -h
280- junit_failures=-1
281- junit_errors=-1
306+ junit_failures=0
307+ junit_errors=0
282308 if [ -f ./results/junit.xml ]; then
283- junit_failures=$(sed -n 's/.*failures="\([0-9][0-9]*\)".*/\1/p' ./results/junit.xml | head -n 1)
284- junit_errors=$(sed -n 's/.*errors="\([0-9][0-9]*\)".*/\1/p' ./results/junit.xml | head -n 1)
285- junit_failures=${junit_failures:-0}
286- junit_errors=${junit_errors:-0}
309+ junit_counts="$(parse_junit_counts ./results/junit.xml || echo '0 0')"
310+ junit_failures="${junit_counts%% *}"
311+ junit_errors="${junit_counts##* }"
287312 fi
313+ case "$junit_failures" in ''|*[!0-9]*) junit_failures=0 ;; esac
314+ case "$junit_errors" in ''|*[!0-9]*) junit_errors=0 ;; esac
288315 echo "pytest_status=$status junit_failures=$junit_failures junit_errors=$junit_errors"
289316 if [ "$status" -ne 0 ] && [ "$junit_failures" -eq 0 ] && [ "$junit_errors" -eq 0 ]; then
290317 echo "pytest exited with $status but junit reports no failures/errors; overriding exit status to 0."
0 commit comments