2
0

collect-test-logs.sh 938 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. echo "Collecting test logs"
  3. LOG_DIR=./logs
  4. html="<html><h3>There are failed unit-tests:</h3><table>"
  5. logs=$(find $LOG_DIR -type f -iname "*.html" -print | sort)
  6. logs_found=0
  7. olddirname=""
  8. for name in $logs
  9. do
  10. logname=$(basename $name)
  11. testname=$(echo $logname | awk -F 'log_run-tests_' '{print $2}' | awk -F '.html' '{print $1}')
  12. testpath="${testname//!/\/}"
  13. dirname=$(dirname $testpath)
  14. test=$(basename $testpath)
  15. if [ "$olddirname" != "$dirname" ]; then
  16. html+="<tr align=\"left\"><th><br>$dirname</th></tr>" ;
  17. olddirname=$dirname ;
  18. fi
  19. html+="<tr align=\"left\"><td><a href="$logname">$test</a>"
  20. backtrace="backtrace_$testname.txt"
  21. if test -f "${LOG_DIR}/$backtrace"; then
  22. html+=". Core dumped, backtrace is available <a href=\"$backtrace\">here</a>"
  23. fi
  24. html+="</td></tr>"
  25. logs_found=1
  26. done
  27. if [ $logs_found -ne 0 ]; then
  28. html+="</table></html>"
  29. echo $html > $LOG_DIR/artifacts.html
  30. exit 1
  31. fi
  32. exit 0