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

Prepare for upcoming go1.22 changes #106

Open
mfridman opened this issue Dec 13, 2023 · 1 comment
Open

Prepare for upcoming go1.22 changes #106

mfridman opened this issue Dec 13, 2023 · 1 comment

Comments

@mfridman
Copy link
Owner

mfridman commented Dec 13, 2023

go test -cover now prints coverage summaries for covered packages that do not have their own test files. Prior to Go 1.22 a go test -cover run for such a package would report

? mymod/mypack [no test files]

and now with Go 1.22, functions in the package are treated as uncovered:

mymod/mypack coverage: 0.0% of statements

Reference: go1.22 Release Notes

We'll need to handle this, since ?.*[no test files] was the only way to get at packages without test files.

@mfridman
Copy link
Owner Author

mfridman commented Feb 8, 2024

From the release notes, https://tip.golang.org/doc/go1.22#tools

go test -cover now prints coverage summaries for covered packages that do not have their own test files. Prior to Go 1.22 a go test -cover run for such a package would report

? mymod/mypack [no test files]

and now with Go 1.22, functions in the package are treated as uncovered:

mymod/mypack coverage: 0.0% of statements

Note that if a package contains no executable code at all, we can't report a meaningful coverage percentage; for such packages the go tool will continue to report that there are no test files.

Example

CleanShot 2024-02-08 at 18 38 09@2x

I dunno, I kind of liked the previous behaviour because it was obvious the package contained no tests, seems like a step back?

Dropped a golang/go#24570 (comment) upstream, but I think that's moot. And I'm probably in the minority that preferred the existing behaviour, so there's probably not much we can do here to aid users outside suggestion scanning for 0.0% when running -cover.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant