-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add code coverage report #1932
Add code coverage report #1932
Conversation
Code Coverage DiffThis PR does not change the code coverage |
@@ -74,7 +74,10 @@ clean: | |||
|
|||
.PHONY: test | |||
test: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer a separate target (perhaps make test/coverage
?) for generating the test coverage profile. I believe make test
should be reserved for just running the unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added new target as requested: make test/coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I just realized while test/coverage
is in line with what we use to separate sub-commands of other make targets (e.g. e2e/cluster
, the test-sanity
target now sticks out. I think this is fine though (if anything we should consider changing test-sanity
to test/sanity
in a separate PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully ran on Linux. Left one more comment about adding a section to our makefile documentation. Thanks for this!
@@ -9,8 +9,9 @@ bin | |||
# Test binary, build with `go test -c` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top level comment: Consider adding a section to local-development section of our makefile documentation. Perhaps something like:
### `make test/coverage`
Outputs a filtered version of the each package's unit test coverage profiling via go's coverage tool to a local `coverage.html` file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - added ✅
Makefile
Outdated
@@ -76,6 +76,13 @@ clean: | |||
test: | |||
go test -v -race ./cmd/... ./pkg/... | |||
|
|||
.PHONY: test/coverage | |||
test/coverage: | |||
go test -v -race -coverprofile=cover.out ./cmd/... ./pkg/... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: could probably ditch the -v
and -race
as this is separate from make test
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - changed ✅
Signed-off-by: Eddie Torres <[email protected]>
/retest |
3 similar comments
/retest |
/retest |
/retest |
/retest |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AndrewSirenko The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What is this PR about? / Why do we need it?
This PR makes modifications to
make test
to generate a test coverage report that explicitly excludes all generated mock files, giving contributors and maintainers more insight into code coverage.In place of using the
grep
tech to filter out mock files, I initially attempted to split out mocked code into its own separate package. However, I quickly discovered that this is not possible due to a circular dependencies issue. To prevent the import cycle we'd have to bring in the tests over to the mock package as well - this is undesirable as a) it would effectively break the code coverage measurement altogether and b) not a standard Go practice.What testing is done?