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

     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.
     7  env GOEXPERIMENT=''
     8  
     9  env TESTGO_VERSION=go1.21actual
    10  
    11  # GOTOOLCHAIN from network, does not exist
    12  env GOTOOLCHAIN=go1.9999x
    13  ! go version
    14  stderr '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'
    18  env GOTOOLCHAIN=go1.999testmod
    19  go version
    20  stderr 'go: downloading go1.999testmod \(.*/.*\)'
    21  
    22  # GOTOOLCHAIN cached from network
    23  go version
    24  ! stderr downloading
    25  stdout go1.999testmod
    26  
    27  # GOTOOLCHAIN with GOSUMDB enabled but at a bad URL should operate in cache and not try badurl
    28  env oldsumdb=$GOSUMDB
    29  env GOSUMDB=$oldsumdb' http://badurl'
    30  go version
    31  ! stderr downloading
    32  stdout go1.999testmod
    33  
    34  # GOTOOLCHAIN with GOSUMB=off should fail, because it cannot access even the cached sumdb info
    35  # without the sumdb name.
    36  env GOSUMDB=off
    37  ! go version
    38  stderr '^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
    41  env GOSUMDB=$oldsumdb' http://badurl'
    42  rm $GOPATH/pkg/mod/cache/download/sumdb
    43  ! go version
    44  ! stderr downloading
    45  stderr 'panic: use of network' # test catches network access
    46  env 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  
    55  env GOPROXY=
    56  [go-builder] env GOSUMDB=
    57  [!go-builder] env GOSUMDB=sum.golang.org  # Set explicitly in case GOROOT/go.env is modified.
    58  env 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.
    65  env PATH=
    66  env path=
    67  
    68  go version
    69  stderr '^go: downloading go1.20.1 '
    70  stdout go1.20.1
    71  

View as plain text