1 [short] skip 'builds and runs go programs'
2 [!symlink] skip 'uses symlinks to construct a GOROOT'
3
4 env NEWGOROOT=$WORK${/}goroot
5 env TOOLDIR=$GOROOT/pkg/tool/${GOOS}_${GOARCH}
6 # Use ${/} in paths we'll check for in stdout below, so they contain '\' on Windows
7 env NEWTOOLDIR=$NEWGOROOT${/}pkg${/}tool${/}${GOOS}_${GOARCH}
8 mkdir $NEWGOROOT $NEWGOROOT/bin $NEWTOOLDIR
9 [symlink] symlink $NEWGOROOT/src -> $GOROOT/src
10 [symlink] symlink $NEWGOROOT/pkg/include -> $GOROOT/pkg/include
11 [symlink] symlink $NEWGOROOT/bin/go -> $GOROOT/bin/go
12 [symlink] symlink $NEWTOOLDIR/compile$GOEXE -> $TOOLDIR/compile$GOEXE
13 [symlink] symlink $NEWTOOLDIR/cgo$GOEXE -> $TOOLDIR/cgo$GOEXE
14 [symlink] symlink $NEWTOOLDIR/link$GOEXE -> $TOOLDIR/link$GOEXE
15 [symlink] symlink $NEWTOOLDIR/asm$GOEXE -> $TOOLDIR/asm$GOEXE
16 [symlink] symlink $NEWTOOLDIR/pack$GOEXE -> $TOOLDIR/pack$GOEXE
17 env GOROOT=$NEWGOROOT
18 env TOOLDIR=$NEWTOOLDIR
19
20 # GOROOT without test2json tool builds and runs it as needed
21 go env GOROOT
22 ! exists $TOOLDIR/test2json
23 go tool test2json
24 stdout '{"Action":"start"}'
25 ! exists $TOOLDIR/test2json$GOEXE
26 go tool -n test2json
27 ! stdout $NEWTOOLDIR${/}test2json$GOEXE
28
29 # GOROOT with test2json uses the test2json in the GOROOT
30 go install cmd/test2json
31 exists $TOOLDIR/test2json$GOEXE
32 go tool test2json
33 stdout '{"Action":"start"}'
34 go tool -n test2json
35 stdout $NEWTOOLDIR${/}test2json$GOEXE
36
37 # Tool still runs properly even with wrong GOOS/GOARCH
38 # Remove test2json from tooldir
39 rm $TOOLDIR/test2json$GOEXE
40 go tool -n test2json
41 ! stdout $NEWTOOLDIR${/}test2json$GOEXE
42 # Set GOOS/GOARCH to different values than host GOOS/GOARCH.
43 env GOOS=js
44 env GOARCH=wasm
45 # Control case: go run shouldn't work because it respects
46 # GOOS/GOARCH, and we can't execute non-native binary.
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.
53 go tool test2json
54 stdout '{"Action":"start"}'
55
View as plain text