Verified Commit 57ad5e1c authored by Camil Staps's avatar Camil Staps 🚀

Add option to run_tests.sh to export JUnit-style XML for GitLab CI

parent 7d94eac3
Pipeline #29170 canceled with stages
in 1 minute and 51 seconds
......@@ -45,26 +45,34 @@ build-wasm:
- src-js/WebPublic.tar.gz
expire_in: 3 months
benchmark-x64:
.benchmark:
extends: .base
artifacts:
paths:
- test/*.junit.xml
reports:
junit: test/*.junit.xml
benchmark-x64:
extends: .benchmark
stage: test-interpreter
script:
- cd test
- ./run_tests.sh -bf
- ./run_tests.sh -bfj
benchmark-x86:
extends: .base
extends: .benchmark
stage: test-interpreter
script:
- cd test
- ./run_tests.sh -3bf
- ./run_tests.sh -3bfj
benchmark-wasm:
extends: .base
extends: .benchmark
stage: test-interpreter
script:
- cd test
- ./run_tests.sh -wb
- ./run_tests.sh -wbj
interworking-Start:
extends: .base
......
*.result
*.junit.xml
acker
arrays
......
......@@ -26,6 +26,7 @@ RUN_ONLY=()
PROFILE=0
QUIET=0
OPTIMISE=1
JUNIT_EXPORT=0
cpprj () {
if [ $OPTIMISE -gt 0 ]; then
......@@ -36,7 +37,7 @@ cpprj () {
[ "$OS" == "Windows_NT" ] && sed -i 's:\*lib\*:*Libraries*:' "$2"
}
cpmq() {
cpmq () {
res="$(cpm $@)"
ecode=$?
echo "$res" | grep -i 'Error' >/dev/null
......@@ -49,6 +50,30 @@ cpmq() {
fi
}
junit_export () {
MODULE="$1"
RESULT="$2"
EXPECTED_FILE="$3"
FAILURES=0
if [ "$RESULT" = "failed" ]; then
FAILURES=1
fi
echo "<?xml version=\"1.0\"?>"
echo "<testsuites tests=\"1\" failures=\"$FAILURES\" time=\"0\">"
echo "<testsuite name=\"$MODULE\" tests=\"1\" failures=\"$FAILURES\" time=\"0\">"
echo "<testcase id=\"$MODULE\" name=\"$MODULE\" classname=\"$MODULE\" time=\"0\">"
if [ "$RESULT" = "failed" ]; then
echo "<failure>"
git diff --no-index --word-diff -U0 $EXPECTED $MODULE.result \
| sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g'
echo "</failure>"
fi
echo "</testcase>"
echo "</testsuite>"
echo "</testsuites>"
}
print_help () {
echo "$0: run tests"
echo
......@@ -71,6 +96,7 @@ print_help () {
echo " -d Print all instructions as they are executed"
echo " -l List bytecode before execution"
echo " -p Make PDF profiles (e.g. nfib.prof.pdf) using google-pprof"
echo " -j Output JUnit style XML files (for GitLab CI)"
exit 0
}
......@@ -86,7 +112,7 @@ contains () {
return 1
}
OPTS=`getopt "Ho:wbMfh:Os:3dlpq" "$@"` || print_usage
OPTS=`getopt "Ho:wbMfh:Os:3dlpjq" "$@"` || print_usage
eval set -- "$OPTS"
while true; do
......@@ -143,6 +169,9 @@ while true; do
export CPUPROFILE_FREQUENCY=10000
PROFILE=1
shift;;
-j)
JUNIT_EXPORT=1
shift;;
-q)
QUIET=1
shift;;
......@@ -240,15 +269,17 @@ do
[ "$OS" == "Windows_NT" ] && dos2unix $MODULE.result
EXPECTED="$MODULE$EXPECTED_PREFIX.expected"
if [ $BENCHMARK -gt 0 ] && [ -f "$MODULE.bm$EXPECTED_PREFIX.expected" ]; then
git diff --no-index --word-diff -U0 $MODULE.bm$EXPECTED_PREFIX.expected $MODULE.result
else
git diff --no-index --word-diff -U0 $MODULE$EXPECTED_PREFIX.expected $MODULE.result
EXPECTED="$MODULE.bm$EXPECTED_PREFIX.expected"
fi
git diff --no-index --word-diff -U0 $EXPECTED $MODULE.result
if [ $? -ne 0 ]; then
if [ $JUNIT_EXPORT -gt 0 ]; then junit_export $MODULE failed "$EXPECTED" > "$MODULE.junit.xml"; fi
echo -e "${RED}FAILED: $MODULE (different result)$RESET"
FAILED+=("$MODULE")
else
if [ $JUNIT_EXPORT -gt 0 ]; then junit_export "$MODULE" passed "$EXPECTED" > "$MODULE.junit.xml"; fi
echo -e "${GREEN}Passed: $MODULE$RESET"
fi
done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment