#!/bin/bash
echo "Collecting test logs"
LOG_DIR=./logs
html="
There are failed unit-tests:
"
logs=$(find $LOG_DIR -type f -iname "*.html" -print | sort)
logs_found=0
olddirname=""
for name in $logs
do
logname=$(basename $name)
testname=$(echo $logname | awk -F 'log_run-tests_' '{print $2}' | awk -F '.html' '{print $1}')
testpath="${testname//!/\/}"
dirname=$(dirname $testpath)
test=$(basename $testpath)
if [ "$olddirname" != "$dirname" ]; then
html+=" $dirname |
" ;
olddirname=$dirname ;
fi
html+="$test"
backtrace="backtrace_$testname.txt"
if test -f "${LOG_DIR}/$backtrace"; then
html+=". Core dumped, backtrace is available here"
fi
html+=" |
"
logs_found=1
done
if [ $logs_found -ne 0 ]; then
html+="
"
echo $html > $LOG_DIR/artifacts.html
exit 1
fi
exit 0