diff options
author | Michael Matloob <matloob@golang.org> | 2021-09-08 17:28:09 -0400 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2021-09-13 18:05:59 +0000 |
commit | c8a58f29dcb2b4f38ca4fcf4d2a2a80f606c9573 (patch) | |
tree | 4c4ae9e42b4e17f2ec02d4044e430971c28ea97c | |
parent | e74e363a6b3e71ec5a49a3aae8c2523abb72faa7 (diff) | |
download | go-c8a58f29dcb2b4f38ca4fcf4d2a2a80f606c9573.tar.gz go-c8a58f29dcb2b4f38ca4fcf4d2a2a80f606c9573.zip |
cmd/go: add test to check for a potential workspace loading issue
This test checks that we load the same graph regardless of the path to
the requested module in the workspace.
We currently don't. This will be fixed in a future change that redoes
workspace mode's usage of the Requirements structure.
For #45713
Change-Id: Id02cbb60a38619d840dbf1e70173ce853c0c167a
Reviewed-on: https://go-review.googlesource.com/c/go/+/348649
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
-rw-r--r-- | src/cmd/go/testdata/script/work_prune.txt | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/work_prune.txt b/src/cmd/go/testdata/script/work_prune.txt new file mode 100644 index 0000000000..7347b312ee --- /dev/null +++ b/src/cmd/go/testdata/script/work_prune.txt @@ -0,0 +1,104 @@ +# This test makes sure workspace mode's handling of the module graph +# is compatible with module pruning. The graph we load from either of +# the workspace modules should be the same, even if their graphs +# don't overlap. +# +# This is the module graph in the test: +# +# example.com/a -> example.com/b v1.0.0 -> example.com/q v1.1.0 +# example.com/p -> example.com/q v1.0.0 +# +# If we didn't load the whole graph and didn't load the dependencies of b +# when loading p, we would end up loading q v1.0.0, rather than v1.1.0, +# which is selected by MVS. +# TODO(#48331): We currently load the wrong version of q. Fix this. + +go list -m -f '{{.Version}}' example.com/q +stdout '^v1.0.0$' # TODO(#48331): This should be 1.1.0. Fix this. + +-- go.work -- +go 1.18 + +directory ( + ./a + ./p +) +-- a/go.mod -- +module example.com/a + +go 1.18 + +require example.com/b v1.0.0 + +replace example.com/b v1.0.0 => ../b +-- a/foo.go -- +package main + +import "example.com/b" + +func main() { + b.B() +} +-- b/go.mod -- +module example.com/b + +go 1.18 + +require example.com/q v1.1.0 + +replace example.com/q v1.0.0 => ../q1_0_0 +replace example.com/q v1.1.0 => ../q1_1_0 +-- b/b.go -- +package b + +func B() { +} +-- b/b_test.go -- +package b + +import "example.com/q" + +func TestB() { + q.PrintVersion +} +-- p/go.mod -- +module example.com/p + +go 1.18 + +require example.com/q v1.0.0 + +replace example.com/q v1.0.0 => ../q1_0_0 +replace example.com/q v1.1.0 => ../q1_1_0 +-- p/main.go -- +package main + +import "example.com/q" + +func main() { + q.PrintVersion() +} +-- q1_0_0/go.mod -- +module example.com/q + +go 1.18 +-- q1_0_0/q.go -- +package q + +import "fmt" + +func PrintVersion() { + fmt.Println("version 1.0.0") +} +-- q1_1_0/go.mod -- +module example.com/q + +go 1.18 +-- q1_1_0/q.go -- +package q + +import "fmt" + +func PrintVersion() { + fmt.Println("version 1.1.0") +} |