mirror of https://github.com/golang/go.git
cmd/go: add a test that reproduces the root cause of issue #56494
For #56494. Change-Id: I9bbded6d014ac73d81b973f2d7b4783e64380031 Reviewed-on: https://go-review.googlesource.com/c/go/+/447797 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
7bc3281747
commit
9fd876924a
|
|
@ -1751,7 +1751,7 @@ func (r *resolver) updateBuildList(ctx context.Context, additions []module.Versi
|
|||
reason := func(m module.Version) string {
|
||||
rv, ok := r.resolvedVersion[m.Path]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("internal error: can't find reason for requirement on %v", m))
|
||||
return fmt.Sprintf("(INTERNAL ERROR: no reason found for %v)", m)
|
||||
}
|
||||
return rv.reason.ResolvedString(module.Version{Path: m.Path, Version: rv.version})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,136 @@
|
|||
# Regression test for https://go.dev/issue/56494:
|
||||
# 'go get' in module mode was failing to prune out dependencies
|
||||
# through modules whose versions are too low to be selected.
|
||||
|
||||
# Initially, modules "a", "b", and "c" are unrelated.
|
||||
#
|
||||
# The package import graph at v1 of everything looks like:
|
||||
#
|
||||
# m --- a
|
||||
# |
|
||||
# + --- b
|
||||
# |
|
||||
# + --- c
|
||||
#
|
||||
# At v2, package "a" adds imports of "b" and "c"
|
||||
# (and a requirement on "c" v2):
|
||||
#
|
||||
# a --- b
|
||||
# |
|
||||
# + --- c
|
||||
#
|
||||
# And "b" adds an import of "a/sub" (in module "a"):
|
||||
#
|
||||
# b --- a/sub
|
||||
#
|
||||
# At v3, "a" no longer imports (nor requires) "c":
|
||||
#
|
||||
# a --- b
|
||||
|
||||
# So upgrading to a3 adds a dependency on b2,
|
||||
# b2 adds a dependency on a2 (for "a/sub"),
|
||||
# and a2 (but not a3) would add a dependency on c2.
|
||||
# Since a2 is lower than a3 it cannot possibly be selected when
|
||||
# upgrading to a3: normally a2 is pruned out of a3's module graph,
|
||||
# so 'go get' should prune it out too, and c should remain at c1
|
||||
# without error.
|
||||
|
||||
# TODO(#56494): This should succeed, not error out.
|
||||
! go get a@v0.3.0
|
||||
stderr 'INTERNAL ERROR'
|
||||
|
||||
go list -m c
|
||||
stdout '^c v0.1.0 '
|
||||
|
||||
-- go.mod --
|
||||
module m
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
a v0.1.0
|
||||
b v0.1.0
|
||||
c v0.1.0
|
||||
)
|
||||
|
||||
replace (
|
||||
a v0.1.0 => ./a1
|
||||
a v0.2.0 => ./a2
|
||||
a v0.3.0 => ./a3
|
||||
b v0.1.0 => ./b1
|
||||
b v0.2.0 => ./b2
|
||||
c v0.1.0 => ./c1
|
||||
c v0.2.0 => ./c2
|
||||
)
|
||||
-- m.go --
|
||||
package m
|
||||
|
||||
import (
|
||||
_ "a"
|
||||
_ "b"
|
||||
_ "c"
|
||||
)
|
||||
-- a1/go.mod --
|
||||
module a
|
||||
|
||||
go 1.19
|
||||
-- a1/a.go --
|
||||
package a
|
||||
-- a2/go.mod --
|
||||
module a
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
b v0.1.0
|
||||
c v0.2.0
|
||||
)
|
||||
-- a2/a.go --
|
||||
package a
|
||||
|
||||
import (
|
||||
_ "b"
|
||||
_ "c"
|
||||
)
|
||||
-- a2/sub/sub.go --
|
||||
package sub
|
||||
-- a3/go.mod --
|
||||
module a
|
||||
|
||||
go 1.19
|
||||
|
||||
require b v0.2.0
|
||||
-- a3/a.go --
|
||||
package a
|
||||
|
||||
import _ "b"
|
||||
-- a3/sub/sub.go --
|
||||
package sub
|
||||
-- b1/go.mod --
|
||||
module b
|
||||
|
||||
go 1.19
|
||||
-- b1/b.go --
|
||||
package b
|
||||
-- b2/go.mod --
|
||||
module b
|
||||
|
||||
go 1.19
|
||||
|
||||
require a v0.2.0
|
||||
-- b2/b.go --
|
||||
package b
|
||||
|
||||
import "a/sub"
|
||||
-- c1/go.mod --
|
||||
module c
|
||||
|
||||
go 1.19
|
||||
-- c1/c.go --
|
||||
package c
|
||||
-- c2/go.mod --
|
||||
module c
|
||||
|
||||
go 1.19
|
||||
-- c2/c.go --
|
||||
package c
|
||||
Loading…
Reference in New Issue