...

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

Documentation: cmd/go/testdata/script

     1# This test only checks that basic network lookups work.
     2# The full test of toolchain version selection is in gotoolchain.txt.
     3
     4# This test is sensitive to "new" Go experiments, so
     5# update the environment to remove any existing GOEXPERIMENT
     6# setting, see #62016 for more on this. 
     7env GOEXPERIMENT=''
     8
     9env TESTGO_VERSION=go1.21actual
    10
    11# GOTOOLCHAIN from network, does not exist
    12env GOTOOLCHAIN=go1.9999x
    13! go version
    14stderr 'go: download go1.9999x for .*: toolchain not available'
    15
    16# GOTOOLCHAIN from network
    17[!exec:/bin/sh] stop 'the fake proxy serves shell scripts instead of binaries'
    18env GOTOOLCHAIN=go1.999testmod
    19go version
    20stderr 'go: downloading go1.999testmod \(.*/.*\)'
    21
    22# GOTOOLCHAIN cached from network
    23go version
    24! stderr downloading
    25stdout go1.999testmod
    26
    27# GOTOOLCHAIN with GOSUMDB enabled but at a bad URL should operate in cache and not try badurl
    28env oldsumdb=$GOSUMDB
    29env GOSUMDB=$oldsumdb' http://badurl'
    30go version
    31! stderr downloading
    32stdout go1.999testmod
    33
    34# GOTOOLCHAIN with GOSUMB=off should fail, because it cannot access even the cached sumdb info
    35# without the sumdb name.
    36env GOSUMDB=off
    37! go version
    38stderr '^go: golang.org/toolchain@v0.0.1-go1.999testmod.[a-z0-9\-]*: verifying module: checksum database disabled by GOSUMDB=off$'
    39
    40# GOTOOLCHAIN with GOSUMDB enabled but at a bad URL should fail if cache is incomplete
    41env GOSUMDB=$oldsumdb' http://badurl'
    42rm $GOPATH/pkg/mod/cache/download/sumdb
    43! go version
    44! stderr downloading
    45stderr 'panic: use of network' # test catches network access
    46env GOSUMDB=$oldsumdb
    47
    48# Test a real GOTOOLCHAIN
    49[short] skip
    50[!net:golang.org] skip
    51[!net:sum.golang.org] skip
    52[!GOOS:darwin] [!GOOS:windows] [!GOOS:linux] skip
    53[!GOARCH:amd64] [!GOARCH:arm64] skip
    54
    55env GOPROXY=
    56[go-builder] env GOSUMDB=
    57[!go-builder] env GOSUMDB=sum.golang.org  # Set explicitly in case GOROOT/go.env is modified.
    58env GOTOOLCHAIN=go1.20.1
    59
    60	# Avoid resolving a "go1.20.1" from the user's real $PATH.
    61	# That would not only cause the "downloading go1.20.1" message
    62	# to be suppressed, but may spuriously fail:
    63	# golang.org/dl/go1.20.1 expects to find its GOROOT in $HOME/sdk,
    64	# but the script environment sets HOME=/no-home.
    65env PATH=
    66env path=
    67
    68go version
    69stderr '^go: downloading go1.20.1 '
    70stdout go1.20.1

View as plain text