From 6a6aa3278356e850f7530e75e857f539bf8cb51e Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Tue, 4 May 2021 16:37:29 -0400 Subject: [PATCH] cmd/go: add a test that reproduces the internal error in #45952 For #45952 Change-Id: I90e895e2fd10bccd947f9ee5133f942fea218a07 Reviewed-on: https://go-review.googlesource.com/c/go/+/316753 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Jay Conrod --- .../go/testdata/script/mod_tidy_newroot.txt | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/cmd/go/testdata/script/mod_tidy_newroot.txt diff --git a/src/cmd/go/testdata/script/mod_tidy_newroot.txt b/src/cmd/go/testdata/script/mod_tidy_newroot.txt new file mode 100644 index 0000000000..db23a21e5b --- /dev/null +++ b/src/cmd/go/testdata/script/mod_tidy_newroot.txt @@ -0,0 +1,66 @@ +# https://golang.org/issue/45952: 'go mod tidy' in an eager module failed due +# to an erroneous check on root completeness. +# +# Per the issue report: +# > It may have to do with: +# > +# > package A imports package B in go.mod, which imports package C in its own go.mod +# > package A drops direct dependency on package B … +# +# We infer from that that package C is still needed by some other indirect +# dependency, and must be at a higher version than what is required by that +# dependency (or else no new root would be needed). An additional package D +# in its own module satisfies that condition, reproducing the bug. + +! go mod tidy +stderr 'internal error' + +-- go.mod -- +module example.net/a + +go 1.16 + +require ( + example.net/b v0.1.0 + example.net/d v0.1.0 +) + +replace ( + example.net/b v0.1.0 => ./b + example.net/c v0.1.0 => ./c + example.net/c v0.2.0 => ./c + example.net/d v0.1.0 => ./d +) +-- a.go -- +package a + +import _ "example.net/d" + +-- b/go.mod -- +module example.net/b + +go 1.16 + +require example.net/c v0.2.0 +-- b/b.go -- +package b + +import _ "example.net/c" + +-- c/go.mod -- +module example.net/c + +go 1.16 +-- c/c.go -- +package c + +-- d/go.mod -- +module example.net/d + +go 1.16 + +require example.net/c v0.1.0 +-- d/d.go -- +package d + +import _ "example.net/c" -- 2.50.0