Skip to content

Commit

Permalink
Better junit reporting, add stderr/out
Browse files Browse the repository at this point in the history
  • Loading branch information
sdedic committed Jan 12, 2022
1 parent 66c6df6 commit 233ec7a
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions nbbuild/travis/print-junit-report.sh
Expand Up @@ -17,18 +17,47 @@
# specific language governing permissions and limitations
# under the License.

echo junit report / failed tests:
#
files=$(grep -L 'errors="0".*failures="0"' ./*/*/build/test/*/results/TEST-*.xml 2> /dev/null) || exit 0

ls ./*/*/build/test/*/results/TEST-*.xml | while read file ;
do
TEST=$(xmllint --xpath '//testsuite[@failures>0]/@name' $file 2>/dev/null)
echo =================== JUnit Report Summary / failed tests ===================
realfiles=''
for file in $files ; do
TEST=$(xmllint --xpath '//testsuite[@errors>0 or @failures>0]/@name' $file 2>/dev/null)
status=$?

if [ $status -eq 0 ]; then
realfiles="$realfiles $file"
echo
echo $TEST | cut -f2 -d '=' | tr -d '"'
xmllint --xpath '//testsuite/testcase[./failure]/@name' $file | cut -f2 -d '=' | xargs -L1 echo " failed:"
xmllint --xpath '//testsuite/testcase[./failure]/@name' $file 2> /dev/null | sed -r 's/name="([^"]+)"/ failed: \1\n/g'
xmllint --xpath '//testsuite/testcase[./error]/@name' $file 2> /dev/null | sed -r 's/name="([^"]+)"/ errored: \1\n/g'
fi
done

echo end of report
echo
echo ====================== JUnit failure details ===============================
echo
for file in $realfiles ; do
classname=$(xmllint --xpath '//testsuite[@errors>0 or @failures>0]/@name' $file 2>/dev/null | cut -f2 -d '=' | tr -d '"')
echo Suite: $classname

for err in $(xmllint --xpath "//testsuite/testcase[@classname='${classname}'][./error]/@name" $file 2> /dev/null | sed -r 's/name="([^"]+)"/\1/g') ; do
msg=$(xmllint --xpath "//testsuite/testcase[@classname='${classname}' and @name='${err}']/error/@message" $file 2> /dev/null | sed -r 's/message="([^"]+)"/\1/g' )
echo " $err ERRORED : $msg"
xmllint --xpath "//testsuite/testcase[@classname='${classname}' and @name='${err}']/error/text()" $file 2> /dev/null | sed -r 's/^(.*$)/ \1/g'
done
for err in $(xmllint --xpath "//testsuite/testcase[@classname='${classname}'][./failure]/@name" $file 2> /dev/null | sed -r 's/name="([^"]+)"/\1/g') ; do
msg=$(xmllint --xpath "//testsuite/testcase[@classname='${classname}' and @name='${err}']/failure/@message" $file 2> /dev/null | sed -r 's/message="([^"]+)"/\1/g' )
echo " $err FAILED : $msg"
xmllint --xpath "//testsuite/testcase[@classname='${classname}' and @name='${err}']/failure/text()" $file 2> /dev/null | sed -r 's/^(.*$)/ \1/g'
done
text=$(xmllint --nocdata --xpath "//testsuite//system-out/text()" $file)
[ -n "$text" ] && { echo "Stdout ----------%<----------%<-------------%<-------------%<---------------" ; echo "$text" ; }
text=$(xmllint --nocdata --xpath "//testsuite//system-err/text()" $file)
[ -n "$text" ] && { echo "Stderr ----------%<----------%<-------------%<-------------%<---------------" ; echo "$text" ; }
echo "------------- End suite $classname ------------"

done
echo
echo ======================= End of JUnit report ===============================

0 comments on commit 233ec7a

Please sign in to comment.