From 657fb0007f39f07cc0401e0c5d03e25df6234aa4 Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Tue, 21 Jul 2026 20:19:46 -0500 Subject: Inital commit. --- scripts/generate-reports.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 scripts/generate-reports.sh (limited to 'scripts/generate-reports.sh') diff --git a/scripts/generate-reports.sh b/scripts/generate-reports.sh new file mode 100644 index 0000000..77c4b0f --- /dev/null +++ b/scripts/generate-reports.sh @@ -0,0 +1,58 @@ +#!/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" -- cgit v1.2.3-70-g09d2