-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go/internal/mvs: retain modules required by older versions
Fixes #29773 Updates #31248 Change-Id: Ic1923119c8cf3a60c586df1b270c3af0c9095f29 Reviewed-on: https://go-review.googlesource.com/c/go/+/186537 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
- Loading branch information
Bryan C. Mills
committed
Jul 18, 2019
1 parent
4a2d3d0
commit a005f99
Showing
4 changed files
with
174 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
env GO111MODULE=on | ||
|
||
# golang.org/issue/31248: module requirements imposed by dependency versions | ||
# older than the selected version must still be taken into account. | ||
|
||
env GOFLAGS=-mod=readonly | ||
|
||
# Indirect dependencies required via older-than-selected versions must exist in | ||
# the module graph, but do not need to be listed explicitly in the go.mod file | ||
# (since they are implied). | ||
go mod graph | ||
stdout i@v0.1.0 | ||
|
||
# The modules must also appear in the build list, not just the graph. | ||
go list -m all | ||
stdout '^i v0.1.0' | ||
|
||
# The packages provided by those dependencies must resolve. | ||
go list all | ||
stdout '^i$' | ||
|
||
-- go.mod -- | ||
module main | ||
|
||
go 1.13 | ||
|
||
require ( | ||
a v0.0.0 | ||
b v0.0.0 | ||
c v0.0.0 | ||
) | ||
|
||
// Apply replacements so that the test can be self-contained. | ||
// (It's easier to see all of the modules here than to go | ||
// rooting around in testdata/mod.) | ||
replace ( | ||
a => ./a | ||
b => ./b | ||
c => ./c | ||
x v0.1.0 => ./x1 | ||
x v0.2.0 => ./x2 | ||
i => ./i | ||
) | ||
-- main.go -- | ||
package main | ||
|
||
import ( | ||
_ "a" | ||
_ "b" | ||
_ "c" | ||
) | ||
|
||
func main() {} | ||
-- a/go.mod -- | ||
module a | ||
go 1.13 | ||
require x v0.1.0 | ||
-- a/a.go -- | ||
package a | ||
-- b/go.mod -- | ||
module b | ||
go 1.13 | ||
require x v0.2.0 | ||
-- b/b.go -- | ||
package b | ||
-- c/go.mod -- | ||
module c | ||
go 1.13 | ||
-- c/c.go -- | ||
package c | ||
import _ "i" | ||
-- x1/go.mod -- | ||
module x | ||
go1.13 | ||
require i v0.1.0 | ||
-- x2/go.mod -- | ||
module x | ||
go1.13 | ||
-- i/go.mod -- | ||
-- i/i.go -- | ||
package i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
env GO111MODULE=on | ||
|
||
# Regression test for golang.org/issue/29773: 'go list -m' was not following | ||
# dependencies through older versions of the main module. | ||
|
||
go list -f '{{with .Module}}{{.Path}}{{with .Version}} {{.}}{{end}}{{end}}' all | ||
cmp stdout pkgmods.txt | ||
|
||
go list -m all | ||
cmp stdout mods.txt | ||
|
||
go mod graph | ||
cmp stdout graph.txt | ||
|
||
-- go.mod -- | ||
module golang.org/issue/root | ||
|
||
go 1.12 | ||
|
||
replace ( | ||
golang.org/issue/mirror v0.1.0 => ./mirror-v0.1.0 | ||
golang.org/issue/pkg v0.1.0 => ./pkg-v0.1.0 | ||
golang.org/issue/root v0.1.0 => ./root-v0.1.0 | ||
) | ||
|
||
require golang.org/issue/mirror v0.1.0 | ||
|
||
-- root.go -- | ||
package root | ||
|
||
import _ "golang.org/issue/mirror" | ||
|
||
-- mirror-v0.1.0/go.mod -- | ||
module golang.org/issue/mirror | ||
|
||
require golang.org/issue/root v0.1.0 | ||
|
||
-- mirror-v0.1.0/mirror.go -- | ||
package mirror | ||
|
||
import _ "golang.org/issue/pkg" | ||
|
||
-- pkg-v0.1.0/go.mod -- | ||
module golang.org/issue/pkg | ||
|
||
-- pkg-v0.1.0/pkg.go -- | ||
package pkg | ||
|
||
-- root-v0.1.0/go.mod -- | ||
module golang.org/issue/root | ||
|
||
require golang.org/issue/pkg v0.1.0 | ||
|
||
-- pkgmods.txt -- | ||
golang.org/issue/mirror v0.1.0 | ||
golang.org/issue/pkg v0.1.0 | ||
golang.org/issue/root | ||
-- mods.txt -- | ||
golang.org/issue/root | ||
golang.org/issue/mirror v0.1.0 => ./mirror-v0.1.0 | ||
golang.org/issue/pkg v0.1.0 => ./pkg-v0.1.0 | ||
-- graph.txt -- | ||
golang.org/issue/root golang.org/issue/mirror@v0.1.0 | ||
golang.org/issue/mirror@v0.1.0 golang.org/issue/root@v0.1.0 | ||
golang.org/issue/root@v0.1.0 golang.org/issue/pkg@v0.1.0 |