1
0
mirror of https://github.com/golang/go synced 2024-09-29 12:14:28 -06:00

cmd/fix: allow cgo commands in tests to fail if 'go build' is not supported

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>
This commit is contained in:
Bryan C. Mills 2022-11-16 20:24:03 -05:00 committed by Gopher Robot
parent b138e71e5b
commit 3f5b02d09f

View 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