# 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$'
# 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$'
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$'
# 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$'
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$'
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$'
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'
# 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$'
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$'
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$'