]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert some tests in vendor_test to the script framework
authorMichael Matloob <matloob@golang.org>
Mon, 6 Jan 2020 20:33:38 +0000 (15:33 -0500)
committerMichael Matloob <matloob@golang.org>
Thu, 27 Feb 2020 21:32:59 +0000 (21:32 +0000)
Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I601e0fcee32b8c5bf2107b520d1dfbe12a19ad3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/213223
Reviewed-by: Jay Conrod <jayconrod@google.com>
37 files changed:
src/cmd/go/testdata/script/build_vendor.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_vendor.txt [new file with mode: 0644]
src/cmd/go/testdata/script/run_vendor.txt [new file with mode: 0644]
src/cmd/go/testdata/script/test_vendor.txt [new file with mode: 0644]
src/cmd/go/testdata/script/vendor_gopath_issue11409.txt [new file with mode: 0644]
src/cmd/go/testdata/script/vendor_import.txt [new file with mode: 0644]
src/cmd/go/testdata/script/vendor_import_missing.txt [new file with mode: 0644]
src/cmd/go/testdata/script/vendor_import_wrong.txt [new file with mode: 0644]
src/cmd/go/testdata/script/vendor_issue12156.txt [new file with mode: 0644]
src/cmd/go/testdata/script/vendor_list_issue11977.txt [new file with mode: 0644]
src/cmd/go/testdata/script/vendor_resolve.txt [new file with mode: 0644]
src/cmd/go/testdata/script/vendor_test_issue11864.txt [new file with mode: 0644]
src/cmd/go/testdata/script/vendor_test_issue14613.txt [new file with mode: 0644]
src/cmd/go/testdata/src/vend/bad.go [deleted file]
src/cmd/go/testdata/src/vend/dir1/dir1.go [deleted file]
src/cmd/go/testdata/src/vend/good.go [deleted file]
src/cmd/go/testdata/src/vend/hello/hello.go [deleted file]
src/cmd/go/testdata/src/vend/hello/hello_test.go [deleted file]
src/cmd/go/testdata/src/vend/hello/hellox_test.go [deleted file]
src/cmd/go/testdata/src/vend/subdir/bad.go [deleted file]
src/cmd/go/testdata/src/vend/subdir/good.go [deleted file]
src/cmd/go/testdata/src/vend/vendor/p/p.go [deleted file]
src/cmd/go/testdata/src/vend/vendor/q/q.go [deleted file]
src/cmd/go/testdata/src/vend/vendor/strings/msg.go [deleted file]
src/cmd/go/testdata/src/vend/vendor/vend/dir1/dir2/dir2.go [deleted file]
src/cmd/go/testdata/src/vend/x/invalid/invalid.go [deleted file]
src/cmd/go/testdata/src/vend/x/vendor/p/p.go [deleted file]
src/cmd/go/testdata/src/vend/x/vendor/p/p/p.go [deleted file]
src/cmd/go/testdata/src/vend/x/vendor/r/r.go [deleted file]
src/cmd/go/testdata/src/vend/x/x.go [deleted file]
src/cmd/go/testdata/testvendor/src/p/p.go [deleted file]
src/cmd/go/testdata/testvendor/src/q/vendor/x/x.go [deleted file]
src/cmd/go/testdata/testvendor/src/q/y/y.go [deleted file]
src/cmd/go/testdata/testvendor/src/q/z/z.go [deleted file]
src/cmd/go/testdata/testvendor2/src/p/p.go [deleted file]
src/cmd/go/testdata/testvendor2/vendor/x/x.go [deleted file]
src/cmd/go/vendor_test.go

diff --git a/src/cmd/go/testdata/script/build_vendor.txt b/src/cmd/go/testdata/script/build_vendor.txt
new file mode 100644 (file)
index 0000000..726ecd7
--- /dev/null
@@ -0,0 +1,41 @@
+# Build
+go build vend/x
+! stdout .
+! stderr .
+
+-- vend/dir1/dir1.go --
+package dir1
+-- vend/subdir/bad.go --
+package subdir
+
+import _ "r"
+-- vend/subdir/good.go --
+package subdir
+
+import _ "p"
+-- vend/vendor/p/p.go --
+package p
+-- vend/vendor/q/q.go --
+package q
+-- vend/vendor/vend/dir1/dir2/dir2.go --
+package dir2
+-- vend/x/invalid/invalid.go --
+package invalid
+
+import "vend/x/invalid/vendor/foo"
+-- vend/x/vendor/p/p/p.go --
+package p
+
+import _ "notfound"
+-- vend/x/vendor/p/p.go --
+package p
+-- vend/x/vendor/r/r.go --
+package r
+-- vend/x/x.go --
+package x
+
+import _ "p"
+import _ "q"
+import _ "r"
+import _ "vend/dir1"      // not vendored
+import _ "vend/dir1/dir2" // vendored
diff --git a/src/cmd/go/testdata/script/get_vendor.txt b/src/cmd/go/testdata/script/get_vendor.txt
new file mode 100644 (file)
index 0000000..a6f0a70
--- /dev/null
@@ -0,0 +1,94 @@
+[short] skip
+
+cd $GOPATH/src/v
+go run m.go
+go test
+go list -f '{{.Imports}}'
+stdout 'v/vendor/vendor.org/p'
+go list -f '{{.TestImports}}'
+stdout 'v/vendor/vendor.org/p'
+go get -d
+go get -t -d
+
+[!net] stop
+[!exec:git] stop
+
+cd $GOPATH/src
+
+# Update
+go get 'github.com/rsc/go-get-issue-11864'
+go get -u 'github.com/rsc/go-get-issue-11864'
+exists github.com/rsc/go-get-issue-11864/vendor
+
+# get -u
+rm $GOPATH
+mkdir $GOPATH/src
+go get -u 'github.com/rsc/go-get-issue-11864'
+exists github.com/rsc/go-get-issue-11864/vendor
+
+# get -t -u
+rm $GOPATH
+mkdir $GOPATH/src
+go get -t -u 'github.com/rsc/go-get-issue-11864/...'
+exists github.com/rsc/go-get-issue-11864/vendor
+
+# Submodules
+rm $GOPATH
+mkdir $GOPATH/src
+go get -d 'github.com/rsc/go-get-issue-12612'
+go get -u -d 'github.com/rsc/go-get-issue-12612'
+exists github.com/rsc/go-get-issue-12612/vendor/golang.org/x/crypto/.git
+
+# Bad vendor (bad/imp)
+rm $GOPATH
+mkdir $GOPATH/src
+! go get -t -u 'github.com/rsc/go-get-issue-18219/bad/imp'
+stderr 'must be imported as'
+! exists github.com/rsc/go-get-issue-11864/vendor
+
+# Bad vendor (bad/imp2)
+rm $GOPATH
+mkdir $GOPATH/src
+! go get -t -u 'github.com/rsc/go-get-issue-18219/bad/imp2'
+stderr 'must be imported as'
+! exists github.com/rsc/go-get-issue-11864/vendor
+
+# Bad vendor (bad/imp3)
+rm $GOPATH
+mkdir $GOPATH/src
+! go get -t -u 'github.com/rsc/go-get-issue-18219/bad/imp3'
+stderr 'must be imported as'
+! exists github.com/rsc/go-get-issue-11864/vendor
+
+# Bad vendor (bad/...)
+rm $GOPATH
+mkdir $GOPATH/src
+! go get -t -u 'github.com/rsc/go-get-issue-18219/bad/...'
+stderr 'must be imported as'
+! exists github.com/rsc/go-get-issue-11864/vendor
+
+-- v/m.go --
+package main
+
+import (
+       "fmt"
+       "vendor.org/p"
+)
+
+func main() {
+       fmt.Println(p.C)
+}
+-- v/m_test.go --
+package main
+import (
+       "fmt"
+       "testing"
+       "vendor.org/p"
+)
+
+func TestNothing(t *testing.T) {
+       fmt.Println(p.C)
+}
+-- v/vendor/vendor.org/p/p.go --
+package p
+const C = 1
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/run_vendor.txt b/src/cmd/go/testdata/script/run_vendor.txt
new file mode 100644 (file)
index 0000000..8544281
--- /dev/null
@@ -0,0 +1,33 @@
+# Run
+cd vend/hello
+go run hello.go
+stdout 'hello, world'
+
+-- vend/hello/hello.go --
+package main
+
+import (
+       "fmt"
+       "strings" // really ../vendor/strings
+)
+
+func main() {
+       fmt.Printf("%s\n", strings.Msg)
+}
+-- vend/hello/hello_test.go --
+package main
+
+import (
+       "strings" // really ../vendor/strings
+       "testing"
+)
+
+func TestMsgInternal(t *testing.T) {
+       if strings.Msg != "hello, world" {
+               t.Fatalf("unexpected msg: %v", strings.Msg)
+       }
+}
+-- vend/vendor/strings/msg.go --
+package strings
+
+var Msg = "hello, world"
diff --git a/src/cmd/go/testdata/script/test_vendor.txt b/src/cmd/go/testdata/script/test_vendor.txt
new file mode 100644 (file)
index 0000000..d72d672
--- /dev/null
@@ -0,0 +1,47 @@
+# Test
+cd vend/hello
+go test -v
+stdout TestMsgInternal
+stdout TestMsgExternal
+
+-- vend/hello/hello.go --
+package main
+
+import (
+       "fmt"
+       "strings" // really ../vendor/strings
+)
+
+func main() {
+       fmt.Printf("%s\n", strings.Msg)
+}
+-- vend/hello/hello_test.go --
+package main
+
+import (
+       "strings" // really ../vendor/strings
+       "testing"
+)
+
+func TestMsgInternal(t *testing.T) {
+       if strings.Msg != "hello, world" {
+               t.Fatalf("unexpected msg: %v", strings.Msg)
+       }
+}
+-- vend/hello/hellox_test.go --
+package main_test
+
+import (
+       "strings" // really ../vendor/strings
+       "testing"
+)
+
+func TestMsgExternal(t *testing.T) {
+       if strings.Msg != "hello, world" {
+               t.Fatalf("unexpected msg: %v", strings.Msg)
+       }
+}
+-- vend/vendor/strings/msg.go --
+package strings
+
+var Msg = "hello, world"
diff --git a/src/cmd/go/testdata/script/vendor_gopath_issue11409.txt b/src/cmd/go/testdata/script/vendor_gopath_issue11409.txt
new file mode 100644 (file)
index 0000000..746a34a
--- /dev/null
@@ -0,0 +1,51 @@
+[!windows] [short] stop 'this test only applies to Windows'
+
+go build run_go.go
+exec ./run_go$GOEXE $GOPATH $GOPATH/src/vend/hello
+stdout 'hello, world'
+
+-- run_go.go --
+package main
+
+import (
+       "fmt"
+       "os"
+       "os/exec"
+       "path/filepath"
+       "strings"
+)
+
+func changeVolume(s string, f func(s string) string) string {
+       vol := filepath.VolumeName(s)
+       return f(vol) + s[len(vol):]
+}
+
+func main() {
+       gopath := changeVolume(os.Args[1], strings.ToLower)
+       dir := changeVolume(os.Args[2], strings.ToUpper)
+       cmd := exec.Command("go", "run", "hello.go")
+       cmd.Dir = dir
+       cmd.Env = append(os.Environ(), "GOPATH="+gopath)
+       cmd.Stdout = os.Stdout
+       cmd.Stderr = os.Stderr
+       if err := cmd.Run(); err != nil {
+               fmt.Fprintln(os.Stderr, err)
+               os.Exit(1)
+       }
+}
+
+-- vend/hello/hello.go --
+package main
+
+import (
+       "fmt"
+       "strings" // really ../vendor/strings
+)
+
+func main() {
+       fmt.Printf("%s\n", strings.Msg)
+}
+-- vend/vendor/strings/msg.go --
+package strings
+
+var Msg = "hello, world"
diff --git a/src/cmd/go/testdata/script/vendor_import.txt b/src/cmd/go/testdata/script/vendor_import.txt
new file mode 100644 (file)
index 0000000..35419f3
--- /dev/null
@@ -0,0 +1,103 @@
+# Imports
+go list -f  '{{.ImportPath}} {{.Imports}}' 'vend/...' 'vend/vendor/...' 'vend/x/vendor/...'
+cmp stdout want_vendor_imports.txt
+
+-- want_vendor_imports.txt --
+vend [vend/vendor/p r]
+vend/dir1 []
+vend/hello [fmt vend/vendor/strings]
+vend/subdir [vend/vendor/p r]
+vend/x [vend/x/vendor/p vend/vendor/q vend/x/vendor/r vend/dir1 vend/vendor/vend/dir1/dir2]
+vend/x/invalid [vend/x/invalid/vendor/foo]
+vend/vendor/p []
+vend/vendor/q []
+vend/vendor/strings []
+vend/vendor/vend/dir1/dir2 []
+vend/x/vendor/p []
+vend/x/vendor/p/p [notfound]
+vend/x/vendor/r []
+-- vend/bad.go --
+package vend
+
+import _ "r"
+-- vend/dir1/dir1.go --
+package dir1
+-- vend/good.go --
+package vend
+
+import _ "p"
+-- vend/hello/hello.go --
+package main
+
+import (
+       "fmt"
+       "strings" // really ../vendor/strings
+)
+
+func main() {
+       fmt.Printf("%s\n", strings.Msg)
+}
+-- vend/hello/hello_test.go --
+package main
+
+import (
+       "strings" // really ../vendor/strings
+       "testing"
+)
+
+func TestMsgInternal(t *testing.T) {
+       if strings.Msg != "hello, world" {
+               t.Fatalf("unexpected msg: %v", strings.Msg)
+       }
+}
+-- vend/hello/hellox_test.go --
+package main_test
+
+import (
+       "strings" // really ../vendor/strings
+       "testing"
+)
+
+func TestMsgExternal(t *testing.T) {
+       if strings.Msg != "hello, world" {
+               t.Fatalf("unexpected msg: %v", strings.Msg)
+       }
+}
+-- vend/subdir/bad.go --
+package subdir
+
+import _ "r"
+-- vend/subdir/good.go --
+package subdir
+
+import _ "p"
+-- vend/vendor/p/p.go --
+package p
+-- vend/vendor/q/q.go --
+package q
+-- vend/vendor/strings/msg.go --
+package strings
+
+var Msg = "hello, world"
+-- vend/vendor/vend/dir1/dir2/dir2.go --
+package dir2
+-- vend/x/invalid/invalid.go --
+package invalid
+
+import "vend/x/invalid/vendor/foo"
+-- vend/x/vendor/p/p/p.go --
+package p
+
+import _ "notfound"
+-- vend/x/vendor/p/p.go --
+package p
+-- vend/x/vendor/r/r.go --
+package r
+-- vend/x/x.go --
+package x
+
+import _ "p"
+import _ "q"
+import _ "r"
+import _ "vend/dir1"      // not vendored
+import _ "vend/dir1/dir2" // vendored
diff --git a/src/cmd/go/testdata/script/vendor_import_missing.txt b/src/cmd/go/testdata/script/vendor_import_missing.txt
new file mode 100644 (file)
index 0000000..8e50dfe
--- /dev/null
@@ -0,0 +1,7 @@
+# Missing package error message
+! go build vend/x/vendor/p/p
+
+-- vend/x/vendor/p/p/p.go --
+package p
+
+import _ "notfound"
diff --git a/src/cmd/go/testdata/script/vendor_import_wrong.txt b/src/cmd/go/testdata/script/vendor_import_wrong.txt
new file mode 100644 (file)
index 0000000..aba6269
--- /dev/null
@@ -0,0 +1,9 @@
+# Wrong import path
+! go build vend/x/invalid
+stderr 'must be imported as foo'
+
+-- vend/x/invalid/invalid.go --
+package invalid
+
+import "vend/x/invalid/vendor/foo"
+
diff --git a/src/cmd/go/testdata/script/vendor_issue12156.txt b/src/cmd/go/testdata/script/vendor_issue12156.txt
new file mode 100644 (file)
index 0000000..49eb235
--- /dev/null
@@ -0,0 +1,15 @@
+# Tests issue #12156, a former index out of range panic.
+
+env GOPATH=$WORK/gopath/src/testvendor2 # vendor/x is directly in $GOPATH, not in $GOPATH/src
+cd $WORK/gopath/src/testvendor2/src/p
+
+! go build p.go
+! stderr panic # Make sure it doesn't panic
+stderr 'cannot find package "x"'
+
+-- testvendor2/src/p/p.go --
+package p
+
+import "x"
+-- testvendor2/vendor/x/x.go --
+package x
diff --git a/src/cmd/go/testdata/script/vendor_list_issue11977.txt b/src/cmd/go/testdata/script/vendor_list_issue11977.txt
new file mode 100644 (file)
index 0000000..d97c651
--- /dev/null
@@ -0,0 +1,16 @@
+[!net] skip
+[!exec:git] skip
+
+go get github.com/rsc/go-get-issue-11864
+
+go list -f '{{join .TestImports "\n"}}' github.com/rsc/go-get-issue-11864/t
+stdout 'go-get-issue-11864/vendor/vendor.org/p'
+
+go list -f '{{join .XTestImports "\n"}}' github.com/rsc/go-get-issue-11864/tx
+stdout 'go-get-issue-11864/vendor/vendor.org/p'
+
+go list -f '{{join .XTestImports "\n"}}' github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2
+stdout 'go-get-issue-11864/vendor/vendor.org/tx2'
+
+go list -f '{{join .XTestImports "\n"}}' github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3
+stdout 'go-get-issue-11864/vendor/vendor.org/tx3'
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/vendor_resolve.txt b/src/cmd/go/testdata/script/vendor_resolve.txt
new file mode 100644 (file)
index 0000000..220b92f
--- /dev/null
@@ -0,0 +1,20 @@
+! go build p
+stderr 'must be imported as x'
+
+-- p/p.go --
+package p
+
+import (
+       _ "q/y"
+       _ "q/z"
+)
+-- q/vendor/x/x.go --
+package x
+-- q/y/y.go --
+package y
+
+import _ "x"
+-- q/z/z.go --
+package z
+
+import _ "q/vendor/x"
diff --git a/src/cmd/go/testdata/script/vendor_test_issue11864.txt b/src/cmd/go/testdata/script/vendor_test_issue11864.txt
new file mode 100644 (file)
index 0000000..f11d790
--- /dev/null
@@ -0,0 +1,19 @@
+[!net] skip
+[!exec:git] skip
+
+go get github.com/rsc/go-get-issue-11864
+
+# build -i should work
+go build -i github.com/rsc/go-get-issue-11864
+go build -i github.com/rsc/go-get-issue-11864/t
+
+# test -i should work like build -i (golang.org/issue/11988)
+go test -i github.com/rsc/go-get-issue-11864
+go test -i github.com/rsc/go-get-issue-11864/t
+
+# test should work too
+go test github.com/rsc/go-get-issue-11864
+go test github.com/rsc/go-get-issue-11864/t
+
+# external tests should observe internal test exports (golang.org/issue/11977)
+go test github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/vendor_test_issue14613.txt b/src/cmd/go/testdata/script/vendor_test_issue14613.txt
new file mode 100644 (file)
index 0000000..4e5e066
--- /dev/null
@@ -0,0 +1,21 @@
+[!net] skip
+[!exec:git] skip
+
+cd $GOPATH
+
+go get github.com/clsung/go-vendor-issue-14613
+go build -o $WORK/a.out -i github.com/clsung/go-vendor-issue-14613
+
+# test folder should work
+go test -i github.com/clsung/go-vendor-issue-14613
+go test github.com/clsung/go-vendor-issue-14613
+
+# test with specified _test.go should work too
+cd $GOPATH/src
+go test -i github.com/clsung/go-vendor-issue-14613/vendor_test.go
+go test github.com/clsung/go-vendor-issue-14613/vendor_test.go
+
+# test with imported and not used
+go test -i github.com/clsung/go-vendor-issue-14613/vendor/mylibtesttest/myapp/myapp_test.go
+! go test github.com/clsung/go-vendor-issue-14613/vendor/mylibtesttest/myapp/myapp_test.go
+stderr 'imported and not used:'
diff --git a/src/cmd/go/testdata/src/vend/bad.go b/src/cmd/go/testdata/src/vend/bad.go
deleted file mode 100644 (file)
index 57cc595..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package vend
-
-import _ "r"
diff --git a/src/cmd/go/testdata/src/vend/dir1/dir1.go b/src/cmd/go/testdata/src/vend/dir1/dir1.go
deleted file mode 100644 (file)
index b719ead..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package dir1
diff --git a/src/cmd/go/testdata/src/vend/good.go b/src/cmd/go/testdata/src/vend/good.go
deleted file mode 100644 (file)
index 952ada3..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package vend
-
-import _ "p"
diff --git a/src/cmd/go/testdata/src/vend/hello/hello.go b/src/cmd/go/testdata/src/vend/hello/hello.go
deleted file mode 100644 (file)
index 41dc03e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package main
-
-import (
-       "fmt"
-       "strings" // really ../vendor/strings
-)
-
-func main() {
-       fmt.Printf("%s\n", strings.Msg)
-}
diff --git a/src/cmd/go/testdata/src/vend/hello/hello_test.go b/src/cmd/go/testdata/src/vend/hello/hello_test.go
deleted file mode 100644 (file)
index 7190f59..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package main
-
-import (
-       "strings" // really ../vendor/strings
-       "testing"
-)
-
-func TestMsgInternal(t *testing.T) {
-       if strings.Msg != "hello, world" {
-               t.Fatalf("unexpected msg: %v", strings.Msg)
-       }
-}
diff --git a/src/cmd/go/testdata/src/vend/hello/hellox_test.go b/src/cmd/go/testdata/src/vend/hello/hellox_test.go
deleted file mode 100644 (file)
index 3f2165b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package main_test
-
-import (
-       "strings" // really ../vendor/strings
-       "testing"
-)
-
-func TestMsgExternal(t *testing.T) {
-       if strings.Msg != "hello, world" {
-               t.Fatalf("unexpected msg: %v", strings.Msg)
-       }
-}
diff --git a/src/cmd/go/testdata/src/vend/subdir/bad.go b/src/cmd/go/testdata/src/vend/subdir/bad.go
deleted file mode 100644 (file)
index d0ddaac..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package subdir
-
-import _ "r"
diff --git a/src/cmd/go/testdata/src/vend/subdir/good.go b/src/cmd/go/testdata/src/vend/subdir/good.go
deleted file mode 100644 (file)
index edd0454..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package subdir
-
-import _ "p"
diff --git a/src/cmd/go/testdata/src/vend/vendor/p/p.go b/src/cmd/go/testdata/src/vend/vendor/p/p.go
deleted file mode 100644 (file)
index c89cd18..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package p
diff --git a/src/cmd/go/testdata/src/vend/vendor/q/q.go b/src/cmd/go/testdata/src/vend/vendor/q/q.go
deleted file mode 100644 (file)
index 946e6d9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package q
diff --git a/src/cmd/go/testdata/src/vend/vendor/strings/msg.go b/src/cmd/go/testdata/src/vend/vendor/strings/msg.go
deleted file mode 100644 (file)
index 438126b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package strings
-
-var Msg = "hello, world"
diff --git a/src/cmd/go/testdata/src/vend/vendor/vend/dir1/dir2/dir2.go b/src/cmd/go/testdata/src/vend/vendor/vend/dir1/dir2/dir2.go
deleted file mode 100644 (file)
index 6fe35e9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package dir2
diff --git a/src/cmd/go/testdata/src/vend/x/invalid/invalid.go b/src/cmd/go/testdata/src/vend/x/invalid/invalid.go
deleted file mode 100644 (file)
index e250d5b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package invalid
-
-import "vend/x/invalid/vendor/foo"
diff --git a/src/cmd/go/testdata/src/vend/x/vendor/p/p.go b/src/cmd/go/testdata/src/vend/x/vendor/p/p.go
deleted file mode 100644 (file)
index c89cd18..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package p
diff --git a/src/cmd/go/testdata/src/vend/x/vendor/p/p/p.go b/src/cmd/go/testdata/src/vend/x/vendor/p/p/p.go
deleted file mode 100644 (file)
index e12e12c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package p
-
-import _ "notfound"
diff --git a/src/cmd/go/testdata/src/vend/x/vendor/r/r.go b/src/cmd/go/testdata/src/vend/x/vendor/r/r.go
deleted file mode 100644 (file)
index 838c177..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package r
diff --git a/src/cmd/go/testdata/src/vend/x/x.go b/src/cmd/go/testdata/src/vend/x/x.go
deleted file mode 100644 (file)
index bdcde57..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package x
-
-import _ "p"
-import _ "q"
-import _ "r"
-import _ "vend/dir1"      // not vendored
-import _ "vend/dir1/dir2" // vendored
diff --git a/src/cmd/go/testdata/testvendor/src/p/p.go b/src/cmd/go/testdata/testvendor/src/p/p.go
deleted file mode 100644 (file)
index e740715..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package p
-
-import (
-       _ "q/y"
-       _ "q/z"
-)
diff --git a/src/cmd/go/testdata/testvendor/src/q/vendor/x/x.go b/src/cmd/go/testdata/testvendor/src/q/vendor/x/x.go
deleted file mode 100644 (file)
index 823aafd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package x
diff --git a/src/cmd/go/testdata/testvendor/src/q/y/y.go b/src/cmd/go/testdata/testvendor/src/q/y/y.go
deleted file mode 100644 (file)
index 4f84223..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package y
-
-import _ "x"
diff --git a/src/cmd/go/testdata/testvendor/src/q/z/z.go b/src/cmd/go/testdata/testvendor/src/q/z/z.go
deleted file mode 100644 (file)
index a8d4924..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package z
-
-import _ "q/vendor/x"
diff --git a/src/cmd/go/testdata/testvendor2/src/p/p.go b/src/cmd/go/testdata/testvendor2/src/p/p.go
deleted file mode 100644 (file)
index 220b2b2..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package p
-
-import "x"
diff --git a/src/cmd/go/testdata/testvendor2/vendor/x/x.go b/src/cmd/go/testdata/testvendor2/vendor/x/x.go
deleted file mode 100644 (file)
index 823aafd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package x
index 8b67de06ca628f218e4725d65af95b244a51312a..9d568b906a91e6d727b861027346323d25b692dd 100644 (file)
 package main_test
 
 import (
-       "bytes"
-       "fmt"
        "internal/testenv"
        "os"
-       "path/filepath"
-       "regexp"
-       "strings"
        "testing"
 )
 
-func TestVendorImports(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-       tg.run("list", "-f", "{{.ImportPath}} {{.Imports}}", "vend/...", "vend/vendor/...", "vend/x/vendor/...")
-       want := `
-               vend [vend/vendor/p r]
-               vend/dir1 []
-               vend/hello [fmt vend/vendor/strings]
-               vend/subdir [vend/vendor/p r]
-               vend/x [vend/x/vendor/p vend/vendor/q vend/x/vendor/r vend/dir1 vend/vendor/vend/dir1/dir2]
-               vend/x/invalid [vend/x/invalid/vendor/foo]
-               vend/vendor/p []
-               vend/vendor/q []
-               vend/vendor/strings []
-               vend/vendor/vend/dir1/dir2 []
-               vend/x/vendor/p []
-               vend/x/vendor/p/p [notfound]
-               vend/x/vendor/r []
-       `
-       want = strings.ReplaceAll(want+"\t", "\n\t\t", "\n")
-       want = strings.TrimPrefix(want, "\n")
-
-       have := tg.stdout.String()
-
-       if have != want {
-               t.Errorf("incorrect go list output:\n%s", diffSortedOutputs(have, want))
-       }
-}
-
-func TestVendorBuild(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-       tg.run("build", "vend/x")
-}
-
-func TestVendorRun(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-       tg.cd(filepath.Join(tg.pwd(), "testdata/src/vend/hello"))
-       tg.run("run", "hello.go")
-       tg.grepStdout("hello, world", "missing hello world output")
-}
-
-func TestVendorGOPATH(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       changeVolume := func(s string, f func(s string) string) string {
-               vol := filepath.VolumeName(s)
-               return f(vol) + s[len(vol):]
-       }
-       gopath := changeVolume(filepath.Join(tg.pwd(), "testdata"), strings.ToLower)
-       tg.setenv("GOPATH", gopath)
-       cd := changeVolume(filepath.Join(tg.pwd(), "testdata/src/vend/hello"), strings.ToUpper)
-       tg.cd(cd)
-       tg.run("run", "hello.go")
-       tg.grepStdout("hello, world", "missing hello world output")
-}
-
-func TestVendorTest(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-       tg.cd(filepath.Join(tg.pwd(), "testdata/src/vend/hello"))
-       tg.run("test", "-v")
-       tg.grepStdout("TestMsgInternal", "missing use in internal test")
-       tg.grepStdout("TestMsgExternal", "missing use in external test")
-}
-
-func TestVendorInvalid(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-
-       tg.runFail("build", "vend/x/invalid")
-       tg.grepStderr("must be imported as foo", "missing vendor import error")
-}
-
-func TestVendorImportError(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-
-       tg.runFail("build", "vend/x/vendor/p/p")
-
-       re := regexp.MustCompile(`cannot find package "notfound" in any of:
-       .*[\\/]testdata[\\/]src[\\/]vend[\\/]x[\\/]vendor[\\/]notfound \(vendor tree\)
-       .*[\\/]testdata[\\/]src[\\/]vend[\\/]vendor[\\/]notfound
-       .*[\\/]src[\\/]notfound \(from \$GOROOT\)
-       .*[\\/]testdata[\\/]src[\\/]notfound \(from \$GOPATH\)`)
-
-       if !re.MatchString(tg.stderr.String()) {
-               t.Errorf("did not find expected search list in error text")
-       }
-}
-
-// diffSortedOutput prepares a diff of the already sorted outputs haveText and wantText.
-// The diff shows common lines prefixed by a tab, lines present only in haveText
-// prefixed by "unexpected: ", and lines present only in wantText prefixed by "missing: ".
-func diffSortedOutputs(haveText, wantText string) string {
-       var diff bytes.Buffer
-       have := splitLines(haveText)
-       want := splitLines(wantText)
-       for len(have) > 0 || len(want) > 0 {
-               if len(want) == 0 || len(have) > 0 && have[0] < want[0] {
-                       fmt.Fprintf(&diff, "unexpected: %s\n", have[0])
-                       have = have[1:]
-                       continue
-               }
-               if len(have) == 0 || len(want) > 0 && want[0] < have[0] {
-                       fmt.Fprintf(&diff, "missing: %s\n", want[0])
-                       want = want[1:]
-                       continue
-               }
-               fmt.Fprintf(&diff, "\t%s\n", want[0])
-               want = want[1:]
-               have = have[1:]
-       }
-       return diff.String()
-}
-
-func splitLines(s string) []string {
-       x := strings.Split(s, "\n")
-       if x[len(x)-1] == "" {
-               x = x[:len(x)-1]
-       }
-       return x
-}
-
-func TestVendorGet(t *testing.T) {
-       tooSlow(t)
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.tempFile("src/v/m.go", `
-               package main
-               import ("fmt"; "vendor.org/p")
-               func main() {
-                       fmt.Println(p.C)
-               }`)
-       tg.tempFile("src/v/m_test.go", `
-               package main
-               import ("fmt"; "testing"; "vendor.org/p")
-               func TestNothing(t *testing.T) {
-                       fmt.Println(p.C)
-               }`)
-       tg.tempFile("src/v/vendor/vendor.org/p/p.go", `
-               package p
-               const C = 1`)
-       tg.setenv("GOPATH", tg.path("."))
-       tg.cd(tg.path("src/v"))
-       tg.run("run", "m.go")
-       tg.run("test")
-       tg.run("list", "-f", "{{.Imports}}")
-       tg.grepStdout("v/vendor/vendor.org/p", "import not in vendor directory")
-       tg.run("list", "-f", "{{.TestImports}}")
-       tg.grepStdout("v/vendor/vendor.org/p", "test import not in vendor directory")
-       tg.run("get", "-d")
-       tg.run("get", "-t", "-d")
-}
-
-func TestVendorGetUpdate(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "github.com/rsc/go-get-issue-11864")
-       tg.run("get", "-u", "github.com/rsc/go-get-issue-11864")
-}
-
-func TestVendorGetU(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "-u", "github.com/rsc/go-get-issue-11864")
-}
-
-func TestVendorGetTU(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "-t", "-u", "github.com/rsc/go-get-issue-11864/...")
-}
-
-func TestVendorGetBadVendor(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       for _, suffix := range []string{"bad/imp", "bad/imp2", "bad/imp3", "..."} {
-               t.Run(suffix, func(t *testing.T) {
-                       tg := testgo(t)
-                       defer tg.cleanup()
-                       tg.makeTempdir()
-                       tg.setenv("GOPATH", tg.path("."))
-                       tg.runFail("get", "-t", "-u", "github.com/rsc/go-get-issue-18219/"+suffix)
-                       tg.grepStderr("must be imported as", "did not find error about vendor import")
-                       tg.mustNotExist(tg.path("src/github.com/rsc/vendor"))
-               })
-       }
-}
-
-func TestGetSubmodules(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "-d", "github.com/rsc/go-get-issue-12612")
-       tg.run("get", "-u", "-d", "github.com/rsc/go-get-issue-12612")
-       tg.mustExist(tg.path("src/github.com/rsc/go-get-issue-12612/vendor/golang.org/x/crypto/.git"))
-}
-
-func TestVendorCache(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/testvendor"))
-       tg.runFail("build", "p")
-       tg.grepStderr("must be imported as x", "did not fail to build p")
-}
-
-func TestVendorTest2(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "github.com/rsc/go-get-issue-11864")
-
-       // build -i should work
-       tg.run("build", "-i", "github.com/rsc/go-get-issue-11864")
-       tg.run("build", "-i", "github.com/rsc/go-get-issue-11864/t")
-
-       // test -i should work like build -i (golang.org/issue/11988)
-       tg.run("test", "-i", "github.com/rsc/go-get-issue-11864")
-       tg.run("test", "-i", "github.com/rsc/go-get-issue-11864/t")
-
-       // test should work too
-       tg.run("test", "github.com/rsc/go-get-issue-11864")
-       tg.run("test", "github.com/rsc/go-get-issue-11864/t")
-
-       // external tests should observe internal test exports (golang.org/issue/11977)
-       tg.run("test", "github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2")
-}
-
-func TestVendorTest3(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "github.com/clsung/go-vendor-issue-14613")
-
-       tg.run("build", "-o", tg.path("a.out"), "-i", "github.com/clsung/go-vendor-issue-14613")
-
-       // test folder should work
-       tg.run("test", "-i", "github.com/clsung/go-vendor-issue-14613")
-       tg.run("test", "github.com/clsung/go-vendor-issue-14613")
-
-       // test with specified _test.go should work too
-       tg.cd(filepath.Join(tg.path("."), "src"))
-       tg.run("test", "-i", "github.com/clsung/go-vendor-issue-14613/vendor_test.go")
-       tg.run("test", "github.com/clsung/go-vendor-issue-14613/vendor_test.go")
-
-       // test with imported and not used
-       tg.run("test", "-i", "github.com/clsung/go-vendor-issue-14613/vendor/mylibtesttest/myapp/myapp_test.go")
-       tg.runFail("test", "github.com/clsung/go-vendor-issue-14613/vendor/mylibtesttest/myapp/myapp_test.go")
-       tg.grepStderr("imported and not used:", `should say "imported and not used"`)
-}
-
-func TestVendorList(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "github.com/rsc/go-get-issue-11864")
-
-       tg.run("list", "-f", `{{join .TestImports "\n"}}`, "github.com/rsc/go-get-issue-11864/t")
-       tg.grepStdout("go-get-issue-11864/vendor/vendor.org/p", "did not find vendor-expanded p")
-
-       tg.run("list", "-f", `{{join .XTestImports "\n"}}`, "github.com/rsc/go-get-issue-11864/tx")
-       tg.grepStdout("go-get-issue-11864/vendor/vendor.org/p", "did not find vendor-expanded p")
-
-       tg.run("list", "-f", `{{join .XTestImports "\n"}}`, "github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2")
-       tg.grepStdout("go-get-issue-11864/vendor/vendor.org/tx2", "did not find vendor-expanded tx2")
-
-       tg.run("list", "-f", `{{join .XTestImports "\n"}}`, "github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3")
-       tg.grepStdout("go-get-issue-11864/vendor/vendor.org/tx3", "did not find vendor-expanded tx3")
-}
-
-func TestVendor12156(t *testing.T) {
-       // Former index out of range panic.
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/testvendor2"))
-       tg.cd(filepath.Join(tg.pwd(), "testdata/testvendor2/src/p"))
-       tg.runFail("build", "p.go")
-       tg.grepStderrNot("panic", "panicked")
-       tg.grepStderr(`cannot find package "x"`, "wrong error")
-}
-
-// Module legacy support does path rewriting very similar to vendoring.
-
-func TestLegacyMod(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/modlegacy"))
-       tg.run("list", "-f", "{{.Imports}}", "old/p1")
-       tg.grepStdout("new/p1", "old/p1 should import new/p1")
-       tg.run("list", "-f", "{{.Imports}}", "new/p1")
-       tg.grepStdout("new/p2", "new/p1 should import new/p2 (not new/v2/p2)")
-       tg.grepStdoutNot("new/v2", "new/p1 should NOT import new/v2*")
-       tg.grepStdout("new/sub/x/v1/y", "new/p1 should import new/sub/x/v1/y (not new/sub/v2/x/v1/y)")
-       tg.grepStdoutNot("new/sub/v2", "new/p1 should NOT import new/sub/v2*")
-       tg.grepStdout("new/sub/inner/x", "new/p1 should import new/sub/inner/x (no rewrites)")
-       tg.run("build", "old/p1", "new/p1")
-}
-
 func TestLegacyModGet(t *testing.T) {
        testenv.MustHaveExternalNetwork(t)
        testenv.MustHaveExecPath(t, "git")