From ae329abec0f78743ab2fbf30ef5b488376fe3c85 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 23 Sep 2020 12:28:29 -0400 Subject: [PATCH] cmd/go: add another test case for package/module ambiguity in 'go get' For #37438 Change-Id: Iae00ef7f97144e85f4f710cdb3087c2548b4b8f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/256799 Trust: Bryan C. Mills Trust: Jay Conrod Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Michael Matloob Reviewed-by: Jay Conrod --- .../mod/example.net_pkgremoved_v0.1.0.txt | 16 ++++++++ .../mod/example.net_pkgremoved_v0.2.0.txt | 15 ++++++++ .../mod/example.net_pkgremoved_v0.2.1.txt | 15 ++++++++ .../go/testdata/script/mod_get_patchmod.txt | 38 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 src/cmd/go/testdata/mod/example.net_pkgremoved_v0.1.0.txt create mode 100644 src/cmd/go/testdata/mod/example.net_pkgremoved_v0.2.0.txt create mode 100644 src/cmd/go/testdata/mod/example.net_pkgremoved_v0.2.1.txt create mode 100644 src/cmd/go/testdata/script/mod_get_patchmod.txt diff --git a/src/cmd/go/testdata/mod/example.net_pkgremoved_v0.1.0.txt b/src/cmd/go/testdata/mod/example.net_pkgremoved_v0.1.0.txt new file mode 100644 index 00000000000..f5e76b00c9b --- /dev/null +++ b/src/cmd/go/testdata/mod/example.net_pkgremoved_v0.1.0.txt @@ -0,0 +1,16 @@ +Written by hand. +Test module with a root package added in v0.1.0 and removed in v0.2.0. + +-- .mod -- +module example.net/pkgremoved + +go 1.16 +-- .info -- +{"Version": "v0.1.0"} +-- go.mod -- +module example.net/pkgremoved + +go 1.16 +-- pkgremoved.go -- +// Package pkgremoved exists in v0.1.0. +package pkgremoved diff --git a/src/cmd/go/testdata/mod/example.net_pkgremoved_v0.2.0.txt b/src/cmd/go/testdata/mod/example.net_pkgremoved_v0.2.0.txt new file mode 100644 index 00000000000..f1fc9fb61f3 --- /dev/null +++ b/src/cmd/go/testdata/mod/example.net_pkgremoved_v0.2.0.txt @@ -0,0 +1,15 @@ +Written by hand. +Test module with a root package added in v0.1.0 and removed in v0.2.0. + +-- .mod -- +module example.net/pkgremoved + +go 1.16 +-- .info -- +{"Version": "v0.2.0"} +-- go.mod -- +module example.net/pkgremoved + +go 1.16 +-- README.txt -- +Package pkgremove was removed in v0.2.0. diff --git a/src/cmd/go/testdata/mod/example.net_pkgremoved_v0.2.1.txt b/src/cmd/go/testdata/mod/example.net_pkgremoved_v0.2.1.txt new file mode 100644 index 00000000000..0e961853d52 --- /dev/null +++ b/src/cmd/go/testdata/mod/example.net_pkgremoved_v0.2.1.txt @@ -0,0 +1,15 @@ +Written by hand. +Test module with a root package added in v0.1.0 and removed in v0.2.0. + +-- .mod -- +module example.net/pkgremoved + +go 1.16 +-- .info -- +{"Version": "v0.2.1"} +-- go.mod -- +module example.net/pkgremoved + +go 1.16 +-- README.txt -- +Package pkgremove was removed in v0.2.0. diff --git a/src/cmd/go/testdata/script/mod_get_patchmod.txt b/src/cmd/go/testdata/script/mod_get_patchmod.txt new file mode 100644 index 00000000000..45d680d0211 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_get_patchmod.txt @@ -0,0 +1,38 @@ +# example.net/pkgremoved@v0.1.0 refers to a package. +go get -d example.net/pkgremoved@v0.1.0 + +go list example.net/pkgremoved +stdout '^example.net/pkgremoved' + +# When we resolve a new dependency on example.net/other, +# it will change the meaning of the path "example.net/pkgremoved" +# from a package (at v0.1.0) to only a module (at v0.2.0). +# +# If we simultaneously 'get' that module at the query "patch", the module should +# be upgraded to its patch release (v0.2.1) even though it no longer matches a +# package. +# +# BUG(#37438): Today, the pattern is only interpreted as its initial kind +# (a package), so the 'go get' invocation fails. + +! go get -d example.net/pkgremoved@patch example.net/other@v0.1.0 + +stderr '^go get example.net/pkgremoved@patch: module example.net/pkgremoved@latest found \(v0.2.1\), but does not contain package example.net/pkgremoved$' + + +-- go.mod -- +module example + +go 1.16 + +replace ( + example.net/other v0.1.0 => ./other +) +-- other/go.mod -- +module example.net/other + +go 1.16 + +require example.net/pkgremoved v0.2.0 +-- other/other.go -- +package other