Skip to content

Commit

Permalink
Export detailed test results to a JSON file and expose it as an artif…
Browse files Browse the repository at this point in the history
…act for CI runs
  • Loading branch information
oSoMoN committed Feb 12, 2024
1 parent 149c044 commit 74fa543
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ jobs:
- run: ./run-upstream-testsuite.sh release || true
env:
TERM: xterm
- uses: actions/upload-artifact@v4
with:
file: test-results.json

coverage:
name: Code Coverage
Expand Down
34 changes: 27 additions & 7 deletions run-upstream-testsuite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,45 @@ else
fi
echo "Running $(echo "$tests" | wc -w) tests"
export LC_ALL=C
pass="$(tput setaf 2)PASS$(tput sgr0)"
fail="$(tput setaf 1)FAIL$(tput sgr0)"
skip=SKIP
export KEEP=yes
exitcode=0
json=""
for test in $tests
do
result=$fail
result="FAIL"
# Run only the tests that invoke `diff`, because other binaries aren't implemented yet
if ! grep -E -s -q "(cmp|diff3|sdiff)" "$test"
then
sh "$test" &> /dev/null && result=$pass || exitcode=1
sh "$test" &> /dev/null && result="PASS" || exitcode=1
json="$json{\"test\":\"$test\",\"result\":\"$result\",\"files\":{"
cd gt-$test.*
for file in *
do
if [[ -f "$file" ]]
then
content=$(base64 -w0 < "$file")
json="$json\"$file\":\"$content\","
fi
done
json="${json%,}}},"
cd - > /dev/null
else
result=$skip
result="SKIP"
json="$json{\"test\":\"$test\",\"result\":\"$result\"},"
fi
printf " %-40s $result\n" "$test"
color=2 # green
[[ "$result" = "FAIL" ]] && color=1 # red
[[ "$result" = "SKIP" ]] && color=3 # yellow
printf " %-40s $(tput setaf $color)$result$(tput sgr0)\n" "$test"
done
json="[${json%,}]"

# Clean up
cd "$scriptpath"
rm -rf "$tempdir"

resultsfile="test-results.json"
echo "$json" | jq > "$resultsfile"
echo "Results written to $resultsfile"

exit $exitcode

0 comments on commit 74fa543

Please sign in to comment.