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:
2
Makefile
2
Makefile
@@ -13,7 +13,7 @@ build:
|
|||||||
# Run all tests (skips known broken tests listed in .test-skip)
|
# Run all tests (skips known broken tests listed in .test-skip)
|
||||||
test:
|
test:
|
||||||
@echo "Running tests..."
|
@echo "Running tests..."
|
||||||
@./scripts/test.sh
|
@TEST_COVER=1 ./scripts/test.sh
|
||||||
|
|
||||||
# Run performance benchmarks (10K and 20K issue databases with automatic CPU profiling)
|
# Run performance benchmarks (10K and 20K issue databases with automatic CPU profiling)
|
||||||
# Generates CPU profile: internal/storage/sqlite/bench-cpu-<timestamp>.prof
|
# Generates CPU profile: internal/storage/sqlite/bench-cpu-<timestamp>.prof
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ TIMEOUT="${TEST_TIMEOUT:-3m}"
|
|||||||
SKIP_PATTERN=$(build_skip_pattern)
|
SKIP_PATTERN=$(build_skip_pattern)
|
||||||
VERBOSE="${TEST_VERBOSE:-}"
|
VERBOSE="${TEST_VERBOSE:-}"
|
||||||
RUN_PATTERN="${TEST_RUN:-}"
|
RUN_PATTERN="${TEST_RUN:-}"
|
||||||
|
COVERAGE="${TEST_COVER:-}"
|
||||||
|
COVERPROFILE="${TEST_COVERPROFILE:-/tmp/beads.coverage.out}"
|
||||||
|
COVERPKG="${TEST_COVERPKG:-./...}"
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
PACKAGES=()
|
PACKAGES=()
|
||||||
@@ -77,10 +80,22 @@ if [[ -n "$RUN_PATTERN" ]]; then
|
|||||||
CMD+=(-run "$RUN_PATTERN")
|
CMD+=(-run "$RUN_PATTERN")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$COVERAGE" ]]; then
|
||||||
|
CMD+=(-covermode=atomic -coverpkg "$COVERPKG" -coverprofile "$COVERPROFILE")
|
||||||
|
fi
|
||||||
|
|
||||||
CMD+=("${PACKAGES[@]}")
|
CMD+=("${PACKAGES[@]}")
|
||||||
|
|
||||||
echo "Running: ${CMD[*]}" >&2
|
echo "Running: ${CMD[*]}" >&2
|
||||||
echo "Skipping: $SKIP_PATTERN" >&2
|
echo "Skipping: $SKIP_PATTERN" >&2
|
||||||
echo "" >&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
|
||||||
|
|||||||
Reference in New Issue
Block a user