Commit 66b76bd1 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 #29171 passed with stages
in 12 minutes and 31 seconds
...@@ -45,26 +45,34 @@ build-wasm: ...@@ -45,26 +45,34 @@ build-wasm:
- src-js/WebPublic.tar.gz - src-js/WebPublic.tar.gz
expire_in: 3 months expire_in: 3 months
benchmark-x64: .benchmark:
extends: .base extends: .base
artifacts:
paths:
- test/*.junit.xml
reports:
junit: test/*.junit.xml
benchmark-x64:
extends: .benchmark
stage: test-interpreter stage: test-interpreter
script: script:
- cd test - cd test
- ./run_tests.sh -bf - ./run_tests.sh -bfj
benchmark-x86: benchmark-x86:
extends: .base extends: .benchmark
stage: test-interpreter stage: test-interpreter
script: script:
- cd test - cd test
- ./run_tests.sh -3bf - ./run_tests.sh -3bfj
benchmark-wasm: benchmark-wasm:
extends: .base extends: .benchmark
stage: test-interpreter stage: test-interpreter
script: script:
- cd test - cd test
- ./run_tests.sh -wb - ./run_tests.sh -wbj
interworking-Start: interworking-Start:
extends: .base extends: .base
......
*.result *.result
*.junit.xml
acker acker
arrays arrays
......
...@@ -26,6 +26,7 @@ RUN_ONLY=() ...@@ -26,6 +26,7 @@ RUN_ONLY=()
PROFILE=0 PROFILE=0
QUIET=0 QUIET=0
OPTIMISE=1 OPTIMISE=1
JUNIT_EXPORT=0
cpprj () { cpprj () {
if [ $OPTIMISE -gt 0 ]; then if [ $OPTIMISE -gt 0 ]; then
...@@ -36,7 +37,7 @@ cpprj () { ...@@ -36,7 +37,7 @@ cpprj () {
[ "$OS" == "Windows_NT" ] && sed -i 's:\*lib\*:*Libraries*:' "$2" [ "$OS" == "Windows_NT" ] && sed -i 's:\*lib\*:*Libraries*:' "$2"
} }
cpmq() { cpmq () {
res="$(cpm $@)" res="$(cpm $@)"
ecode=$? ecode=$?
echo "$res" | grep -i 'Error' >/dev/null echo "$res" | grep -i 'Error' >/dev/null
...@@ -49,6 +50,30 @@ cpmq() { ...@@ -49,6 +50,30 @@ cpmq() {
fi 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 () { print_help () {
echo "$0: run tests" echo "$0: run tests"
echo echo
...@@ -71,6 +96,7 @@ print_help () { ...@@ -71,6 +96,7 @@ print_help () {
echo " -d Print all instructions as they are executed" echo " -d Print all instructions as they are executed"
echo " -l List bytecode before execution" echo " -l List bytecode before execution"
echo " -p Make PDF profiles (e.g. nfib.prof.pdf) using google-pprof" 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 exit 0
} }
...@@ -86,7 +112,7 @@ contains () { ...@@ -86,7 +112,7 @@ contains () {
return 1 return 1
} }
OPTS=`getopt "Ho:wbMfh:Os:3dlpq" "$@"` || print_usage OPTS=`getopt "Ho:wbMfh:Os:3dlpjq" "$@"` || print_usage
eval set -- "$OPTS" eval set -- "$OPTS"
while true; do while true; do
...@@ -143,6 +169,9 @@ while true; do ...@@ -143,6 +169,9 @@ while true; do
export CPUPROFILE_FREQUENCY=10000 export CPUPROFILE_FREQUENCY=10000
PROFILE=1 PROFILE=1
shift;; shift;;
-j)
JUNIT_EXPORT=1
shift;;
-q) -q)
QUIET=1 QUIET=1
shift;; shift;;
...@@ -240,15 +269,17 @@ do ...@@ -240,15 +269,17 @@ do
[ "$OS" == "Windows_NT" ] && dos2unix $MODULE.result [ "$OS" == "Windows_NT" ] && dos2unix $MODULE.result
EXPECTED="$MODULE$EXPECTED_PREFIX.expected"
if [ $BENCHMARK -gt 0 ] && [ -f "$MODULE.bm$EXPECTED_PREFIX.expected" ]; then 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 EXPECTED="$MODULE.bm$EXPECTED_PREFIX.expected"
else
git diff --no-index --word-diff -U0 $MODULE$EXPECTED_PREFIX.expected $MODULE.result
fi fi
git diff --no-index --word-diff -U0 $EXPECTED $MODULE.result
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
[ $JUNIT_EXPORT -gt 0 ] && junit_export $MODULE failed "$EXPECTED" > "$MODULE.junit.xml"
echo -e "${RED}FAILED: $MODULE (different result)$RESET" echo -e "${RED}FAILED: $MODULE (different result)$RESET"
FAILED+=("$MODULE") FAILED+=("$MODULE")
else else
[ $JUNIT_EXPORT -gt 0 ] && junit_export "$MODULE" passed "$EXPECTED" > "$MODULE.junit.xml"
echo -e "${GREEN}Passed: $MODULE$RESET" echo -e "${GREEN}Passed: $MODULE$RESET"
fi fi
done 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