Skip to content

Commit

Permalink
internal/testenv: skip tests that need export data for std if 'go too…
Browse files Browse the repository at this point in the history
…l compile' does not exist

Now that .a files are no longer being preinstalled for
standard-library packages (#47257), tests that require the export data
from those files must have access to 'go list -export' in order to
generate and load export data from the Go build cache.

`go list -export` does not work without a Go compiler, so assume that
tests that need the 'go' command also need the compiler.

This may cause the tests currently failing on the android-.*-emu
builders to instead be skipped, since the test harness does not copy
the compiler to the execution environment.

For golang/go#47257.

Change-Id: Ie82ab09ac8165a01fc1d3a083b1e86226efc469d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/451597
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
  • Loading branch information
Bryan C. Mills authored and rinchsan committed Feb 19, 2023
1 parent 68d9bf9 commit 04742fb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ func hasTool(tool string) error {
GOROOT := strings.TrimSpace(string(out))
if GOROOT != runtime.GOROOT() {
checkGoGoroot.err = fmt.Errorf("'go env GOROOT' does not match runtime.GOROOT:\n\tgo env: %s\n\tGOROOT: %s", GOROOT, runtime.GOROOT())
return
}

// Also ensure that that GOROOT includes a compiler: 'go' commands
// don't in general work without it, and some builders
// (such as android-amd64-emu) seem to lack it in the test environment.
cmd := exec.Command(tool, "tool", "-n", "compile")
stderr := new(bytes.Buffer)
stderr.Write([]byte("\n"))
cmd.Stderr = stderr
out, err = cmd.Output()
if err != nil {
checkGoGoroot.err = fmt.Errorf("%v: %v%s", cmd, err, stderr)
return
}
if _, err := os.Stat(string(bytes.TrimSpace(out))); err != nil {
checkGoGoroot.err = err
}
})
if checkGoGoroot.err != nil {
Expand Down

0 comments on commit 04742fb

Please sign in to comment.