aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_require_exclude.txt
blob: 9156d4ce5d5fdfb47c93071a79ec09e8ef7dde35 (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
# build with no newer version to satisfy exclude
env GO111MODULE=on
cp go.mod go.mod.orig

# With the selected version excluded, commands that query that version without
# updating go.mod should fail.

! go list -mod=readonly -m all
stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$'
stderr '^go: updates to go.mod needed, disabled by -mod=readonly$'
! stdout '^rsc.io/sampler v1.99.99'
cmp go.mod go.mod.orig

! go list -mod=vendor -m rsc.io/sampler
stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$'
stderr '^go list -m: module rsc.io/sampler: can''t resolve module using the vendor directory\n\t\(Use -mod=mod or -mod=readonly to bypass\.\)$'
! stdout '^rsc.io/sampler v1.99.99'
cmp go.mod go.mod.orig

# With the selected version excluded, commands that load only modules should
# drop the excluded module.

go list -m -mod=mod all
stderr '^go: dropping requirement on excluded version rsc.io/sampler v1\.99\.99$'
stdout '^x$'
! stdout '^rsc.io/sampler'
cmp go.mod go.moddrop

# With the latest version excluded, 'go list' should resolve needed packages
# from the next-highest version.

cp go.mod.orig go.mod
go list -mod=mod -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all
stderr '^go: dropping requirement on excluded version rsc.io/sampler v1\.99\.99$'
stdout '^x $'
! stdout '^rsc.io/sampler v1.99.99'
stdout '^rsc.io/sampler v1.3.0'

# build with newer version available
cp go.mod2 go.mod
go list -mod=mod -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all
stderr '^go: dropping requirement on excluded version rsc.io/quote v1\.5\.1$'
stdout 'rsc.io/quote v1.5.2'

# build with excluded newer version
cp go.mod3 go.mod
go list -mod=mod -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all
! stderr '^go: dropping requirement'
stdout 'rsc.io/quote v1.5.1'

-- x.go --
package x
import _ "rsc.io/quote"

-- go.mod --
module x

go 1.13

exclude rsc.io/sampler v1.99.99
require rsc.io/sampler v1.99.99
-- go.moddrop --
module x

go 1.13

exclude rsc.io/sampler v1.99.99
-- go.mod2 --
module x

go 1.13

exclude rsc.io/quote v1.5.1
require rsc.io/quote v1.5.1
-- go.mod3 --
module x

go 1.13

exclude rsc.io/quote v1.5.2
require rsc.io/quote v1.5.1