aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_sum_issue56222.txt
blob: 841553941e32a5acd144b6bfca63f05490609262 (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
# Regression test for #56222: 'go get -t' and 'go mod tidy'
# should save enough checksums to run 'go test' on the named
# packages or any package in "all" respectively.

# At go 1.19 or earlier, 'go mod tidy' should preserve the historical go.sum
# contents, but 'go test' should flag the missing checksums (instead of trying
# to build the test dependency with the wrong language version).

cd m1
go mod tidy
! go test -o $devnull -c example.com/m2/q
stderr '^# example.com/m2/q\n'..${/}m2${/}q${/}'q_test.go:3:8: example.com/generics@v1.0.0: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/generics$'

go mod download -json example.com/generics
go list -f '{{if eq .ImportPath "example.com/generics"}}{{.Module.GoVersion}}{{end}}' -deps -test example.com/m2/q
stdout 1.18


# Even at go 1.19 or earlier, 'go mod tidy' shouldn't need go.mod files or
# checksums that it won't record.

go mod tidy -go=1.19
go clean -modcache  # Remove checksums from the module cache, so that only go.sum is used.

env OLDSUMDB=$GOSUMDB
env GOSUMDB=bad
go mod tidy

env GOSUMDB=$OLDSUMDB


# Regardless of the go version in go.mod, 'go get -t' should fetch
# enough checksums to run 'go test' on the named package.

rm p
go mod tidy -go=1.19
go list -m all
! stdout example.com/generics
go get -t example.com/m2/q@v1.0.0
go list -f '{{if eq .ImportPath "example.com/generics"}}{{.Module.GoVersion}}{{end}}' -deps -test example.com/m2/q
stdout 1.18
[!short] go test -o $devnull -c example.com/m2/q


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

go 1.19

require example.com/m2 v1.0.0
replace example.com/m2 => ../m2
-- m1/p/p.go --
package p

import _ "example.com/m2/q"
-- m2/go.mod --
module example.com/m2

go 1.19

require example.com/generics v1.0.0
-- m2/q/q.go --
package q
-- m2/q/q_test.go --
package q

import _ "example.com/generics"