1 # Regression test for #60939: when 'go tool dist' is missing,
2 # 'go tool dist list' should inject its output.
3
4
5 # Set GOROOT to a directory that definitely does not include
6 # a compiled 'dist' tool. 'go tool dist list' should still
7 # work, because 'cmd/go' itself can impersonate this command.
8
9 mkdir $WORK/goroot/bin
10 mkdir $WORK/goroot/pkg/tool/${GOOS}_${GOARCH}
11 env GOROOT=$WORK/goroot
12
13 ! go tool -n dist
14 stderr 'go: no such tool "dist"'
15
16 go tool dist list
17 stdout linux/amd64
18 cp stdout tool.txt
19
20 go tool dist list -v
21 stdout linux/amd64
22 cp stdout tool-v.txt
23
24 go tool dist list -broken
25 stdout $GOOS/$GOARCH
26 cp stdout tool-broken.txt
27
28 go tool dist list -json
29 stdout '"GOOS": "linux",\n\s*"GOARCH": "amd64",\n'
30 cp stdout tool-json.txt
31
32 go tool dist list -json -broken
33 stdout '"GOOS": "'$GOOS'",\n\s*"GOARCH": "'$GOARCH'",\n'
34 cp stdout tool-json-broken.txt
35
36 [short] stop
37
38
39 # Check against the real cmd/dist as the source of truth.
40
41 env GOROOT=$TESTGO_GOROOT
42 go build -o dist.exe cmd/dist
43
44 exec ./dist.exe list
45 cmp stdout tool.txt
46
47 exec ./dist.exe list -v
48 cmp stdout tool-v.txt
49
50 exec ./dist.exe list -broken
51 cmp stdout tool-broken.txt
52
53 exec ./dist.exe list -json
54 cmp stdout tool-json.txt
55
56 exec ./dist.exe list -json -broken
57 cmp stdout tool-json-broken.txt
58
View as plain text