Skip to content

Commit 76dce3d

Browse files
committed
Export detailed test results to a JSON file and expose it as an artifact for CI runs
1 parent 149c044 commit 76dce3d

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

.github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ jobs:
6060
- run: ./run-upstream-testsuite.sh release || true
6161
env:
6262
TERM: xterm
63+
- uses: actions/upload-artifact@v4
64+
with:
65+
name: test-results.json
66+
path: test-results.json
6367

6468
coverage:
6569
name: Code Coverage

run-upstream-testsuite.sh

+27-7
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,45 @@ else
4343
fi
4444
echo "Running $(echo "$tests" | wc -w) tests"
4545
export LC_ALL=C
46-
pass="$(tput setaf 2)PASS$(tput sgr0)"
47-
fail="$(tput setaf 1)FAIL$(tput sgr0)"
48-
skip=SKIP
46+
export KEEP=yes
4947
exitcode=0
48+
json=""
5049
for test in $tests
5150
do
52-
result=$fail
51+
result="FAIL"
5352
# Run only the tests that invoke `diff`, because other binaries aren't implemented yet
5453
if ! grep -E -s -q "(cmp|diff3|sdiff)" "$test"
5554
then
56-
sh "$test" &> /dev/null && result=$pass || exitcode=1
55+
sh "$test" &> /dev/null && result="PASS" || exitcode=1
56+
json="$json{\"test\":\"$test\",\"result\":\"$result\",\"files\":{"
57+
cd gt-$test.*
58+
for file in *
59+
do
60+
if [[ -f "$file" ]]
61+
then
62+
content=$(base64 -w0 < "$file")
63+
json="$json\"$file\":\"$content\","
64+
fi
65+
done
66+
json="${json%,}}},"
67+
cd - > /dev/null
5768
else
58-
result=$skip
69+
result="SKIP"
70+
json="$json{\"test\":\"$test\",\"result\":\"$result\"},"
5971
fi
60-
printf " %-40s $result\n" "$test"
72+
color=2 # green
73+
[[ "$result" = "FAIL" ]] && color=1 # red
74+
[[ "$result" = "SKIP" ]] && color=3 # yellow
75+
printf " %-40s $(tput setaf $color)$result$(tput sgr0)\n" "$test"
6176
done
77+
json="[${json%,}]"
6278

6379
# Clean up
6480
cd "$scriptpath"
6581
rm -rf "$tempdir"
6682

83+
resultsfile="test-results.json"
84+
echo "$json" | jq > "$resultsfile"
85+
echo "Results written to $resultsfile"
86+
6787
exit $exitcode

0 commit comments

Comments
 (0)