summaryrefslogtreecommitdiff
path: root/src/test/lib/test_to_junit.sh
diff options
context:
space:
mode:
authorRobert Norton2017-07-19 18:08:02 +0100
committerRobert Norton2017-07-19 18:08:02 +0100
commit632b10c0d4b01dc1af8593b8ae1f088fbfd9e342 (patch)
treeac566808213125670da5f4dc3d702fe663333f7e /src/test/lib/test_to_junit.sh
parentd8969b1f9631dc15d5fb6b3b33a4a69dbfb7358a (diff)
split library tests into separate files to avoid risk of sail compiler stack overflow.
Diffstat (limited to 'src/test/lib/test_to_junit.sh')
-rwxr-xr-xsrc/test/lib/test_to_junit.sh32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/test/lib/test_to_junit.sh b/src/test/lib/test_to_junit.sh
index 65753835..71e908bd 100755
--- a/src/test/lib/test_to_junit.sh
+++ b/src/test/lib/test_to_junit.sh
@@ -12,6 +12,8 @@ fail=0
XML=""
+XML_FILE=tests.xml
+
function green {
(( pass += 1 ))
printf "$1: ${GREEN}$2${NC}\n"
@@ -33,24 +35,28 @@ function red {
function finish_suite {
printf "$1: Passed ${pass} out of $(( pass + fail ))\n"
XML=" <testsuite name=\"$1\" tests=\"$(( pass + fail ))\" failures=\"${fail}\" timestamp=\"$(date)\">\n$XML </testsuite>\n"
- printf "$XML" > $1.xml
+ printf "$XML" >> $XML_FILE
XML=""
pass=0
fail=0
}
-test_regex="^(.*): (pass|fail)$"
-while read line; do
- if [[ $line =~ $test_regex ]] ; then
- test_name=${BASH_REMATCH[1]}
- test_status=${BASH_REMATCH[2]}
- if [[ $test_status == pass ]] ; then
- green $test_name $test_status
+test_regex="^\"*([^\"]*)\"*: (pass|fail)$"
+echo "<testsuites>" > $XML_FILE
+for result_file in $@; do
+ while read line; do
+ if [[ $line =~ $test_regex ]] ; then
+ test_name=${BASH_REMATCH[1]}
+ test_status=${BASH_REMATCH[2]}
+ if [[ $test_status == pass ]] ; then
+ green $test_name $test_status
+ else
+ red $test_name $test_status
+ fi
else
- red $test_name $test_status
+ echo $line
fi
- else
- echo $line
- fi
+ done < "$result_file"
+ finish_suite $result_file
done
-finish_suite all_tests
+echo "</testsuites>" >> $XML_FILE