summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/testdata/script/mod_e.txt
blob: 3cffaf6ef1c1cf1bdc6bda4bc1ac6ae79966be00 (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
cp go.mod go.mod.orig


# If a dependency cannot be resolved, 'go mod tidy' fails with an error message
# explaining the problem and does not update the go.mod file.
# TODO(bcmills): Ideally, with less redundancy than these error messages!

! go mod tidy

stderr '^example.com/untidy imports\n\texample.net/directnotfound: cannot find module providing package example.net/directnotfound: module example.net/directnotfound: reading http://.*: 404 Not Found$'

stderr '^example.com/untidy imports\n\texample.net/m imports\n\texample.net/indirectnotfound: cannot find module providing package example.net/indirectnotfound: module example.net/indirectnotfound: reading http://.*: 404 Not Found$'

stderr '^example.com/untidy tested by\n\texample.com/untidy.test imports\n\texample.net/directtestnotfound: cannot find module providing package example.net/directtestnotfound: module example.net/directtestnotfound: reading http://.*: 404 Not Found$'

stderr '^example.com/untidy imports\n\texample.net/m tested by\n\texample.net/m.test imports\n\texample.net/indirecttestnotfound: cannot find module providing package example.net/indirecttestnotfound: module example.net/indirecttestnotfound: reading http://.*: 404 Not Found$'

cmp go.mod.orig go.mod


# If a dependency cannot be resolved, 'go mod vendor' fails with an error message
# explaining the problem, does not update the go.mod file, and does not create
# the vendor directory.

! go mod vendor

stderr '^example.com/untidy imports\n\texample.net/directnotfound: no required module provides package example.net/directnotfound; to add it:\n\tgo get example.net/directnotfound$'

stderr '^example.com/untidy imports\n\texample.net/m: module example.net/m provides package example.net/m and is replaced but not required; to add it:\n\tgo get example.net/m@v0.1.0$'

stderr '^example.com/untidy tested by\n\texample.com/untidy.test imports\n\texample.net/directtestnotfound: no required module provides package example.net/directtestnotfound; to add it:\n\tgo get example.net/directtestnotfound$'

! stderr 'indirecttestnotfound'  # Vendor prunes test dependencies.

cmp go.mod.orig go.mod
! exists vendor


# 'go mod tidy' still logs the errors, but succeeds and updates go.mod.

go mod tidy -e
stderr -count=4 'cannot find module providing package'
cmp go.mod.final go.mod


# 'go mod vendor -e' still logs the errors, but creates a vendor directory
# and exits with status 0.
# 'go mod vendor -e' does not update go.mod and will not vendor packages that
# would require changing go.mod, for example, by adding a requirement.
cp go.mod.orig go.mod
go mod vendor -e
stderr -count=2 'no required module provides package'
stderr '^example.com/untidy imports\n\texample.net/m: module example.net/m provides package example.net/m and is replaced but not required; to add it:\n\tgo get example.net/m@v0.1.0$'
exists vendor/modules.txt
! exists vendor/example.net

go mod edit -require example.net/m@v0.1.0
go mod vendor -e
stderr -count=3 'no required module provides package'
exists vendor/modules.txt
exists vendor/example.net/m/m.go

-- go.mod --
module example.com/untidy
go 1.16
replace example.net/m v0.1.0 => ./m
-- go.mod.final --
module example.com/untidy

go 1.16

replace example.net/m v0.1.0 => ./m

require example.net/m v0.1.0
-- untidy.go --
package untidy

import (
	_ "example.net/m"
	_ "example.net/directnotfound"
)
-- untidy_test.go --
package untidy_test

import _ "example.net/directtestnotfound"
-- m/go.mod --
module example.net/m
go 1.16
-- m/m.go --
package m

import _ "example.net/indirectnotfound"
-- m/m_test.go --
package m_test

import _ "example.net/indirecttestnotfound"