Skip to content

Commit

Permalink
tools: Add test coverage html output (sourcenetwork#466)
Browse files Browse the repository at this point in the history
- RELEVANT ISSUE(S)
Resolves sourcenetwork#466 

- DESCRIPTION
Instead of relying on codecov to inspect our code coverage, we can do it locally using -coverprofile. This PR adds a make command to simplify the process.
  • Loading branch information
fredcarle committed May 24, 2022
1 parent 249ecda commit 20e62a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ coverage-full.txt
coverage-quick.txt
tests/bench/*.log
tests/bench/*.svg
.vscode
.vscode
coverage.out
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ test\:coverage-full: deps\:coverage
go-acc ./... --output=coverage-full.txt --covermode=atomic
go tool cover -func coverage-full.txt | grep total | awk '{print $$3}'

# Usage: make test:coverage-html path="{pathToPackage}"
.PHONY: test\:coverage-html
test\:coverage-html:
ifeq ($(path),)
go test ./... -v -race -coverprofile=coverage.out
else
go test $(path) -v -race -coverprofile=coverage.out
endif
go tool cover -html=coverage.out
rm ./coverage.out

# This only covers how much of the package is tested by itself (unit test).
.PHONY: test\:coverage-quick
test\:coverage-quick:
Expand Down

0 comments on commit 20e62a8

Please sign in to comment.