mfridman / tparse

CLI tool for summarizing go test output. Pipe friendly. CI/CD friendly.
MIT License
998 stars 22 forks source link

Prepare for upcoming go1.22 changes #106

Open mfridman opened 9 months ago

mfridman commented 9 months ago

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 commented 7 months ago

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 https://github.com/golang/go/issues/24570#issuecomment-1935119394 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.