-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: run tests when cmd/go is cross-compiled
When the GOOS or GOARCH of the cmd/go test binary does not match the GOOS or GOARCH of the installed 'go' binary itself, the test currently attempts to trick 'go test' into thinking that there were no test functions to run. That makes it very difficult to discover how to actually run the tests, which in turn makes it difficult to diagnose and fix regressions in, say, the linux-386-longtest builders. (We have had a few of those lately, and they shouldn't be as much of an ordeal to fix as they currently are.) There are three underlying problems: 1. cmd/go uses its own GOOS and GOARCH to figure out which variant of other tools to use, and the cache keys for all installed tools and libraries include the IDs of the tools used to build them. So when cmd/go's GOARCH changes, all installed tools and binaries appear stale *even if* they were just installed by invoking the native cmd/go with the appropriate GOARCH value set. 2. The "go/build" library used by cmd/go toggles its default CGO_ENABLED behavior depending on whether the GOOS and GOARCH being imported match runtime.GOOS and runtime.GOARCH. 3. A handful of cmd/go tests explicitly use gccgo, but the user's installed gccgo binary cannot necessarily cross-compile to the same platforms as cmd/go. To address the cache-invalidation problem, we modify the test variant of cmd/go to use the host's native toolchain (as indicated by the new TESTGO_GOHOSTOS and TESTGO_GOHOSTARCH environment variables) instead of the toolchain matching the test binary itself. That allows a test cmd/go binary compiled with GOARCH=386 to use libraries and tools cross-compiled by the native toolchain, so that $ GOARCH=386 go install std cmd suffices to make the packages in std and cmd non-stale in the tests. To address the CGO_ENABLED mismatch, we set CGO_ENABLED explicitly in the test's environment whenever it may differ from the default. Since script tests that use cgo are already expected to use a [cgo] condition, setting the environment to match that condition fixes the cgo-specific tests. To address the gccgo-specific cross-compilation failures, we add a new script condition, [cross], which evaluates to true whenever the platform of the test binary differs from that of the native toolchain. We can then use that condition to explicitly skip the handful of gccgo tests that fail under cross-compilation. Fixes #53936. Change-Id: I8633944f674eb5941ccc95df928991660e7e8137 Reviewed-on: https://go-review.googlesource.com/c/go/+/356611 Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]>
- Loading branch information
Showing
17 changed files
with
120 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.