Text file
src/cmd/go/testdata/script/mod_get_update_unrelated_sum.txt
1 # Check that 'go get' adds sums for updated modules if we had sums before,
2 # even if we didn't load packages from them.
3 # Verifies #44129.
4
5 env fmt='{{.ImportPath}}: {{if .Error}}{{.Error.Err}}{{else}}ok{{end}}'
6
7 # Control case: before upgrading, we have the sums we need.
8 # go list -deps -e -f $fmt .
9 # stdout '^rsc.io/quote: ok$'
10 # ! stdout rsc.io/sampler # not imported by quote in this version
11 cp go.mod.orig go.mod
12 cp go.sum.orig go.sum
13 go mod tidy
14 cmp go.mod.orig go.mod
15 cmp go.sum.orig go.sum
16
17
18 # Upgrade a module. This also upgrades rsc.io/quote, and though we didn't load
19 # a package from it, we had the sum for its old version, so we need the
20 # sum for the new version, too.
21 go get example.com/upgrade@v0.0.2
22 grep '^rsc.io/quote v1.5.2 ' go.sum
23
24 # The upgrade still breaks the build because the new version of quote imports
25 # rsc.io/sampler, and we don't have its zip sum.
26 go list -deps -e -f $fmt
27 stdout 'rsc.io/quote: ok'
28 stdout 'rsc.io/sampler: missing go.sum entry for module providing package rsc.io/sampler'
29 cp go.mod.orig go.mod
30 cp go.sum.orig go.sum
31
32
33 # Replace the old version with a directory before upgrading.
34 # We didn't need a sum for it before (even though we had one), so we won't
35 # fetch a new sum.
36 go mod edit -replace rsc.io/quote@v1.0.0=./dummy
37 go get example.com/upgrade@v0.0.2
38 ! grep '^rsc.io/quote v1.5.2 ' go.sum
39 cp go.mod.orig go.mod
40 cp go.sum.orig go.sum
41
42
43 # Replace the new version with a directory before upgrading.
44 # We can't get a sum for a directory.
45 go mod edit -replace rsc.io/quote@v1.5.2=./dummy
46 go get example.com/upgrade@v0.0.2
47 ! grep '^rsc.io/quote v1.5.2 ' go.sum
48 cp go.mod.orig go.mod
49 cp go.sum.orig go.sum
50
51
52 # Replace the new version with a different version.
53 # We should get a sum for that version.
54 go mod edit -replace rsc.io/quote@v1.5.2=rsc.io/quote@v1.5.1
55 go get example.com/upgrade@v0.0.2
56 ! grep '^rsc.io/quote v1.5.2 ' go.sum
57 grep '^rsc.io/quote v1.5.1 ' go.sum
58 cp go.mod.orig go.mod
59 cp go.sum.orig go.sum
60
61
62 # Delete the new version's zip (but not mod) from the cache and go offline.
63 # 'go get' should fail when fetching the zip.
64 rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
65 env GOPROXY=off
66 ! go get example.com/upgrade@v0.0.2
67 stderr '^go: upgraded rsc.io/quote v1.0.0 => v1.5.2: error finding sum for rsc.io/quote@v1.5.2: module lookup disabled by GOPROXY=off$'
68
69 -- go.mod.orig --
70 module m
71
72 go 1.16
73
74 require (
75 example.com/upgrade v0.0.1
76 rsc.io/quote v1.0.0
77 )
78
79 replace (
80 example.com/upgrade v0.0.1 => ./upgrade1
81 example.com/upgrade v0.0.2 => ./upgrade2
82 )
83 -- go.sum.orig --
84 rsc.io/quote v1.0.0 h1:kQ3IZQzPTiDJxSZI98YaWgxFEhlNdYASHvh+MplbViw=
85 rsc.io/quote v1.0.0/go.mod h1:v83Ri/njykPcgJltBc/gEkJTmjTsNgtO1Y7vyIK1CQA=
86 -- go.sum.want --
87 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
88 rsc.io/quote v1.0.0 h1:kQ3IZQzPTiDJxSZI98YaWgxFEhlNdYASHvh+MplbViw=
89 rsc.io/quote v1.0.0/go.mod h1:v83Ri/njykPcgJltBc/gEkJTmjTsNgtO1Y7vyIK1CQA=
90 rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0=
91 rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
92 rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
93 -- use.go --
94 package use
95
96 import (
97 _ "example.com/upgrade"
98 _ "rsc.io/quote"
99 )
100 -- upgrade1/go.mod --
101 module example.com/upgrade
102
103 go 1.16
104 -- upgrade1/upgrade.go --
105 package upgrade
106 -- upgrade2/go.mod --
107 module example.com/upgrade
108
109 go 1.16
110
111 require rsc.io/quote v1.5.2 // indirect
112 -- upgrade2/upgrade.go --
113 package upgrade
114 -- dummy/go.mod --
115 module rsc.io/quote
116
117 go 1.16
118 -- dummy/quote.go --
119 package quote
120
121
View as plain text