aboutsummaryrefslogtreecommitdiff
path: root/scripts/generate-reports.sh
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2026-07-21 20:19:46 -0500
committerAlexander M Pickering <alex@cogarr.net>2026-07-21 20:19:46 -0500
commit657fb0007f39f07cc0401e0c5d03e25df6234aa4 (patch)
treef73fe23232dc80802f39caed738c38464a60ec6d /scripts/generate-reports.sh
downloadtrbldoc-657fb0007f39f07cc0401e0c5d03e25df6234aa4.tar.gz
trbldoc-657fb0007f39f07cc0401e0c5d03e25df6234aa4.tar.bz2
trbldoc-657fb0007f39f07cc0401e0c5d03e25df6234aa4.zip
Inital commit.
Diffstat (limited to 'scripts/generate-reports.sh')
-rw-r--r--scripts/generate-reports.sh58
1 files changed, 58 insertions, 0 deletions
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-<timestamp>)
+# -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"