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>
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