summaryrefslogtreecommitdiff
path: root/libgo/go/cmd/go/testdata/script/mod_tidy_replace.txt
blob: d5c22530944df3fd90337c4914b3d131eb3acd63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
env GO111MODULE=on
[short] skip

# golang.org/issue/30166: 'go mod tidy' should not crash if a replaced module is
# involved in a cycle.
cd cycle
env GOTRACEBACK=off
go mod tidy
cd ..

# From inside the module, 'go list -m all' should NOT include transitive
# requirements of modules that have been replaced.
go list -m all
stdout 'rsc.io/quote/v3 v3.0.0'
! stdout 'rsc.io/sampler'
! stdout 'golang.org/x/text'

# From outside the module, 'go list -m all' should include them.
cd outside
go list -m all
stdout 'rsc.io/quote/v3 v3.0.0'
stdout 'rsc.io/sampler v1.3.0'
stdout 'golang.org/x/text'
cd ..

# 'go list all' should add indirect requirements to satisfy the packages
# imported from replacement modules.
! grep 'rsc.io/sampler' go.mod
! grep 'golang.org/x/text' go.mod
go list all
grep 'rsc.io/sampler' go.mod
grep 'golang.org/x/text' go.mod

# 'go get' and 'go mod tidy' should follow the requirements of the replacements,
# not the originals, even if that results in a set of versions that are
# misleading or redundant without those replacements.
go get rsc.io/sampler@v1.2.0
go mod tidy
go list -m all
stdout 'rsc.io/quote/v3 v3.0.0'
stdout 'rsc.io/sampler v1.2.0'
stdout 'golang.org/x/text'

# The requirements seen from outside may be higher (or lower)
# than those seen from within the module.
grep 'rsc.io/sampler v1.2.0' go.mod
cd outside
go list -m all
stdout 'rsc.io/sampler v1.3.0'

-- go.mod --
module example.com/tidy

require rsc.io/quote/v3 v3.0.0
replace rsc.io/quote/v3 => ./not-rsc.io/quote/v3

-- imports.go --
package tidy

import _ "rsc.io/quote/v3"

-- outside/go.mod --
module example.com/tidy/outside

require example.com/tidy v0.0.0
replace example.com/tidy => ./..

-- not-rsc.io/quote/v3/go.mod --
module not-rsc.io/quote/v3

// No requirements specified!

-- not-rsc.io/quote/v3/quote.go --
package quote

import (
	_ "rsc.io/sampler"
	_ "golang.org/x/text/language"
)

-- cycle/go.mod --
module golang.org/issue/30166

require (
	golang.org/issue/30166/a v0.0.0
	golang.org/issue/30166/b v0.0.0
)

replace (
	golang.org/issue/30166/a => ./a
	golang.org/issue/30166/b => ./b
)
-- cycle/cycle.go --
package cycle

import (
	_ "golang.org/issue/30166/a"
	_ "golang.org/issue/30166/b"
)
-- cycle/a/a.go --
package a
-- cycle/a/go.mod --
module golang.org/issue/30166/a

require golang.org/issue/30166/b v0.0.0
-- cycle/b/b.go --
package b
-- cycle/b/go.mod --
module golang.org/issue/30166/b

require golang.org/issue/30166/a v0.0.0