...

Text file src/cmd/go/testdata/script/dist_list_missing.txt

Documentation: cmd/go/testdata/script

     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
     9mkdir $WORK/goroot/bin
    10mkdir $WORK/goroot/pkg/tool/${GOOS}_${GOARCH}
    11env GOROOT=$WORK/goroot
    12
    13! go tool -n dist
    14stderr 'go: no such tool "dist"'
    15
    16go tool dist list
    17stdout linux/amd64
    18cp stdout tool.txt
    19
    20go tool dist list -v
    21stdout linux/amd64
    22cp stdout tool-v.txt
    23
    24go tool dist list -broken
    25stdout $GOOS/$GOARCH
    26cp stdout tool-broken.txt
    27
    28go tool dist list -json
    29stdout '"GOOS": "linux",\n\s*"GOARCH": "amd64",\n'
    30cp stdout tool-json.txt
    31
    32go tool dist list -json -broken
    33stdout '"GOOS": "'$GOOS'",\n\s*"GOARCH": "'$GOARCH'",\n'
    34cp stdout tool-json-broken.txt
    35
    36[short] stop
    37
    38
    39# Check against the real cmd/dist as the source of truth.
    40
    41env GOROOT=$TESTGO_GOROOT
    42go build -o dist.exe cmd/dist
    43
    44exec ./dist.exe list
    45cmp stdout tool.txt
    46
    47exec ./dist.exe list -v
    48cmp stdout tool-v.txt
    49
    50exec ./dist.exe list -broken
    51cmp stdout tool-broken.txt
    52
    53exec ./dist.exe list -json
    54cmp stdout tool-json.txt
    55
    56exec ./dist.exe list -json -broken
    57cmp stdout tool-json-broken.txt

View as plain text