From 6ea2af0890260fec6cc951b5f426c0464e43266d Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 11 Jun 2021 16:39:54 -0400 Subject: [PATCH] cmd/go: add a regression test for #45979 Change-Id: Id7f83b2e6a99af798e55b272b04880ebb588351f Reviewed-on: https://go-review.googlesource.com/c/go/+/328230 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Michael Matloob --- .../testdata/script/mod_get_lazy_indirect.txt | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/cmd/go/testdata/script/mod_get_lazy_indirect.txt diff --git a/src/cmd/go/testdata/script/mod_get_lazy_indirect.txt b/src/cmd/go/testdata/script/mod_get_lazy_indirect.txt new file mode 100644 index 0000000000..60548e8429 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_get_lazy_indirect.txt @@ -0,0 +1,38 @@ +# https://golang.org/issue/45979: after 'go get' on a package, +# that package should be importable without error. + + +# We start out with an unresolved dependency. +# 'go list' suggests that we run 'go get' on that dependency. + +! go list -deps . +stderr '^m.go:3:8: no required module provides package rsc\.io/quote; to add it:\n\tgo get rsc.io/quote$' + + +# Unfortunately, the suggested 'go get' command leaves us with another problem. +# +# TODO(#45979): After 'go get', the 'go list' command from above should succeed. + +go get rsc.io/quote + +! go list -deps . +stderr '^go: updates to go.mod needed; to update it:\n\tgo mod tidy' +[!short] ! go build . +stderr '^go: updates to go.mod needed; to update it:\n\tgo mod tidy' + + +# After running the suggested 'go mod tidy' command, the build +# should succeed. +go mod tidy +go list -deps . +[!short] go build . + + +-- go.mod -- +module example.com/m + +go 1.17 +-- m.go -- +package m + +import _ "rsc.io/quote" -- 2.50.0