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"