Skip to content

Commit 29f3469

Browse files
Bryan C. Millsmknyszek
Bryan C. Mills
authored andcommitted
[release-branch.go1.19] cmd/go: save checksums for go.mod files needed for go version lines
When we load a package from a module, we need the go version line from that module's go.mod file to know what language semantics to use for the package. We need to save a checksum for the go.mod file even if the module's requirements are pruned out of the module graph. Previously, we were missing checksums for test dependencies of packages in 'all' and packages passed to 'go get -t'. This change preserves the existing bug for 'go mod tidy', but fixes it for 'go get -t' and flags the missing checksum with a clearer error in other cases. Fixes #60000. Updates #56222. Change-Id: Icd6acce348907621ae0b02dbeac04fb180353dcf (cherry picked from CL 489075 and CL 492741) Reviewed-on: https://go-review.googlesource.com/c/go/+/492983 Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com>
1 parent 65cc8e6 commit 29f3469

17 files changed

+162
-27
lines changed

src/cmd/go/internal/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ func runList(ctx context.Context, cmd *base.Command, args []string) {
643643
} else {
644644
pmain, ptest, pxtest, err = load.TestPackagesFor(ctx, pkgOpts, p, nil)
645645
if err != nil {
646-
base.Errorf("can't load test package: %s", err)
646+
base.Errorf("go: can't load test package: %s", err)
647647
}
648648
}
649649
if pmain != nil {

src/cmd/go/internal/modload/import.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,13 @@ func (e *invalidImportError) Unwrap() error {
248248
// If the package is present in exactly one module, importFromModules will
249249
// return the module, its root directory, and a list of other modules that
250250
// lexically could have provided the package but did not.
251-
func importFromModules(ctx context.Context, path string, rs *Requirements, mg *ModuleGraph) (m module.Version, modroot, dir string, altMods []module.Version, err error) {
251+
//
252+
// If skipModFile is true, the go.mod file for the package is not loaded. This
253+
// allows 'go mod tidy' to preserve a minor checksum-preservation bug
254+
// (https://go.dev/issue/56222) for modules with 'go' versions between 1.17 and
255+
// 1.20, preventing unnecessary go.sum churn and network access in those
256+
// modules.
257+
func importFromModules(ctx context.Context, path string, rs *Requirements, mg *ModuleGraph, skipModFile bool) (m module.Version, modroot, dir string, altMods []module.Version, err error) {
252258
invalidf := func(format string, args ...interface{}) (module.Version, string, string, []module.Version, error) {
253259
return module.Version{}, "", "", nil, &invalidImportError{
254260
importPath: path,
@@ -412,6 +418,18 @@ func importFromModules(ctx context.Context, path string, rs *Requirements, mg *M
412418
}
413419

414420
if len(mods) == 1 {
421+
// We've found the unique module containing the package.
422+
// However, in order to actually compile it we need to know what
423+
// Go language version to use, which requires its go.mod file.
424+
//
425+
// If the module graph is pruned and this is a test-only dependency
426+
// of a package in "all", we didn't necessarily load that file
427+
// when we read the module graph, so do it now to be sure.
428+
if !skipModFile && cfg.BuildMod != "vendor" && mods[0].Path != "" && !MainModules.Contains(mods[0].Path) {
429+
if _, err := goModSummary(mods[0]); err != nil {
430+
return module.Version{}, "", "", nil, err
431+
}
432+
}
415433
return mods[0], roots[0], dirs[0], altMods, nil
416434
}
417435

src/cmd/go/internal/modload/init.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,8 @@ func commitRequirements(ctx context.Context) (err error) {
15711571
// keepSums returns the set of modules (and go.mod file entries) for which
15721572
// checksums would be needed in order to reload the same set of packages
15731573
// loaded by the most recent call to LoadPackages or ImportFromFiles,
1574-
// including any go.mod files needed to reconstruct the MVS result,
1574+
// including any go.mod files needed to reconstruct the MVS result
1575+
// or identify go versions,
15751576
// in addition to the checksums for every module in keepMods.
15761577
func keepSums(ctx context.Context, ld *loader, rs *Requirements, which whichSums) map[module.Version]bool {
15771578
// Every module in the full module graph contributes its requirements,
@@ -1593,6 +1594,16 @@ func keepSums(ctx context.Context, ld *loader, rs *Requirements, which whichSums
15931594
continue
15941595
}
15951596

1597+
// We need the checksum for the go.mod file for pkg.mod
1598+
// so that we know what Go version to use to compile pkg.
1599+
// However, we didn't do so before Go 1.21, and the bug is relatively
1600+
// minor, so we maintain the previous (buggy) behavior in 'go mod tidy' to
1601+
// avoid introducing unnecessary churn.
1602+
if !ld.Tidy || semver.Compare("v"+ld.GoVersion, tidyGoModSumVersionV) >= 0 {
1603+
r := resolveReplacement(pkg.mod)
1604+
keep[modkey(r)] = true
1605+
}
1606+
15961607
if rs.pruning == pruned && pkg.mod.Path != "" {
15971608
if v, ok := rs.rootSelected(pkg.mod.Path); ok && v == pkg.mod.Version {
15981609
// pkg was loaded from a root module, and because the main module has
@@ -1648,6 +1659,7 @@ func keepSums(ctx context.Context, ld *loader, rs *Requirements, which whichSums
16481659
if which == addBuildListZipSums {
16491660
for _, m := range mg.BuildList() {
16501661
r := resolveReplacement(m)
1662+
keep[modkey(r)] = true // we need the go version from the go.mod file to do anything useful with the zipfile
16511663
keep[r] = true
16521664
}
16531665
}

src/cmd/go/internal/modload/load.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,10 @@ type loader struct {
842842
// transitively *imported by* the packages and tests in the main module.)
843843
allClosesOverTests bool
844844

845+
// skipImportModFiles indicates whether we may skip loading go.mod files
846+
// for imported packages (as in 'go mod tidy' in Go 1.17–1.20).
847+
skipImportModFiles bool
848+
845849
work *par.Queue
846850

847851
// reset on each iteration
@@ -1022,6 +1026,10 @@ func loadFromRoots(ctx context.Context, params loaderParams) *loader {
10221026
// version higher than the go.mod version adds nothing.
10231027
ld.TidyCompatibleVersion = ld.GoVersion
10241028
}
1029+
1030+
if semver.Compare("v"+ld.GoVersion, tidyGoModSumVersionV) < 0 {
1031+
ld.skipImportModFiles = true
1032+
}
10251033
}
10261034

10271035
if semver.Compare("v"+ld.GoVersion, narrowAllVersionV) < 0 && !ld.UseVendorAll {
@@ -1402,7 +1410,7 @@ func (ld *loader) updateRequirements(ctx context.Context) (changed bool, err err
14021410
//
14031411
// In some sense, we can think of this as ‘upgraded the module providing
14041412
// pkg.path from "none" to a version higher than "none"’.
1405-
if _, _, _, _, err = importFromModules(ctx, pkg.path, rs, nil); err == nil {
1413+
if _, _, _, _, err = importFromModules(ctx, pkg.path, rs, nil, ld.skipImportModFiles); err == nil {
14061414
changed = true
14071415
break
14081416
}
@@ -1613,7 +1621,7 @@ func (ld *loader) preloadRootModules(ctx context.Context, rootPkgs []string) (ch
16131621
// If the main module is tidy and the package is in "all" — or if we're
16141622
// lucky — we can identify all of its imports without actually loading the
16151623
// full module graph.
1616-
m, _, _, _, err := importFromModules(ctx, path, ld.requirements, nil)
1624+
m, _, _, _, err := importFromModules(ctx, path, ld.requirements, nil, ld.skipImportModFiles)
16171625
if err != nil {
16181626
var missing *ImportMissingError
16191627
if errors.As(err, &missing) && ld.ResolveMissingImports {
@@ -1701,7 +1709,7 @@ func (ld *loader) load(ctx context.Context, pkg *loadPkg) {
17011709
}
17021710

17031711
var modroot string
1704-
pkg.mod, modroot, pkg.dir, pkg.altMods, pkg.err = importFromModules(ctx, pkg.path, ld.requirements, mg)
1712+
pkg.mod, modroot, pkg.dir, pkg.altMods, pkg.err = importFromModules(ctx, pkg.path, ld.requirements, mg, ld.skipImportModFiles)
17051713
if pkg.dir == "" {
17061714
return
17071715
}
@@ -1960,7 +1968,7 @@ func (ld *loader) checkTidyCompatibility(ctx context.Context, rs *Requirements)
19601968

19611969
pkg := pkg
19621970
ld.work.Add(func() {
1963-
mod, _, _, _, err := importFromModules(ctx, pkg.path, rs, mg)
1971+
mod, _, _, _, err := importFromModules(ctx, pkg.path, rs, mg, ld.skipImportModFiles)
19641972
if mod != pkg.mod {
19651973
mismatches := <-mismatchMu
19661974
mismatches[pkg] = mismatch{mod: mod, err: err}

src/cmd/go/internal/modload/modfile.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ const (
4545
// "// indirect" dependencies are added in a block separate from the direct
4646
// ones. See https://golang.org/issue/45965.
4747
separateIndirectVersionV = "v1.17"
48+
49+
// tidyGoModSumVersionV is the Go version (plus leading "v") at which
50+
// 'go mod tidy' preserves go.mod checksums needed to build test dependencies
51+
// of packages in "all", so that 'go test all' can be run without checksum
52+
// errors.
53+
// See https://go.dev/issue/56222.
54+
tidyGoModSumVersionV = "v1.21"
4855
)
4956

5057
// ReadModFile reads and parses the mod file at gomod. ReadModFile properly applies the
@@ -566,6 +573,8 @@ func goModSummary(m module.Version) (*modFileSummary, error) {
566573
summary := &modFileSummary{
567574
module: module.Version{Path: m.Path},
568575
}
576+
577+
readVendorList(MainModules.mustGetSingleMainModule())
569578
if vendorVersion[m.Path] != m.Version {
570579
// This module is not vendored, so packages cannot be loaded from it and
571580
// it cannot be relevant to the build.
@@ -574,8 +583,6 @@ func goModSummary(m module.Version) (*modFileSummary, error) {
574583

575584
// For every module other than the target,
576585
// return the full list of modules from modules.txt.
577-
readVendorList(MainModules.mustGetSingleMainModule())
578-
579586
// We don't know what versions the vendored module actually relies on,
580587
// so assume that it requires everything.
581588
summary.require = vendorList
@@ -586,7 +593,7 @@ func goModSummary(m module.Version) (*modFileSummary, error) {
586593
if HasModRoot() && cfg.BuildMod == "readonly" && !inWorkspaceMode() && actual.Version != "" {
587594
key := module.Version{Path: actual.Path, Version: actual.Version + "/go.mod"}
588595
if !modfetch.HaveSum(key) {
589-
suggestion := fmt.Sprintf("; to add it:\n\tgo mod download %s", m.Path)
596+
suggestion := fmt.Sprintf(" for go.mod file; to add it:\n\tgo mod download %s", m.Path)
590597
return nil, module.VersionError(actual, &sumMissingError{suggestion: suggestion})
591598
}
592599
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
example.com/generics v1.0.0
2+
written by hand
3+
4+
-- .mod --
5+
module example.com/generics
6+
7+
go 1.18
8+
-- .info --
9+
{"Version":"v1.0.0"}
10+
-- go.mod --
11+
module example.com/generics
12+
13+
go 1.18
14+
-- generics.go --
15+
package generics
16+
17+
type Int interface {
18+
~int
19+
}
20+
21+
func Bar() {}

src/cmd/go/testdata/script/list_parse_err.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ stderr '^p[/\\]b.go:2:2: expected ''package'', found ''EOF''$'
44
! go list -f '{{range .Imports}}{{.}} {{end}}' ./p
55
stderr '^p[/\\]b.go:2:2: expected ''package'', found ''EOF''$'
66
! go list -test ./t
7-
stderr '^can''t load test package: t[/\\]t_test.go:8:1: expected declaration, found ʕ'
7+
stderr '^go: can''t load test package: t[/\\]t_test.go:8:1: expected declaration, found ʕ'
88
! go list -test -f '{{range .Imports}}{{.}} {{end}}' ./t
9-
stderr '^can''t load test package: t[/\\]t_test.go:8:1: expected declaration, found ʕ'
9+
stderr '^go: can''t load test package: t[/\\]t_test.go:8:1: expected declaration, found ʕ'
1010

1111
# 'go list -e' should report imports, even if some files have parse errors
1212
# before the import block.

src/cmd/go/testdata/script/mod_install_pkg_version.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ env GO111MODULE=auto
1616
cd m
1717
cp go.mod go.mod.orig
1818
! go list -m all
19-
stderr '^go: example.com/cmd@v1.1.0-doesnotexist: missing go.sum entry; to add it:\n\tgo mod download example.com/cmd$'
19+
stderr '^go: example.com/cmd@v1.1.0-doesnotexist: reading http.*/mod/example.com/cmd/@v/v1.1.0-doesnotexist.info: 404 Not Found\n\tserver response: 404 page not found$'
20+
stderr '^go: example.com/cmd@v1.1.0-doesnotexist: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/cmd$'
2021
go install example.com/cmd/a@latest
2122
cmp go.mod go.mod.orig
2223
exists $GOPATH/bin/a$GOEXE

src/cmd/go/testdata/script/mod_list_sums.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ stderr '^go: updates to go.sum needed, disabled by -mod=readonly$'
2929
#
3030
# TODO(#41297): This should not be an error either.
3131
! go list -m -mod=readonly -versions rsc.io/sampler
32-
stderr '^go: rsc\.io/quote@v1\.5\.1: missing go\.sum entry; to add it:\n\tgo mod download rsc\.io/quote$'
32+
stderr '^go: rsc\.io/quote@v1\.5\.1: missing go\.sum entry for go.mod file; to add it:\n\tgo mod download rsc\.io/quote$'

src/cmd/go/testdata/script/mod_run_pkg_version.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ env GO111MODULE=on
2121
cd m
2222
cp go.mod go.mod.orig
2323
! go list -m all
24-
stderr '^go: example.com/cmd@v1.1.0-doesnotexist: missing go.sum entry; to add it:\n\tgo mod download example.com/cmd$'
24+
stderr '^go: example.com/cmd@v1.1.0-doesnotexist: reading http.*/mod/example\.com/cmd/@v/v1.1.0-doesnotexist.info: 404 Not Found\n\tserver response: 404 page not found$'
25+
stderr '^go: example.com/cmd@v1.1.0-doesnotexist: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/cmd$'
2526
go run example.com/cmd/a@v1.0.0
2627
stdout '^a@v1.0.0$'
2728
cmp go.mod go.mod.orig
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Regression test for #56222: 'go get -t' and 'go mod tidy'
2+
# should save enough checksums to run 'go test' on the named
3+
# packages or any package in "all" respectively.
4+
5+
# At go 1.19 or earlier, 'go mod tidy' should preserve the historical go.sum
6+
# contents, but 'go test' should flag the missing checksums (instead of trying
7+
# to build the test dependency with the wrong language version).
8+
9+
cd m1
10+
go mod tidy
11+
! go test -o $devnull -c example.com/m2/q
12+
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$'
13+
14+
go mod download -json example.com/generics
15+
go list -f '{{if eq .ImportPath "example.com/generics"}}{{.Module.GoVersion}}{{end}}' -deps -test example.com/m2/q
16+
stdout 1.18
17+
18+
19+
# Even at go 1.19 or earlier, 'go mod tidy' shouldn't need go.mod files or
20+
# checksums that it won't record.
21+
22+
go mod tidy -go=1.19
23+
go clean -modcache # Remove checksums from the module cache, so that only go.sum is used.
24+
25+
env OLDSUMDB=$GOSUMDB
26+
env GOSUMDB=bad
27+
go mod tidy
28+
29+
env GOSUMDB=$OLDSUMDB
30+
31+
32+
# Regardless of the go version in go.mod, 'go get -t' should fetch
33+
# enough checksums to run 'go test' on the named package.
34+
35+
rm p
36+
go mod tidy -go=1.19
37+
go list -m all
38+
! stdout example.com/generics
39+
go get -t example.com/m2/q@v1.0.0
40+
go list -f '{{if eq .ImportPath "example.com/generics"}}{{.Module.GoVersion}}{{end}}' -deps -test example.com/m2/q
41+
stdout 1.18
42+
[!short] go test -o $devnull -c example.com/m2/q
43+
44+
45+
-- m1/go.mod --
46+
module example.com/m1
47+
48+
go 1.19
49+
50+
require example.com/m2 v1.0.0
51+
replace example.com/m2 => ../m2
52+
-- m1/p/p.go --
53+
package p
54+
55+
import _ "example.com/m2/q"
56+
-- m2/go.mod --
57+
module example.com/m2
58+
59+
go 1.19
60+
61+
require example.com/generics v1.0.0
62+
-- m2/q/q.go --
63+
package q
64+
-- m2/q/q_test.go --
65+
package q
66+
67+
import _ "example.com/generics"

src/cmd/go/testdata/script/mod_sum_readonly.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ env GO111MODULE=on
44
# When a sum is needed to load the build list, we get an error for the
55
# specific module. The .mod file is not downloaded, and go.sum is not written.
66
! go list -m all
7-
stderr '^go: rsc.io/quote@v1.5.2: missing go.sum entry; to add it:\n\tgo mod download rsc.io/quote$'
7+
stderr '^go: rsc.io/quote@v1.5.2: missing go.sum entry for go.mod file; to add it:\n\tgo mod download rsc.io/quote$'
88
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
99
! exists go.sum
1010

1111
# If go.sum exists but contains hashes from an algorithm we don't know about,
1212
# we should see the same error.
1313
cp go.sum.h2only go.sum
1414
! go list -m all
15-
stderr '^go: rsc.io/quote@v1.5.2: missing go.sum entry; to add it:\n\tgo mod download rsc.io/quote$'
15+
stderr '^go: rsc.io/quote@v1.5.2: missing go.sum entry for go.mod file; to add it:\n\tgo mod download rsc.io/quote$'
1616
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
1717
cmp go.sum go.sum.h2only
1818
rm go.sum
@@ -21,7 +21,7 @@ rm go.sum
2121
cp go.mod go.mod.orig
2222
go mod edit -replace rsc.io/quote@v1.5.2=rsc.io/quote@v1.5.1
2323
! go list -m all
24-
stderr '^go: rsc.io/quote@v1.5.2 \(replaced by rsc.io/quote@v1.5.1\): missing go.sum entry; to add it:\n\tgo mod download rsc.io/quote$'
24+
stderr '^go: rsc.io/quote@v1.5.2 \(replaced by rsc.io/quote@v1.5.1\): missing go.sum entry for go.mod file; to add it:\n\tgo mod download rsc.io/quote$'
2525
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.1.mod
2626
! exists go.sum
2727
cp go.mod.orig go.mod

src/cmd/go/testdata/script/mod_tidy_compat.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ cmp stdout m_all.txt
5050

5151
go mod edit -go=1.16
5252
! go list -m all
53-
stderr '^go: example.net/lazy@v0.1.0 requires\n\texample.com/version@v1.0.1: missing go.sum entry; to add it:\n\tgo mod download example.com/version$'
53+
stderr '^go: example.net/lazy@v0.1.0 requires\n\texample.com/version@v1.0.1: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/version$'
5454

5555

5656
-- go.mod --

src/cmd/go/testdata/script/mod_tidy_compat_ambiguous.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ cmp stdout all-m.txt
6262

6363
go mod edit -go=1.16
6464
! go list -m all
65-
stderr '^go: example\.net/indirect@v0\.1\.0 requires\n\texample\.net/ambiguous@v0\.1\.0: missing go\.sum entry; to add it:\n\tgo mod download example\.net/ambiguous\n'
65+
stderr '^go: example\.net/indirect@v0\.1\.0 requires\n\texample\.net/ambiguous@v0\.1\.0: missing go\.sum entry for go\.mod file; to add it:\n\tgo mod download example\.net/ambiguous\n'
6666

6767

6868
-- go.mod --

src/cmd/go/testdata/script/mod_tidy_compat_implicit.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ go mod tidy -compat=1.17
4545
! stderr .
4646
cmp go.mod go.mod.orig
4747

48-
go list -deps -test -f $MODFMT all
49-
stdout '^example\.com/retract/incompatible v1\.0\.0$'
48+
go list -deps -test -f $MODFMT ./...
49+
stdout '^example.net/lazy v0.1.0$'
5050

5151
go mod edit -go=1.16
52-
! go list -deps -test -f $MODFMT all
52+
! go list -deps -test -f $MODFMT ./...
5353

5454
# TODO(#46160): -count=1 instead of -count=2.
55-
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$'
55+
stderr -count=2 '^go: example\.net/lazy@v0\.1\.0 requires\n\texample\.com/retract/incompatible@v1\.0\.0: missing go\.sum entry for go\.mod file; to add it:\n\tgo mod download example\.com/retract/incompatible$'
5656

5757

5858
# If we combine a Go 1.16 go.sum file...
@@ -63,7 +63,7 @@ cp go.mod.orig go.mod
6363

6464
# ...then Go 1.17 no longer works. 😞
6565
! go list -deps -test -f $MODFMT all
66-
stderr -count=1 '^can''t load test package: lazy[/\\]lazy_test.go:3:8: missing go\.sum entry for module providing package example\.com/retract/incompatible \(imported by example\.net/lazy\); to add:\n\tgo get -t example.net/lazy@v0\.1\.0$'
66+
stderr -count=1 '^go: can''t load test package: lazy[/\\]lazy_test.go:3:8: missing go\.sum entry for module providing package example\.com/retract/incompatible \(imported by example\.net/lazy\); to add:\n\tgo get -t example.net/lazy@v0\.1\.0$'
6767

6868

6969
# However, if we take the union of the go.sum files...

src/cmd/go/testdata/script/mod_tidy_compat_incompatible.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ cmp go.mod go.mod.orig
4949
go mod edit -go=1.16
5050
! go list -f $MODFMT -deps ./...
5151
# TODO(#46160): -count=1 instead of -count=2.
52-
stderr -count=2 '^go: example\.net/lazy@v0\.1\.0 requires\n\texample\.net/requireincompatible@v0\.1\.0 requires\n\texample\.com/retract/incompatible@v2\.0\.0\+incompatible: missing go.sum entry; to add it:\n\tgo mod download example.com/retract/incompatible$'
52+
stderr -count=2 '^go: example\.net/lazy@v0\.1\.0 requires\n\texample\.net/requireincompatible@v0\.1\.0 requires\n\texample\.com/retract/incompatible@v2\.0\.0\+incompatible: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/retract/incompatible$'
5353

5454

5555
# There are two ways for the module author to bring the two into alignment.

src/cmd/go/testdata/script/mod_tidy_compat_irrelevant.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cmp stdout out-117.txt
4848
go mod edit -go=1.16
4949
! go list -deps -test -f $MODFMT all
5050
# TODO(#46160): -count=1 instead of -count=2.
51-
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$'
51+
stderr -count=2 '^go: example.net/lazy@v0.1.0 requires\n\texample.com/retract/incompatible@v1.0.0: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/retract/incompatible$'
5252

5353

5454
-- go.mod --

0 commit comments

Comments
 (0)