...
1# Regression test for https://golang.org/issue/47979:
2#
3# An argument to 'go get' that results in an upgrade to a different existing
4# root should be allowed, and should not panic the 'go' command.
5
6cp go.mod go.mod.orig
7
8
9# Transitive upgrades from upgraded roots should not prevent
10# 'go get -u' from performing upgrades.
11
12cp go.mod.orig go.mod
13go get -u .
14cmp go.mod go.mod.want
15
16
17# 'go get' of a specific version should allow upgrades of
18# every dependency (transitively) required by that version,
19# including dependencies that are pulled into the module
20# graph by upgrading other root requirements
21# (in this case, example.net/indirect).
22
23cp go.mod.orig go.mod
24go get example.net/a@v0.2.0
25cmp go.mod go.mod.want
26
27
28-- go.mod --
29module golang.org/issue47979
30
31go 1.17
32
33replace (
34 example.net/a v0.1.0 => ./a1
35 example.net/a v0.2.0 => ./a2
36 example.net/indirect v0.1.0 => ./indirect1
37 example.net/indirect v0.2.0 => ./indirect2
38 example.net/other v0.1.0 => ./other
39 example.net/other v0.2.0 => ./other
40)
41
42require (
43 example.net/a v0.1.0
44 example.net/other v0.1.0
45)
46
47require example.net/indirect v0.1.0 // indirect
48-- go.mod.want --
49module golang.org/issue47979
50
51go 1.17
52
53replace (
54 example.net/a v0.1.0 => ./a1
55 example.net/a v0.2.0 => ./a2
56 example.net/indirect v0.1.0 => ./indirect1
57 example.net/indirect v0.2.0 => ./indirect2
58 example.net/other v0.1.0 => ./other
59 example.net/other v0.2.0 => ./other
60)
61
62require (
63 example.net/a v0.2.0
64 example.net/other v0.2.0
65)
66
67require example.net/indirect v0.2.0 // indirect
68-- issue.go --
69package issue
70
71import _ "example.net/a"
72-- useother/useother.go --
73package useother
74
75import _ "example.net/other"
76-- a1/go.mod --
77module example.net/a
78
79go 1.17
80
81require example.net/indirect v0.1.0
82-- a1/a.go --
83package a
84-- a2/go.mod --
85module example.net/a
86
87go 1.17
88
89require example.net/indirect v0.2.0
90-- a2/a.go --
91package a
92
93import "example.net/indirect"
94-- indirect1/go.mod --
95module example.net/indirect
96
97go 1.17
98
99require example.net/other v0.1.0
100-- indirect1/indirect.go --
101package indirect
102-- indirect2/go.mod --
103module example.net/indirect
104
105go 1.17
106
107require example.net/other v0.2.0
108-- indirect2/indirect.go --
109package indirect
110
111import "example.net/other"
112-- other/go.mod --
113module example.net/other
114
115go 1.17
116-- other/other.go --
117package other
View as plain text