aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_e.txt
blob: 3a0d18dabc2c94ab57010a316ac6812601139d9a (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
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: 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 '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 succeeds and updates go.mod.

cp go.mod.orig go.mod
go mod vendor -e
stderr -count=3 'cannot find module providing package'
cmp go.mod.final go.mod
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"