Skip to content

Commit

Permalink
fix test coverage check
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Dec 5, 2024
1 parent a037c1c commit dcdd2e0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/wasp-test-benchspy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,3 @@ jobs:
if: steps.changes.outputs.src == 'true'
run: |-
nix develop -c make test_benchspy_race
coverage=$(go tool cover -func=cover.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
if (( $(echo "$coverage < 85" | bc -l) )); then
echo "Test coverage $coverage% is below minimum 85%"
exit 1
fi
echo "Test coverage: $coverage%"
2 changes: 1 addition & 1 deletion wasp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_race:

.PHONY: test_benchspy_race
test_benchspy_race:
go test -v -race -coverprofile cover.out -count 1 `go list ./... | grep -v examples | grep benchspy` -run TestBenchSpy
@./scripts/run_benchspy_tests.sh

.PHONY: test_bench
test_bench:
Expand Down
14 changes: 14 additions & 0 deletions wasp/scripts/run_benchspy_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

go test -v -race -coverprofile cover.out -count 1 `go list ./... | grep -v examples | grep benchspy` -run TestBenchSpy
coverage=$(go tool cover -func=cover.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
if [ -z "$coverage" ]; then
echo "Error: Could not determine test coverage";
exit 1
fi

if [[ $(echo "$coverage < 85" | bc -l) -eq 1 ]]; then
echo "Test coverage $coverage% is below minimum 85%"
exit 1
fi
echo "Test coverage: $coverage%"

0 comments on commit dcdd2e0

Please sign in to comment.