2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Modify custom-test-driver to interpret JUnit results

Pytest provides JUnit output and uses different exit codes from
Automake. Use the conversion script to interpret the JUnit test results
from python rather than relying on the status code.
This commit is contained in:
Tom Krizek 2023-09-05 10:29:13 +02:00
parent b96c8e8062
commit 295890a16b
No known key found for this signature in database
GPG Key ID: 01623B9B652A20A7
2 changed files with 11 additions and 12 deletions

View File

@ -13,6 +13,7 @@ named.run
/random.data
/*.log
/*.trs
/*.xml
/resolve
/legacy.run.sh
/run.log

View File

@ -56,7 +56,7 @@ END
test_name= # Used for reporting.
log_file= # Where to save the output of the test script.
trs_file= # Where to save the metadata of the test run.
status_file= # Where to save the status of the test run.
junit_file= # Where to save pytest junit output.
expect_failure=no
color_tests=no
enable_hard_errors=yes
@ -67,8 +67,7 @@ while test $# -gt 0; do
--version) echo "test-driver $scriptversion"; exit $?;;
--test-name) test_name=$2; shift;;
--log-file) log_file=$2; shift;;
--trs-file) trs_file=$2; shift;;
--status-file) status_file=$2; shift;;
--trs-file) trs_file=$2; junit_file=$(echo $trs_file | sed 's/\.trs$/\.xml/'); shift;;
--color-tests) color_tests=$2; shift;;
--expect-failure) expect_failure=$2; shift;;
--enable-hard-errors) enable_hard_errors=$2; shift;;
@ -104,22 +103,22 @@ else
red= grn= lgn= blu= mgn= std=
fi
do_exit='rm -f $log_file $trs_file $status_file; (exit $st); exit $st'
do_exit='rm -f $log_file $trs_file $junit_file; (exit $st); exit $st'
trap "st=129; $do_exit" 1
trap "st=130; $do_exit" 2
trap "st=141; $do_exit" 13
trap "st=143; $do_exit" 15
# Set default
test x"$status_file" = x && status_file=$(mktemp ./custom-test-runner.XXXXXX)
# Test script is run here.
if test $verbose = yes; then
("$@" 2>&1; echo $? > "$status_file") | tee $log_file
"$@" --junit-xml $PWD/$junit_file 2>&1 | tee $log_file
else
"$@" >$log_file 2>&1; echo $? > "$status_file"
"$@" --junit-xml $PWD/$junit_file >$log_file 2>&1
fi
read -r estatus < "$status_file"
rm "$status_file"
# Run junit to trs converter script.
./convert-junit-to-trs.py $junit_file > $trs_file
estatus=$?
if test $enable_hard_errors = no && test $estatus -eq 99; then
tweaked_estatus=1
@ -145,8 +144,7 @@ echo "$res $test_name (exit status: $estatus)" >>$log_file
# Report outcome to console.
echo "${col}${res}${std}: $test_name"
# Register the test result, and other relevant metadata.
echo ":test-result: $res" > $trs_file
# Register other relevant test metadata.
echo ":global-test-result: $res" >> $trs_file
echo ":recheck: $recheck" >> $trs_file
echo ":copy-in-global-log: $gcopy" >> $trs_file