]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/fix: allow cgo commands in tests to fail if 'go build' is not supported
authorBryan C. Mills <bcmills@google.com>
Thu, 17 Nov 2022 01:24:03 +0000 (20:24 -0500)
committerGopher Robot <gobot@golang.org>
Thu, 17 Nov 2022 02:37:07 +0000 (02:37 +0000)
testenv.HasCgo reports whether the test binary may have been built
with cgo enabled, but having been built with cgo does not necessarily
imply that the test can invoke the cgo tool itself.

This should fix a test failure on the android builders introduced in
CL 450714.

Change-Id: I2eed4098736e1cb285ca20bc248b0ab3515f0dea
Reviewed-on: https://go-review.googlesource.com/c/go/+/451221
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

src/cmd/fix/main_test.go

index 837a5d72c7216497086539d4fdb018d743e1e6d6..2b293077d13f6df09d8b5373cd57bc7ae1c0f408 100644 (file)
@@ -17,7 +17,7 @@ import (
 func init() {
        // If cgo is enabled, enforce that cgo commands invoked by cmd/fix
        // do not fail during testing.
-       if testenv.HasCGO() {
+       if testenv.HasCGO() && testenv.HasGoBuild() {
                // The reportCgoError hook is global, so we can't set it per-test
                // if we want to be able to run those tests in parallel.
                // Instead, simply set it to panic on error: the goroutine dump