Skip to content

Commit a8fb949

Browse files
rscgopherbot
authored andcommitted
cmd/go: fix TestScript/tool_build_as_needed
This test assumes that changing GOOS/GOARCH results in an unrunnable binary, but that's not true if the user has go_GOOS_GOARCH_exec programs in their path (like I do). This test was timing out waiting to create a gomote to run a windows/amd64 binary. Rewrite the test not to assume that alternate GOOS/GOARCH binaries are unrunnable. Fixes one failing case in 'go test cmd/go' on my Mac. Change-Id: Ib5f721f91e10d285820efb5995a3a9bc29833214 Reviewed-on: https://go-review.googlesource.com/c/go/+/718180 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
1 parent 04f0521 commit a8fb949

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/cmd/go/testdata/script/tool_build_as_needed.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ rm $TOOLDIR/test2json$GOEXE
4040
go tool -n test2json
4141
! stdout $NEWTOOLDIR${/}test2json$GOEXE
4242
# Set GOOS/GOARCH to different values than host GOOS/GOARCH.
43-
env GOOS=windows
44-
[GOOS:windows] env GOOS=linux
45-
env GOARCH=arm64
46-
[GOARCH:arm64] env GOARCH=amd64
43+
env GOOS=js
44+
env GOARCH=wasm
4745
# Control case: go run shouldn't work because it respects
4846
# GOOS/GOARCH, and we can't execute non-native binary.
49-
! go run cmd/test2json -exec=''
50-
# But go tool should because it doesn't respect GOOS/GOARCH.
47+
# Don't actually run the binary because maybe we can.
48+
# (Maybe the user has a go_js_wasm_exec installed.)
49+
# Instead just look to see that the right binary got linked.
50+
go run -n cmd/test2json
51+
stderr modinfo.*GOARCH=wasm.*GOOS=js
52+
# go tool should succeed because it doesn't respect GOOS/GOARCH.
5153
go tool test2json
5254
stdout '{"Action":"start"}'

0 commit comments

Comments
 (0)