test: report total coverage from make test

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
Jordan Hubbard
2025-12-26 09:47:48 -04:00
parent 7af3106610
commit 6c37a58148
2 changed files with 17 additions and 2 deletions

View File

@@ -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-<timestamp>.prof

View File

@@ -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