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

     1  # Test the GODEBUG=toolchaintrace behavior
     2  # See https://go.dev/issue/63939
     3  env GODEBUG=toolchaintrace=1
     4  env TESTGO_VERSION=go1.21.0
     5  env TESTGO_VERSION_SWITCH=switch
     6  env GOTOOLCHAIN=auto
     7  
     8  # Go line is newer than local go version.
     9  go mod init m
    10  go mod edit -go=1.21.1
    11  go version
    12  stderr -count=1 'go: upgrading toolchain to go1.21.1 \(required by go line in go.mod; upgrade allowed by GOTOOLCHAIN=auto\)'
    13  stderr -count=1 'go: using go1.21.1 toolchain from cache located at .*'
    14  stdout 'go version go1.21.1'
    15  rm go.mod
    16  
    17  # Toolchain line is newer than go line.
    18  go mod init m
    19  go mod edit -go=1.21.1 -toolchain=go1.21.2
    20  go version
    21  stderr -count=1 'go: upgrading toolchain to go1.21.2 \(required by toolchain line in go.mod; upgrade allowed by GOTOOLCHAIN=auto\)'
    22  stderr -count=1 'go: using go1.21.2 toolchain from cache located at .*'
    23  stdout 'go version go1.21.2'
    24  rm go.mod
    25  
    26  # Go line is newer than local go version and toolchain line.
    27  go mod init m
    28  go mod edit -go=1.22 -toolchain=go1.21.2
    29  go version
    30  stderr -count=1 'go: upgrading toolchain to go1.21.2 \(required by toolchain line in go.mod; upgrade allowed by GOTOOLCHAIN=auto\)'
    31  stderr -count=1 'go: upgrading toolchain to go1.22.0 \(required by go line in go.mod; upgrade allowed by GOTOOLCHAIN=auto\)'
    32  stderr -count=1 'go: using go1.22.0 toolchain from cache located at .*'
    33  stdout 'go version go1.22.0'
    34  rm go.mod
    35  
    36  # No switch.
    37  go mod init m
    38  go mod edit -go=1.21.0 -toolchain=go1.21.0
    39  go version
    40  stderr -count=1 'go: using local toolchain go1.21.0'
    41  ! stderr 'go: upgrading toolchain'
    42  stdout 'go version go1.21.0'
    43  rm go.mod
    44  
    45  # GOTOOLCHAIN+auto is older than go line and toolchain line.
    46  go mod init m
    47  go mod edit -go=1.22 -toolchain=go1.21.2
    48  env GOTOOLCHAIN=go1.21.0+auto
    49  go version
    50  stderr -count=1 'go: default toolchain set to go1.21.0 from GOTOOLCHAIN=go1.21.0\+auto'
    51  stderr -count=1 'go: upgrading toolchain to go1.21.2 \(required by toolchain line in go.mod; upgrade allowed by GOTOOLCHAIN=<name>\+auto\)'
    52  stderr -count=1 'go: upgrading toolchain to go1.22.0 \(required by go line in go.mod; upgrade allowed by GOTOOLCHAIN=<name>\+auto\)'
    53  stderr -count=1 'go: using go1.22.0 toolchain from cache located at .*'
    54  stdout 'go version go1.22.0'
    55  rm go.mod
    56  
    57  # GOTOOLCHAIN is older than go line and toolchain line.
    58  go mod init m
    59  go mod edit -go=1.22 -toolchain=go1.21.2
    60  env GOTOOLCHAIN=go1.21.1
    61  go version
    62  stderr -count=1 'go: default toolchain set to go1.21.1 from GOTOOLCHAIN=go1.21.1'
    63  stderr -count=1 'go: using go1.21.1 toolchain from cache located at .*'
    64  ! stderr 'go: upgrading toolchain'
    65  stdout 'go version go1.21.1'
    66  rm go.mod
    67  env GOTOOLCHAIN=auto
    68  
    69  # GOTOOLCHAIN+auto is newer than go line and toolchain line.
    70  go mod init m
    71  go mod edit -go=1.21.1 -toolchain=go1.21.2
    72  env GOTOOLCHAIN=go1.22.0+auto
    73  go version
    74  stderr -count=1 'go: default toolchain set to go1.22.0 from GOTOOLCHAIN=go1.22.0\+auto'
    75  stderr -count=1 'go: using go1.22.0 toolchain from cache located at .*'
    76  stdout 'go version go1.22.0'
    77  rm go.mod
    78  
    79  # GOTOOLCHAIN=local
    80  env GOTOOLCHAIN=local
    81  go mod init m
    82  go mod edit -go=1.21.1 -toolchain=go1.21.2
    83  go version
    84  stderr -count=1 'go: default toolchain set to go1.21.0 from GOTOOLCHAIN=local'
    85  stderr -count=1 'go: using local toolchain go1.21.0'
    86  stdout 'go version go1.21.0'
    87  rm go.mod
    88  
    89  [short] stop 'requires build'
    90  # If toolchain found in PATH, ensure we print that.
    91  env GOTOOLCHAIN=auto
    92  env TESTGO_VERSION_SWITCH=
    93  mkdir $WORK/bin
    94  go build -o $WORK/bin/go1.22.0$GOEXE ./fake/fakego.go  # adds .exe extension implicitly on Windows
    95  [!GOOS:plan9] env PATH=$WORK/bin
    96  [GOOS:plan9] env path=$WORK/bin
    97  go mod init m
    98  go mod edit -go=1.22.0
    99  ! go version
   100  stderr -count=1 'go: upgrading toolchain to go1.22.0 \(required by go line in go.mod; upgrade allowed by GOTOOLCHAIN=auto\)'
   101  stderr -count=1 'go: using go1.22.0 toolchain located in system PATH \('$WORK'[/\\]bin[/\\]go1.22.0'$GOEXE'\)'
   102  stderr 'running go1.22.0 from PATH'
   103  rm go.mod
   104  
   105  
   106  -- fake/fakego.go --
   107  package main
   108  
   109  import (
   110  	"fmt"
   111  	"os"
   112  	"path/filepath"
   113  	"strings"
   114  )
   115  
   116  func main() {
   117  	exe, _ := os.Executable()
   118  	name := filepath.Base(exe)
   119  	name = strings.TrimSuffix(name, ".exe")
   120  	fmt.Fprintf(os.Stderr, "running %s from PATH\n", name)
   121  	os.Exit(1) // fail in case we are running this accidentally (like in "go mod edit")
   122  }
   123  

View as plain text