]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: permit "go list" error in some tests
authorCherry Mui <cherryyz@google.com>
Mon, 20 Mar 2023 20:19:30 +0000 (16:19 -0400)
committerCherry Mui <cherryyz@google.com>
Wed, 22 Mar 2023 21:14:01 +0000 (21:14 +0000)
The vendor_import test lists packages that are known bad (e.g.
bad.go, invalid.go). Pass -e to permit error.

The mod_vendor_auto test includes a package that imports a main
package, which should be an error. Pass -e to permit error.

Updates #59186.

Change-Id: I3b63025c3935f55feda1a95151d4c688d0394644
Reviewed-on: https://go-review.googlesource.com/c/go/+/477838
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/cmd/go/testdata/script/mod_vendor_auto.txt
src/cmd/go/testdata/script/vendor_import.txt

index 3cace73a896410595cef799f146de5f09a5ad570..2cafcdab6aea84f28b53195bb0858d5d0e3cbc98 100644 (file)
@@ -11,7 +11,10 @@ cp $WORK/modules-1.13.txt $WORK/auto/modules.txt
 # An explicit -mod=vendor should force use of the vendor directory.
 env GOFLAGS=-mod=vendor
 
-go list -f {{.Dir}} -tags tools all
+# Pass -e to permit an error: tools.go imports a main package
+# "example.com/printversion".
+# TODO(#59186): investigate why it didn't fail without -e.
+go list -f {{.Dir}} -tags tools -e all
 stdout '^'$WORK'[/\\]auto$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]printversion$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]version$'
@@ -25,7 +28,7 @@ stderr 'go: can''t compute ''all'' using the vendor directory\n\t\(Use -mod=mod
 # An explicit -mod=mod should force the vendor directory to be ignored.
 env GOFLAGS=-mod=mod
 
-go list -f {{.Dir}} -tags tools all
+go list -f {{.Dir}} -tags tools -e all
 stdout '^'$WORK'[/\\]auto$'
 stdout '^'$GOPATH'[/\\]pkg[/\\]mod[/\\]example.com[/\\]printversion@v1.0.0$'
 stdout '^'$WORK'[/\\]auto[/\\]replacement-version$'
@@ -44,7 +47,7 @@ stdout '^'$WORK'[/\\]auto[/\\]replacement-version$'
 env GOFLAGS=
 go mod edit -go=1.13
 
-go list -f {{.Dir}} -tags tools all
+go list -f {{.Dir}} -tags tools -e all
 stdout '^'$WORK'[/\\]auto$'
 stdout '^'$GOPATH'[/\\]pkg[/\\]mod[/\\]example.com[/\\]printversion@v1.0.0$'
 stdout '^'$WORK'[/\\]auto[/\\]replacement-version$'
@@ -75,7 +78,7 @@ stdout '^example.com/printversion@v1.0.0 example.com/version@v1.0.0$'
 # An explicit -mod=mod should still force the vendor directory to be ignored.
 env GOFLAGS=-mod=mod
 
-go list -f {{.Dir}} -tags tools all
+go list -f {{.Dir}} -tags tools -e all
 stdout '^'$WORK'[/\\]auto$'
 stdout '^'$GOPATH'[/\\]pkg[/\\]mod[/\\]example.com[/\\]printversion@v1.0.0$'
 stdout '^'$WORK'[/\\]auto[/\\]replacement-version$'
@@ -97,7 +100,7 @@ env GOFLAGS=
 go mod edit -go=1.14
 go mod vendor
 
-go list -f {{.Dir}} -tags tools all
+go list -f {{.Dir}} -tags tools -e all
 stdout '^'$WORK'[/\\]auto$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]printversion$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]version$'
@@ -120,7 +123,7 @@ rm go.mod
 rm vendor/modules.txt
 
 go mod init example.com/auto
-go list -f {{.Dir}} -tags tools all
+go list -f {{.Dir}} -tags tools -e all
 stdout '^'$WORK'[/\\]auto$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]printversion$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]version$'
@@ -130,7 +133,7 @@ stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]version$'
 
 cp go.mod.orig go.mod
 go mod edit -go=1.14
-! go list -f {{.Dir}} -tags tools all
+! go list -f {{.Dir}} -tags tools -e all
 stderr '^go: inconsistent vendoring in '$WORK[/\\]auto':$'
 stderr '^\texample.com/printversion@v1.0.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt'
 stderr '^\texample.com/unused: is replaced in go.mod, but not marked as replaced in vendor/modules.txt'
@@ -141,7 +144,7 @@ stderr '^\tTo ignore the vendor directory, use -mod=readonly or -mod=mod.\n\tTo
 # the go version is 1.13 or earlier.
 # An incomplete or missing vendor/modules.txt should resolve the vendored packages...
 go mod edit -go=1.13
-go list -mod=vendor -f {{.Dir}} -tags tools all
+go list -mod=vendor -f {{.Dir}} -tags tools -e all
 stdout '^'$WORK'[/\\]auto$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]printversion$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]version$'
@@ -158,7 +161,7 @@ stderr '^\tTo ignore the vendor directory, use -mod=readonly or -mod=mod.\n\tTo
 go mod vendor
 cmp $WORK/modules-1.13.txt vendor/modules.txt
 
-go list -mod=vendor -f {{.Dir}} -tags tools all
+go list -mod=vendor -f {{.Dir}} -tags tools -e all
 stdout '^'$WORK'[/\\]auto$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]printversion$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]version$'
@@ -170,7 +173,7 @@ go mod vendor
 cmp $WORK/modules-1.14.txt vendor/modules.txt
 
 # Then, -mod=vendor should kick in automatically and succeed.
-go list -f {{.Dir}} -tags tools all
+go list -f {{.Dir}} -tags tools -e all
 stdout '^'$WORK'[/\\]auto$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]printversion$'
 stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]version$'
index df4c27df816fe1b4064d900dfa23abaeb713e137..c64af2c543f18c27e066c702ecb7e69f343d8a43 100644 (file)
@@ -1,6 +1,8 @@
 # Imports
 env GO111MODULE=off
-go list -f  '{{.ImportPath}} {{.Imports}}' 'vend/...' 'vend/vendor/...' 'vend/x/vendor/...'
+
+# Pass -e to permit errors (e.g. bad.go, invalid.go)
+go list -f  '{{.ImportPath}} {{.Imports}}' -e 'vend/...' 'vend/vendor/...' 'vend/x/vendor/...'
 cmp stdout want_vendor_imports.txt
 
 -- want_vendor_imports.txt --