blob: 77c4b0f037073b14f3566763db050a719fcc8714 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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"
|