aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_lazy_new_import.txt
blob: 02935bf236528b4e56efaefef9dd850a3b9fe074 (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
# This test illustrates the use of a deepening scan to resolve transitive
# imports of imports of new packages from within existing dependencies.

# The package import graph used in this test looks like:
#
# lazy ---- a/x ---- b
#     \
#      ---- a/y ---- c
#
# Where a/x and x/y are disjoint packages, but both contained in module a.
#
# The module dependency graph initially looks like:
#
# lazy ---- a.1 ---- b.1
#              \
#               c.1


cp go.mod go.mod.old
cp lazy.go lazy.go.old
go mod tidy
cmp go.mod go.mod.old

# Before adding a new import, the go.mod file should
# enumerate modules for all packages already imported.
go list all
cmp go.mod go.mod.old

# When we add a new import of a package in an existing dependency,
# and that dependency is already tidy, its transitive dependencies
# should already be present.
cp lazy.go.new lazy.go
go list all
go list -m all
stdout '^example.com/c v0.1.0' # not v0.2.0 as would be be resolved by 'latest'
cmp go.mod go.mod.old

# TODO(#36460):
cp lazy.go.old lazy.go
cp go.mod.old go.mod
go mod edit -go=1.16

# When a new import is found, we should perform a deepening scan of the existing
# dependencies and add a requirement on the version required by those
# dependencies — not re-resolve 'latest'.


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

go 1.15

require example.com/a v0.1.0

replace (
	example.com/a v0.1.0 => ./a
	example.com/b v0.1.0 => ./b
	example.com/c v0.1.0 => ./c1
	example.com/c v0.2.0 => ./c2
)
-- lazy.go --
package lazy

import (
	_ "example.com/a/x"
)
-- lazy.go.new --
package lazy

import (
	_ "example.com/a/x"
	_ "example.com/a/y"
)
-- a/go.mod --
module example.com/a

go 1.15

require (
	example.com/b v0.1.0
	example.com/c v0.1.0
)
-- a/x/x.go --
package x
import _ "example.com/b"
-- a/y/y.go --
package y
import _ "example.com/c"
-- b/go.mod --
module example.com/b

go 1.15
-- b/b.go --
package b
-- c1/go.mod --
module example.com/c

go 1.15
-- c1/c.go --
package c
-- c2/go.mod --
module example.com/c

go 1.15
-- c2/c.go --
package c
This file should not be used, so this syntax error should be ignored.