-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
cmd/test2json: CGO_ENABLED is set, when running tests from prebuilt binary #54545
Comments
I think the following fragment is responsible for this discrepancy: Lines 202 to 213 in 6001c04
|
Arguably the test is both fragile and wrong, it tests for an unset value (ie use the default) when it actually needs the specific value of off. |
Change https://go.dev/cl/424999 mentions this issue: |
The point is that the go/src/cmd/go/internal/test/test.go Line 1358 in bf4e35b
The PR #54554 align this to be the same. |
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
make repro
What did you expect to see?
I expect to see the test pass regardless if executed via:
or
What did you see instead?
The process fails with the following output:
Additional context
I stumbled on this problem while running tests via the Goland IDE. The Goland IDE uses the pair of commands to execute tests:
We are executing google/ko in our tests to built test OCI images. KO sets the
CGO_ENABLED=0
by default because the default base image is distroless, which doesn't contain any system libraries.When I execute tests from Goland IDE, I have effectively
CGO_ENABLED=1
when the test starts. This overrides the KO default value, and the produced image is invalid. The faulty image contains dynamic binary, which can't run on distroless.When the tests are executed with
go test
directly, all is well.I think running tests via
go tool test2json -t
shouldn't change the execution environment for the test.See also: knative-extensions/control-protocol#204
The text was updated successfully, but these errors were encountered: