feat: improve Go test coverage script by adding trap for coverage file cleanup and ensuring readonly module mode
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user