1 # This test illustrates a case where downgrading one module may upgrade another.
2 # Compare to the downcross1 test case in cmd/go/internal/mvs/mvs_test.go.
3
4 # The package import graph used in this test looks like:
5 #
6 # a ---- b
7 # \ \
8 # \ \
9 # ----- c ---- d
10 #
11 # The module dependency graph originally looks like:
12 #
13 # a ---- b.2
14 # \ \
15 # \ \
16 # ----- c.1 ---- d.2
17 #
18 # b.1 ---- c.2
19 #
20 # If we downgrade module d to version 1, we must downgrade b as well.
21 # If that downgrade selects b version 1, we will upgrade module c to version 2.
22 # So 'go get d@1' should instead downgrade both b and c to "none".
23
24 cp go.mod go.mod.orig
25 go mod tidy
26 cmp go.mod.orig go.mod
27
28 go get example.com/d@v0.1.0
29 go list -m all
30 ! stdout '^example.com/b '
31 ! stdout '^example.com/c '
32 stdout '^example.com/d v0.1.0 '
33
34 -- go.mod --
35 module example.com/a
36
37 go 1.15
38
39 require (
40 example.com/b v0.2.0
41 example.com/c v0.1.0
42 )
43
44 replace (
45 example.com/b v0.1.0 => ./b1
46 example.com/b v0.2.0 => ./b2
47 example.com/c v0.1.0 => ./c1
48 example.com/c v0.2.0 => ./c2
49 example.com/d v0.1.0 => ./d
50 example.com/d v0.2.0 => ./d
51 )
52 -- a.go --
53 package a
54
55 import (
56 _ "example.com/b"
57 _ "example.com/c"
58 )
59
60 -- b1/go.mod --
61 module example.com/b
62
63 go 1.15
64
65 require example.com/c v0.2.0
66 -- b1/b.go --
67 package b
68
69 import _ "example.com/c"
70
71 -- b2/go.mod --
72 module example.com/b
73
74 go 1.15
75
76 require example.com/c v0.1.0
77 -- b2/b.go --
78 package b
79
80 import _ "example.com/c"
81
82 -- c1/go.mod --
83 module example.com/c
84
85 go 1.15
86
87 require example.com/d v0.2.0
88 -- c1/c.go --
89 package c
90
91 -- c2/go.mod --
92 module example.com/c
93
94 go 1.15
95 -- c2/c.go --
96 package c
97
98 -- d/go.mod --
99 module example.com/d
100
101 go 1.15
102
View as plain text