...

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

Documentation: cmd/go/testdata/script

     1# Create basic modules and work space.
     2env TESTGO_VERSION=go1.50
     3mkdir m1_22_0
     4go mod init -C m1_22_0
     5go mod edit -C m1_22_0 -go=1.22.0 -toolchain=go1.99.0
     6mkdir m1_22_1
     7go mod init -C m1_22_1
     8go mod edit -C m1_22_1 -go=1.22.1 -toolchain=go1.99.1
     9mkdir m1_24_rc0
    10go mod init -C m1_24_rc0
    11go mod edit -C m1_24_rc0 -go=1.24rc0 -toolchain=go1.99.2
    12
    13go work init ./m1_22_0 ./m1_22_1
    14grep '^go 1.50$' go.work
    15! grep toolchain go.work
    16
    17# work sync with older modules should leave go 1.50 in the go.work.
    18go work sync
    19cat go.work
    20grep '^go 1.50$' go.work
    21! grep toolchain go.work
    22
    23# work sync with newer modules should update go 1.21 -> 1.22.1 and toolchain -> go1.22.9 in go.work
    24env TESTGO_VERSION=go1.21
    25env TESTGO_VERSION_SWITCH=switch
    26go work edit -go=1.21
    27grep '^go 1.21$' go.work
    28! grep toolchain go.work
    29env GOTOOLCHAIN=local
    30! go work sync
    31stderr '^go: cannot load module m1_22_0 listed in go.work file: m1_22_0'${/}'go.mod requires go >= 1.22.0 \(running go 1.21; GOTOOLCHAIN=local\)$'
    32stderr '^go: cannot load module m1_22_1 listed in go.work file: m1_22_1'${/}'go.mod requires go >= 1.22.1 \(running go 1.21; GOTOOLCHAIN=local\)$'
    33env GOTOOLCHAIN=auto
    34go work sync
    35stderr '^go: m1_22_1'${/}'go.mod requires go >= 1.22.1; switching to go1.22.9$'
    36grep '^go 1.22.1$' go.work
    37grep '^toolchain go1.22.9$' go.work
    38
    39# work sync with newer modules should update go 1.22.1 -> 1.24rc1 and drop toolchain
    40go work edit -use=./m1_24_rc0
    41go work sync
    42stderr '^go: m1_24_rc0'${/}'go.mod requires go >= 1.24rc0; switching to go1.24rc1$'
    43cat go.work
    44grep '^go 1.24rc0$' go.work
    45grep '^toolchain go1.24rc1$' go.work

View as plain text