#!/usr/bin/env bash ### shfmt -w -s -ci -sr -kp -fn tests/unit/collect-test-logs.sh #------------------------------------------------------------------------------ # Collects test logs and generates an HTML report # of failed unit tests with links to backtraces #------------------------------------------------------------------------------ # Configuration with default value LOG_DIR="./logs" PRINT_TO_CONSOLE=0 # Parse command line arguments while [[ $# -gt 0 ]]; do case $1 in -p | --print) if ! command -v html2text > /dev/null 2>&1; then echo "Error: html2text is required for printing HTML contents" echo "Please install html2text and try again" exit 1 fi PRINT_TO_CONSOLE=1 shift ;; -d | --dir) if [ -z "$2" ]; then echo "Error: Log directory path is required for -d|--dir option" exit 1 fi LOG_DIR="$2" shift 2 ;; *) echo "Unknown option: $1" echo "Usage: $0 [-p|--print] [-d|--dir DIR]" exit 1 ;; esac done # Initialize HTML echo "Collecting test logs" html="
$dirname |
---|
$test" # Check for backtrace backtrace="backtrace_$testname.txt" if test -f "${LOG_DIR}/$backtrace"; then if [ $PRINT_TO_CONSOLE -eq 1 ]; then echo "Core dumped, backtrace:" cat $backtrace echo fi html+=". Core dumped, backtrace is available here" fi html+=" |