From 4fcc0d6c4f7dd55cb300a78e48abec340d282b2e Mon Sep 17 00:00:00 2001 From: Wikid82 Date: Thu, 20 Nov 2025 11:37:37 -0500 Subject: [PATCH] feat: improve Go test coverage script by adding trap for coverage file cleanup and ensuring readonly module mode --- scripts/go-test-coverage.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/go-test-coverage.sh b/scripts/go-test-coverage.sh index 54538069..f2ac8be6 100755 --- a/scripts/go-test-coverage.sh +++ b/scripts/go-test-coverage.sh @@ -6,9 +6,11 @@ BACKEND_DIR="$ROOT_DIR/backend" COVERAGE_FILE="$BACKEND_DIR/coverage.pre-commit.out" MIN_COVERAGE="${CPM_MIN_COVERAGE:-40}" +trap 'rm -f "$COVERAGE_FILE"' EXIT + cd "$BACKEND_DIR" -go test -coverprofile="$COVERAGE_FILE" ./internal/... +go test -mod=readonly -coverprofile="$COVERAGE_FILE" ./internal/... go tool cover -func="$COVERAGE_FILE" | tail -n 1 TOTAL_LINE=$(go tool cover -func="$COVERAGE_FILE" | grep total) @@ -30,6 +32,4 @@ if total < minimum: sys.exit(1) PY -rm -f "$COVERAGE_FILE" - echo "Coverage requirement met"