]> Cypherpunks.ru repositories - gostls13.git/blob - src/cmd/go/testdata/script/mod_download_exec_toolchain.txt
e44145775456bb458fcf5729a606dde6288154c0
[gostls13.git] / src / cmd / go / testdata / script / mod_download_exec_toolchain.txt
1 env TESTGO_VERSION=go1.21
2 env TESTGO_VERSION_SWITCH=switch
3
4 # First, test 'go mod download' outside of a module.
5 #
6 # There is no go.mod file into which we can record the selected toolchain,
7 # so unfortunately these version switches won't be as reproducible as other
8 # go commands, but that's still preferable to failing entirely or downloading
9 # a module zip that we don't understand.
10
11 # GOTOOLCHAIN=auto should run the newer toolchain
12 env GOTOOLCHAIN=auto
13 go mod download rsc.io/needgo121@latest rsc.io/needgo122@latest rsc.io/needgo123@latest rsc.io/needall@latest
14 stderr '^go: rsc.io/needall@v0.0.1 requires go >= 1.23; switching to go1.23.9$'
15 ! stderr '\(running'
16
17 # GOTOOLCHAIN=min+auto should run the newer toolchain
18 env GOTOOLCHAIN=go1.21+auto
19 go mod download rsc.io/needgo121@latest rsc.io/needgo122@latest rsc.io/needgo123@latest rsc.io/needall@latest
20 stderr '^go: rsc.io/needall@v0.0.1 requires go >= 1.23; switching to go1.23.9$'
21 ! stderr '\(running'
22
23 # GOTOOLCHAIN=go1.21 should NOT run the newer toolchain
24 env GOTOOLCHAIN=go1.21
25 ! go mod download rsc.io/needgo121@latest rsc.io/needgo122@latest rsc.io/needgo123@latest rsc.io/needall@latest
26 ! stderr switching
27 stderr 'rsc.io/needgo122@v0.0.1 requires go >= 1.22'
28 stderr 'rsc.io/needgo123@v0.0.1 requires go >= 1.23'
29 stderr 'rsc.io/needall@v0.0.1 requires go >= 1.23'
30 stderr 'requires go >= 1.23'
31 ! stderr 'requires go >= 1.21' # that's us!
32
33
34 # JSON output should be emitted exactly once,
35 # and non-JSON output should go to stderr instead of stdout.
36 env GOTOOLCHAIN=auto
37 go mod download -json rsc.io/needgo121@latest rsc.io/needgo122@latest rsc.io/needgo123@latest rsc.io/needall@latest
38 stderr '^go: rsc.io/needall@v0.0.1 requires go >= 1.23; switching to go1.23.9$'
39 ! stderr '\(running'
40 stdout -count=1 '"Path": "rsc.io/needgo121",'
41 stdout -count=1 '"Path": "rsc.io/needgo122",'
42 stdout -count=1 '"Path": "rsc.io/needgo123",'
43 stdout -count=1 '"Path": "rsc.io/needall",'
44
45 # GOTOOLCHAIN=go1.21 should write the errors in the JSON Error fields, not to stderr.
46 env GOTOOLCHAIN=go1.21
47 ! go mod download -json rsc.io/needgo121@latest rsc.io/needgo122@latest rsc.io/needgo123@latest rsc.io/needall@latest
48 ! stderr switching
49 stdout -count=1 '"Error": "rsc.io/needgo122@v0.0.1 requires go .*= 1.22 \(running go 1.21; GOTOOLCHAIN=go1.21\)"'
50 stdout -count=1 '"Error": "rsc.io/needgo123@v0.0.1 requires go .*= 1.23 \(running go 1.21; GOTOOLCHAIN=go1.21\)"'
51 stdout -count=1 '"Error": "rsc.io/needall@v0.0.1 requires go .*= 1.23 \(running go 1.21; GOTOOLCHAIN=go1.21\)"'
52 ! stdout '"Error": "rsc.io/needgo121'  # We can handle this one.
53 ! stderr .
54
55
56 # Within a module, 'go mod download' of explicit versions should upgrade if
57 # needed to perform the download, but should not change the main module's
58 # toolchain version (because the downloaded modules are still not required by
59 # the main module).
60
61 cd example
62 cp go.mod go.mod.orig
63
64 env GOTOOLCHAIN=auto
65 go mod download rsc.io/needgo121@latest rsc.io/needgo122@latest rsc.io/needgo123@latest rsc.io/needall@latest
66 stderr '^go: rsc.io/needall@v0.0.1 requires go >= 1.23; switching to go1.23.9$'
67 ! stderr '\(running'
68 cmp go.mod go.mod.orig
69
70
71 # However, 'go mod download' without arguments should fix up the
72 # 'go' and 'toolchain' lines to be consistent with the existing
73 # requirements in the module graph.
74
75 go mod edit -require=rsc.io/needall@v0.0.1
76 cp go.mod go.mod.121
77
78 # If an upgrade is needed, GOTOOLCHAIN=go1.21 should cause
79 # the command to fail without changing go.mod.
80
81 env GOTOOLCHAIN=go1.21
82 ! go mod download
83 stderr 'rsc.io/needall@v0.0.1 requires go >= 1.23'
84 ! stderr switching
85 cmp go.mod go.mod.121
86
87 # If an upgrade is needed, GOTOOLCHAIN=auto should perform
88 # the upgrade and record the resulting toolchain version.
89
90 env GOTOOLCHAIN=go1.21
91 ! go mod download
92 stderr 'rsc.io/needall@v0.0.1 requires go >= 1.23'
93 ! stderr switching
94 cmp go.mod go.mod.final
95
96
97 -- example/go.mod --
98 module example
99
100 go 1.21
101 -- example/go.mod.final --
102 module example
103
104 go 1.21
105
106 require rsc.io/needall v0.0.1