You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
testscript: remove our code coverage mechanism thanks to Go 1.20
Our code was a fairly hacky version of what Go 1.20 does for us,
since we had to externally reach into the testing internals
to do the right thing before and after each program execution.
With Go 1.20, all we actually need to do is ensure that the GOCOVERDIR
environment variable is forwarded properly. With that, test binaries
will know how to produce multiple coverage profiles, and "go test" will
know how to collect and merge them.
We could keep our hacky workaround for the sake of "deep" coverage
information for Go 1.19, but that doesn't seem worthwhile.
The old mechanism caused test flakes like #130,
is incompatible with Go 1.20, and is overall worse than what Go 1.20 can do.
If a user wants code coverage with the latest testscript version, they
can use Go 1.20. If they are stuck on Go 1.19 and need code coverage,
I imagine they can also stick to a slightly older testscript version.
On a main package, the old testscript with Go 1.19 reports:
PASS
coverage: 8.0% of statements
total coverage: 90.1% of statements
ok mvdan.cc/sh/v3/cmd/shfmt 0.063s
The new testscript with Go 1.20 reports:
PASS
mvdan.cc/sh/v3/cmd/shfmt coverage: 90.1% of statements
ok mvdan.cc/sh/v3/cmd/shfmt 0.047s
Fixes#130, as the RemoveAll call is no longer present.
Fixes#161, as the API is now deprecated.
Fixes#199, as "go test -coverprofile" now works on Go 1.20.
0 commit comments