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