From 6c37a58148ae8f607b1e648d474ff3958fcea6d0 Mon Sep 17 00:00:00 2001 From: Jordan Hubbard Date: Fri, 26 Dec 2025 09:47:48 -0400 Subject: [PATCH] test: report total coverage from make test Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- Makefile | 2 +- scripts/test.sh | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4ea2c17c..cc0cd528 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ build: # Run all tests (skips known broken tests listed in .test-skip) test: @echo "Running tests..." - @./scripts/test.sh + @TEST_COVER=1 ./scripts/test.sh # Run performance benchmarks (10K and 20K issue databases with automatic CPU profiling) # Generates CPU profile: internal/storage/sqlite/bench-cpu-.prof diff --git a/scripts/test.sh b/scripts/test.sh index dc826936..ac5729bf 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -24,6 +24,9 @@ TIMEOUT="${TEST_TIMEOUT:-3m}" SKIP_PATTERN=$(build_skip_pattern) VERBOSE="${TEST_VERBOSE:-}" RUN_PATTERN="${TEST_RUN:-}" +COVERAGE="${TEST_COVER:-}" +COVERPROFILE="${TEST_COVERPROFILE:-/tmp/beads.coverage.out}" +COVERPKG="${TEST_COVERPKG:-./...}" # Parse arguments PACKAGES=() @@ -77,10 +80,22 @@ if [[ -n "$RUN_PATTERN" ]]; then CMD+=(-run "$RUN_PATTERN") fi +if [[ -n "$COVERAGE" ]]; then + CMD+=(-covermode=atomic -coverpkg "$COVERPKG" -coverprofile "$COVERPROFILE") +fi + CMD+=("${PACKAGES[@]}") echo "Running: ${CMD[*]}" >&2 echo "Skipping: $SKIP_PATTERN" >&2 echo "" >&2 -exec "${CMD[@]}" +"${CMD[@]}" +status=$? + +if [[ -n "$COVERAGE" ]]; then + total=$(go tool cover -func="$COVERPROFILE" | awk '/^total:/ {print $NF}') + echo "Total coverage: ${total} (profile: ${COVERPROFILE})" >&2 +fi + +exit $status