summaryrefslogtreecommitdiff
path: root/libgo/go/cmd/go/testdata/script/mod_vendor.txt
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/cmd/go/testdata/script/mod_vendor.txt')
-rw-r--r--libgo/go/cmd/go/testdata/script/mod_vendor.txt56
1 files changed, 40 insertions, 16 deletions
diff --git a/libgo/go/cmd/go/testdata/script/mod_vendor.txt b/libgo/go/cmd/go/testdata/script/mod_vendor.txt
index 5d872c3c80e..bb3e634b3a3 100644
--- a/libgo/go/cmd/go/testdata/script/mod_vendor.txt
+++ b/libgo/go/cmd/go/testdata/script/mod_vendor.txt
@@ -1,15 +1,15 @@
env GO111MODULE=on
-go list -m all
-stdout '^x v1.0.0 => ./x'
-stdout '^w'
-
+# Without vendoring, a build should succeed unless -mod=vendor is set.
[!short] go build
[!short] ! go build -mod=vendor
+# Without vendoring, 'go list' should report the replacement directory for
+# a package in a replaced module.
go list -f {{.Dir}} x
stdout 'src[\\/]x'
+# 'go mod vendor' should copy all replaced modules to the vendor directory.
go mod vendor -v
stderr '^# x v1.0.0 => ./x'
stderr '^x'
@@ -20,28 +20,47 @@ stderr '^z'
! stderr '^w'
grep 'a/foo/bar/b\na/foo/bar/c' vendor/modules.txt # must be sorted
-go list -f {{.Dir}} x
+# An explicit '-mod=mod' should ignore the vendor directory.
+go list -mod=mod -f {{.Dir}} x
stdout 'src[\\/]x'
-go list -f {{.Dir}} -m x
+go list -mod=mod -f {{.Dir}} -m x
stdout 'src[\\/]x'
+# An explicit '-mod=vendor' should report package directories within
+# the vendor directory.
go list -mod=vendor -f {{.Dir}} x
stdout 'src[\\/]vendor[\\/]x'
-go list -mod=vendor -f {{.Dir}} -m x
-stdout 'src[\\/]vendor[\\/]x'
-
-go list -f {{.Dir}} -m w
+# 'go list -mod=vendor -m' should successfully list vendored modules,
+# but should not provide a module directory because no directory contains
+# the complete module.
+go list -mod=vendor -f '{{.Version}} {{.Dir}}' -m x
+stdout '^v1.0.0 $'
+
+# 'go list -mod=vendor -m' on a transitive dependency that does not
+# provide vendored packages should give a helpful error rather than
+# 'not a known dependency'.
+! go list -mod=vendor -f '{{.Version}} {{.Dir}}' -m diamondright
+stderr 'go list -m: module diamondright: can''t resolve module using the vendor directory\n\t\(Use -mod=mod or -mod=readonly to bypass.\)'
+
+# 'go list -mod=mod' should report packages outside the import graph,
+# but 'go list -mod=vendor' should error out for them.
+go list -mod=mod -f {{.Dir}} w
stdout 'src[\\/]w'
-
! go list -mod=vendor -f {{.Dir}} w
stderr 'src[\\/]vendor[\\/]w'
+go list -mod=mod -f {{.Dir}} diamondright
+stdout 'src[\\/]diamondright'
+
+# Test dependencies should not be copied.
! exists vendor/x/testdata
! exists vendor/a/foo/bar/b/ignored.go
! exists vendor/a/foo/bar/b/main_test.go
+# Licenses and other metadata for each module should be copied
+# if any package within their module is copied.
exists vendor/a/foo/AUTHORS.txt
exists vendor/a/foo/CONTRIBUTORS
exists vendor/a/foo/LICENSE
@@ -59,14 +78,18 @@ exists vendor/mysite/myname/mypkg/LICENSE.txt
[short] stop
-go build
+# 'go build' and 'go test' using vendored packages should succeed.
+go build -mod=mod
go build -mod=vendor
go test -mod=vendor . ./subdir
go test -mod=vendor ./...
+go fmt -mod=vendor ./...
-- go.mod --
module m
+go 1.13
+
require (
a v1.0.0
diamondroot v0.0.0
@@ -252,10 +275,11 @@ require (
-- diamondroot/x.go --
package diamondroot
-import (
- _ "diamondleft"
- _ "diamondright"
-)
+import _ "diamondleft"
+-- diamondroot/unused/unused.go --
+package unused
+
+import _ "diamondright"
-- diamondleft/go.mod --
module diamondleft