Hi Brian,
thanks for checking out, yes that I wanted also to write you.
We need it currently in our CI as some dependency scanner tool does not work with the "go X.Y.Z." syntax, but I tried, and for my problem it did not was the cause.
> If a test fails, I would expect it to terminate with an error (exit code 1 in this case).
See my second mail, the test case should not fail, it was kinda a typo (tried to shorten the reproducer to much in my first mail).
> If I run your reproducer locally (not in Docker) with the modified TestHelloer, it works fine(*) and gives me an exit code of 0
Yes, when I run it with golang 1.21.7 it works fine as well, as my problem statement is about golang 1.22.0.
> Therefore, if your problem only occurs when using Docker, then you should provide a docker-based reproducer (including the Dockerfile)
Happens locally as well. And in my original setup it was using a fresh docker container from golang (in an CI/GitLab pipeline) and did this:
$ go test -v ./... -coverprofile=coverage.out -coverpkg=./internal/... -covermode count || echo "flaky:$?"
example.com/m: open /tmp/go-build2233205084/b002/covmeta.f6e4431d5ec1fd71f02b3ce4e56eb691a86525173d917007425576a7d9db7c72: no such file or directory
=== RUN TestHelloer
--- PASS: TestHelloer (0.00s)
PASS
coverage: 100.0% of statements in ./internal/...
But I just tried it locally (Windows) and there it happens as well:
C:\dev\git\golang-test-cover>go test -v ./... -coverprofile=coverage.out -coverpkg=./internal/... -covermode count
example.com/m: open C:\Users\A1524415\AppData\Local\Temp\go-build2423189316\b002\covmeta.f6e4431d5ec1fd71f02b3ce4e56eb691a86525173d917007425576a7d9db7c72: The system cannot find the file specified.
=== RUN TestHelloer
--- PASS: TestHelloer (0.00s)
PASS
coverage: 100.0% of statements in ./internal/...
So for now I checked it on:
- windows
- debian (via docker container)
- alpine (via docker container)
All with 1.22.0.
> since you say that the coverage file is created, and presumably you would have noticed the "toolchain not available" error message. In any case, you're using a base image with go 1.22.0.
Exactly.
As seen in the output above, further commands (go tool cover) using the coverage.out work fine.