aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_tidy_compat_irrelevant.txt
blob: 7c22fca6c0f4d15b0e27f1c0f11706efe7b11398 (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
# https://golang.org/issue/46141: 'go mod tidy' for a Go 1.17 module should by
# default preserve enough checksums for the module to be used by Go 1.16.
#
# We don't have a copy of Go 1.16 handy, but we can simulate it by editing the
# 'go' version in the go.mod file to 1.16, without actually updating the
# requirements to match.

[short] skip

env MODFMT='{{with .Module}}{{.Path}} {{.Version}}{{end}}'


# This module selects the same versions in Go 1.16 and 1.17 for all modules
# that provide packages (or test dependencies of packages) imported by the
# main module. However, in Go 1.16 it selects a higher version of a
# transitive module dependency that is not otherwise relevant to the main module.
# As a result, Go 1.16 needs an additional checksum for the go.mod file of
# that irrelevant dependency.
#
# The Go 1.16 module graph looks like:
#
# m ---- lazy v0.1.0 ---- incompatible v1.0.0
#         |
#         + ------------- requireincompatible v0.1.0 ---- incompatible v2.0.0+incompatible

cp go.mod go.mod.orig
go mod tidy
cmp go.mod go.mod.orig

go list -deps -test -f $MODFMT all
cp stdout out-117.txt

go mod edit -go=1.16
go list -deps -test -f $MODFMT all
cmp stdout out-117.txt


# If we explicitly drop compatibility with 1.16, we retain fewer checksums,
# which gives a cleaner go.sum file but causes 1.16 to fail in readonly mode.

cp go.mod.orig go.mod
go mod tidy -compat=1.17
cmp go.mod go.mod.orig

go list -deps -test -f $MODFMT all
cmp stdout out-117.txt

go mod edit -go=1.16
! go list -deps -test -f $MODFMT all
	# TODO(#46160): -count=1 instead of -count=2.
stderr -count=2 '^go: example.net/lazy@v0.1.0 requires\n\texample.com/retract/incompatible@v1.0.0: missing go.sum entry; to add it:\n\tgo mod download example.com/retract/incompatible$'


-- go.mod --
// Module m imports packages from the same versions under Go 1.17
// as under Go 1.16, but under 1.16 its (implicit) external test dependencies
// are higher.
module example.com/m

go 1.17

replace (
	example.net/lazy v0.1.0 => ./lazy
	example.net/requireincompatible v0.1.0 => ./requireincompatible
)

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

import _ "example.net/lazy"
-- lazy/go.mod --
// Module lazy requires example.com/retract/incompatible v1.0.0.
//
// When viewed from the outside it also has a transitive dependency
// on v2.0.0+incompatible, but in lazy mode that transitive dependency
// is pruned out.
module example.net/lazy

go 1.17

exclude example.com/retract/incompatible v2.0.0+incompatible

require (
	example.com/retract/incompatible v1.0.0
	example.net/requireincompatible v0.1.0
)
-- lazy/lazy.go --
package lazy
-- lazy/unimported/unimported.go --
package unimported

import _ "example.com/retract/incompatible"
-- requireincompatible/go.mod --
module example.net/requireincompatible

go 1.15

require example.com/retract/incompatible v2.0.0+incompatible