#!/bin/sh # scripts/generate-reports.sh # Convenience wrapper: run both the profiler and the coverage report for a # suite into a single timestamped directory under reports/. # # POSIX sh; works under mingw bash, WSL bash and Alpine/busybox ash. # # Usage: # scripts/generate-reports.sh [-s all|unit|integration] [-o OUTDIR] # [-p] [-m MIN_PERCENT] [-t "file.sh ..."] # # -s SUITE suite to run (default: integration) # -o OUTDIR base output directory (default: reports/run-) # -p include per-line hotspots in the profile report # -m MIN_PERCENT coverage threshold to enforce (default: 0 = no gate) # -t LIST space-separated target source files (default: trbldoc.sh) set -u SELF="$0" . "$(dirname -- "$0")/lib/common.sh" tb_resolve_paths "$SELF" SUITE=integration OUTDIR="" HOTSPOTS=0 MIN_PERCENT=0 TARGETS="trbldoc.sh" while getopts ":s:o:pm:t:h" opt; do case "$opt" in s) SUITE="$OPTARG" ;; o) OUTDIR="$OPTARG" ;; p) HOTSPOTS=1 ;; m) MIN_PERCENT="$OPTARG" ;; t) TARGETS="$OPTARG" ;; h) sed -n '2,20p' "$SELF"; exit 0 ;; :) tb_die "option -$OPTARG requires an argument" ;; \?) tb_die "unknown option -$OPTARG" ;; esac done [ -n "$OUTDIR" ] || OUTDIR="$REPO_ROOT/reports/run-$(tb_timestamp)" mkdir -p "$OUTDIR" || tb_die "cannot create output dir: $OUTDIR" PROFILE_ARGS="-s $SUITE -o $OUTDIR/profile -t $TARGETS" [ "$HOTSPOTS" -eq 1 ] && PROFILE_ARGS="$PROFILE_ARGS -p" tb_info "=== profiling ===" # shellcheck disable=SC2086 sh "$SCRIPTS_DIR/profile-tests.sh" $PROFILE_ARGS tb_info "=== coverage ===" # shellcheck disable=SC2086 sh "$SCRIPTS_DIR/coverage-tests.sh" -s "$SUITE" -o "$OUTDIR/coverage" \ -t "$TARGETS" -m "$MIN_PERCENT" printf '\nAll reports under: %s\n' "$OUTDIR"