Skip to content
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

proposal: cmd/cover: add flag to print total coverage number #47398

Closed
matrixik opened this issue Jul 26, 2021 · 7 comments
Closed

proposal: cmd/cover: add flag to print total coverage number #47398

matrixik opened this issue Jul 26, 2021 · 7 comments

Comments

@matrixik
Copy link

I would like cover tool to have flag outputing total coverage that could be then later used in some custom scripts (like in CI).

Example:

λ go tool cover -func=coverage.out
slug/slug.go:43:		fooA		100.0%
slug/slug.go:49:		fooB		100.0%
slug/slug.go:106:		fooC		100.0%
total:				(statements)	100.0%

# now in script (could break if output format change)
λ go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'
100.0

# some flag idea
λ go tool cover -total-number -func=coverage.out
100.0
$ go version
go version go1.16.6 linux/amd64
λ go tool cover -V
cover version go1.16.6
@gopherbot gopherbot added this to the Proposal milestone Jul 26, 2021
@earthboundkid
Copy link
Contributor

ISTM, a -json flag would be more general and useful.

@ianlancetaylor ianlancetaylor added this to Incoming in Proposals (old) Jul 28, 2021
@bcmills
Copy link
Contributor

bcmills commented Aug 3, 2021

See previously #16888.

@rsc rsc moved this from Incoming to Active in Proposals (old) Aug 4, 2021
@rsc
Copy link
Contributor

rsc commented Aug 4, 2021

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@matrixik
Copy link
Author

matrixik commented Aug 4, 2021

See previously #16888.

#16888 wanted to change existing output (reason for abandonment), here I'm asking about new and always stable output.

@rsc
Copy link
Contributor

rsc commented Aug 11, 2021

I think at this point we are happy to say that the output format of go tool cover -func=coverage.out is not going to change.
That seems like a better solution than a separate flag that prints a single number.
(Printing the single number puts too much emphasis on that one metric.)

@rsc
Copy link
Contributor

rsc commented Aug 18, 2021

Based on the discussion above, this proposal seems like a likely decline.
— rsc for the proposal review group

@rsc rsc moved this from Active to Likely Decline in Proposals (old) Aug 18, 2021
@rsc rsc moved this from Likely Decline to Declined in Proposals (old) Aug 25, 2021
@rsc
Copy link
Contributor

rsc commented Aug 25, 2021

No change in consensus, so declined.
— rsc for the proposal review group

@rsc rsc closed this as completed Aug 25, 2021
@golang golang locked and limited conversation to collaborators Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

5 participants