aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_load_badchain.txt
blob: 67d9a1584f51f8fcabbf62dc83a466bf95ae98db (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
[short] skip
env GO111MODULE=on

# Download everything to avoid "finding" messages in stderr later.
cp go.mod.orig go.mod
go mod download
go mod download example.com@v1.0.0
go mod download example.com/badchain/a@v1.1.0
go mod download example.com/badchain/b@v1.1.0
go mod download example.com/badchain/c@v1.1.0

# Try to update example.com/badchain/a (and its dependencies).
! go get -d example.com/badchain/a
cmp stderr update-a-expected
cmp go.mod go.mod.orig

# Try to update the main module. This updates everything, including
# modules that aren't direct requirements, so the error stack is shorter.
! go get -d -u ./...
cmp stderr update-main-expected
cmp go.mod go.mod.orig

# Update manually. Listing modules should produce an error.
go mod edit -require=example.com/badchain/a@v1.1.0
! go list -m
cmp stderr list-expected

# Try listing a package that imports a package
# in a module without a requirement.
go mod edit -droprequire example.com/badchain/a
! go list m/use
cmp stderr list-missing-expected

! go list -test m/testuse
cmp stderr list-missing-test-expected

-- go.mod.orig --
module m

go 1.13

require example.com/badchain/a v1.0.0
-- use/use.go --
package use

import _ "example.com/badchain/c"
-- testuse/testuse.go --
package testuse
-- testuse/testuse_test.go --
package testuse

import (
	"testing"
	_ "example.com/badchain/c"
)

func Test(t *testing.T) {}
-- update-main-expected --
go: example.com/badchain/c upgrade => v1.1.0
go get: example.com/badchain/c@v1.0.0 updating to
	example.com/badchain/c@v1.1.0: parsing go.mod:
	module declares its path as: badchain.example.com/c
	        but was required as: example.com/badchain/c
-- update-a-expected --
go: example.com/badchain/a upgrade => v1.1.0
go get: example.com/badchain/a@v1.1.0 requires
	example.com/badchain/b@v1.1.0 requires
	example.com/badchain/c@v1.1.0: parsing go.mod:
	module declares its path as: badchain.example.com/c
	        but was required as: example.com/badchain/c
-- list-expected --
go: example.com/badchain/a@v1.1.0 requires
	example.com/badchain/b@v1.1.0 requires
	example.com/badchain/c@v1.1.0: parsing go.mod:
	module declares its path as: badchain.example.com/c
	        but was required as: example.com/badchain/c
-- list-missing-expected --
go: finding module for package example.com/badchain/c
go: found example.com/badchain/c in example.com/badchain/c v1.1.0
go: m/use imports
	example.com/badchain/c: example.com/badchain/c@v1.1.0: parsing go.mod:
	module declares its path as: badchain.example.com/c
	        but was required as: example.com/badchain/c
-- list-missing-test-expected --
go: finding module for package example.com/badchain/c
go: found example.com/badchain/c in example.com/badchain/c v1.1.0
go: m/testuse tested by
	m/testuse.test imports
	example.com/badchain/c: example.com/badchain/c@v1.1.0: parsing go.mod:
	module declares its path as: badchain.example.com/c
	        but was required as: example.com/badchain/c