diff options
author | Jay Conrod <jayconrod@google.com> | 2019-10-10 10:26:21 -0400 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2019-10-10 19:07:50 +0000 |
commit | 68395a66f9fece387701e1450e3d7a8fa91fb76e (patch) | |
tree | 302e4c4e83a64035ab7c638fa6a236e23905f794 /src/cmd/go/testdata/script/mod_outside.txt | |
parent | 46b7557836c8a7f8a481946eebbf4a1b0947b332 (diff) | |
download | go-68395a66f9fece387701e1450e3d7a8fa91fb76e.tar.gz go-68395a66f9fece387701e1450e3d7a8fa91fb76e.zip |
cmd/go: forbid module pattern 'all' when outside a module
Also, in cmd/doc, avoid calling 'go list -m all' when in module mode
outside a module since it's now an error.
Fixes #32027
Change-Id: I7224c7fdf7e950bce6c058ab2a5837c27ba3b899
Reviewed-on: https://go-review.googlesource.com/c/go/+/200297
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/testdata/script/mod_outside.txt')
-rw-r--r-- | src/cmd/go/testdata/script/mod_outside.txt | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/cmd/go/testdata/script/mod_outside.txt b/src/cmd/go/testdata/script/mod_outside.txt index dd4e2d5800..815745e8bf 100644 --- a/src/cmd/go/testdata/script/mod_outside.txt +++ b/src/cmd/go/testdata/script/mod_outside.txt @@ -25,8 +25,6 @@ stderr 'cannot find main module' go list all ! stdout . stderr 'warning: "all" matched no packages' -go list -m all -stderr 'warning: pattern "all" matched no module dependencies' # 'go list' on standard-library packages should work, since they do not depend # on the contents of any module. @@ -49,10 +47,13 @@ stdout 'example.com/version v1.1.0' go list -m -versions example.com/version stdout 'v1.0.0\s+v1.0.1\s+v1.1.0' -# 'go list -m <mods> all' does not include the dependencies of <mods> in the computation of 'all'. -go list -m example.com/printversion@v1.0.0 all -stdout 'example.com/printversion v1.0.0' -stderr 'warning: pattern "all" matched no module dependencies' +# 'go list -m all' should fail. "all" is not meaningful outside of a module. +! go list -m all +stderr 'go: cannot match "all": working directory is not part of a module' + +# 'go list -m <mods> all' should also fail. +! go list -m example.com/printversion@v1.0.0 all +stderr 'go: cannot match "all": working directory is not part of a module' ! stdout 'example.com/version' @@ -87,6 +88,10 @@ go mod download example.com/printversion@v1.0.0 exists $GOPATH/pkg/mod/cache/download/example.com/printversion/@v/v1.0.0.zip ! exists $GOPATH/pkg/mod/cache/download/example.com/version/@v/v1.0.0.zip +# 'go mod download all' should fail. "all" is not meaningful outside of a module. +! go mod download all +stderr 'go: cannot match "all": working directory is not part of a module' + # 'go mod vendor' should fail: it starts by clearing the existing vendor # directory, and we don't know where that is. ! go mod vendor @@ -109,9 +114,8 @@ stderr 'cannot find main module' # 'go get -u all' upgrades the transitive import graph of the main module, # which is empty. -go get -u all -! stdout . -stderr 'warning: "all" matched no packages' +! go get -u all +stderr 'go get all: cannot match "all": working directory is not part of a module' # 'go get' should check the proposed module graph for consistency, # even though we won't write it anywhere. |