]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestSymlink* to the script framework
authorMichael Matloob <matloob@golang.org>
Fri, 10 Jan 2020 17:57:19 +0000 (12:57 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 19 Feb 2020 21:00:15 +0000 (21:00 +0000)
Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I0696fa54184514d69c0763ac772d99b12e133eb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/214288
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/list_symlink.txt [new file with mode: 0644]
src/cmd/go/testdata/script/list_symlink_internal.txt [new file with mode: 0644]
src/cmd/go/testdata/script/list_symlink_vendor_issue14054.txt [new file with mode: 0644]
src/cmd/go/testdata/script/list_symlink_vendor_issue15201.txt [new file with mode: 0644]

index fed6487357201942a14ffacf066a9588ab6bcc7a..35571a75468075002b16100d64ed8524fd789f6f 100644 (file)
@@ -1565,88 +1565,6 @@ func TestGoTestDashIDashOWritesBinary(t *testing.T) {
        tg.wantExecutable(tg.path("myerrors.test"+exeSuffix), "go test -o myerrors.test did not create myerrors.test")
 }
 
-// Issue 4568.
-func TestSymlinksList(t *testing.T) {
-       testenv.MustHaveSymlink(t)
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       // TODO: tg.parallel()
-       tg.tempDir("src")
-       tg.must(os.Symlink(tg.path("."), tg.path("src/dir1")))
-       tg.tempFile("src/dir1/p.go", "package p")
-       tg.setenv("GOPATH", tg.path("."))
-       tg.cd(tg.path("src"))
-       tg.run("list", "-f", "{{.Root}}", "dir1")
-       if strings.TrimSpace(tg.getStdout()) != tg.path(".") {
-               t.Error("confused by symlinks")
-       }
-}
-
-// Issue 14054.
-func TestSymlinksVendor(t *testing.T) {
-       testenv.MustHaveSymlink(t)
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       // TODO: tg.parallel()
-       tg.tempDir("gopath/src/dir1/vendor/v")
-       tg.tempFile("gopath/src/dir1/p.go", "package main\nimport _ `v`\nfunc main(){}")
-       tg.tempFile("gopath/src/dir1/vendor/v/v.go", "package v")
-       tg.must(os.Symlink(tg.path("gopath/src/dir1"), tg.path("symdir1")))
-       tg.setenv("GOPATH", tg.path("gopath"))
-       tg.cd(tg.path("symdir1"))
-       tg.run("list", "-f", "{{.Root}}", ".")
-       if strings.TrimSpace(tg.getStdout()) != tg.path("gopath") {
-               t.Error("list confused by symlinks")
-       }
-
-       // All of these should succeed, not die in vendor-handling code.
-       tg.run("run", "p.go")
-       tg.run("build")
-       tg.run("install")
-}
-
-// Issue 15201.
-func TestSymlinksVendor15201(t *testing.T) {
-       testenv.MustHaveSymlink(t)
-
-       tg := testgo(t)
-       defer tg.cleanup()
-
-       tg.tempDir("gopath/src/x/y/_vendor/src/x")
-       tg.must(os.Symlink("../../..", tg.path("gopath/src/x/y/_vendor/src/x/y")))
-       tg.tempFile("gopath/src/x/y/w/w.go", "package w\nimport \"x/y/z\"\n")
-       tg.must(os.Symlink("../_vendor/src", tg.path("gopath/src/x/y/w/vendor")))
-       tg.tempFile("gopath/src/x/y/z/z.go", "package z\n")
-
-       tg.setenv("GOPATH", tg.path("gopath/src/x/y/_vendor")+string(filepath.ListSeparator)+tg.path("gopath"))
-       tg.cd(tg.path("gopath/src"))
-       tg.run("list", "./...")
-}
-
-func TestSymlinksInternal(t *testing.T) {
-       testenv.MustHaveSymlink(t)
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.tempDir("gopath/src/dir1/internal/v")
-       tg.tempFile("gopath/src/dir1/p.go", "package main\nimport _ `dir1/internal/v`\nfunc main(){}")
-       tg.tempFile("gopath/src/dir1/internal/v/v.go", "package v")
-       tg.must(os.Symlink(tg.path("gopath/src/dir1"), tg.path("symdir1")))
-       tg.setenv("GOPATH", tg.path("gopath"))
-       tg.cd(tg.path("symdir1"))
-       tg.run("list", "-f", "{{.Root}}", ".")
-       if strings.TrimSpace(tg.getStdout()) != tg.path("gopath") {
-               t.Error("list confused by symlinks")
-       }
-
-       // All of these should succeed, not die in internal-handling code.
-       tg.run("run", "p.go")
-       tg.run("build")
-       tg.run("install")
-}
-
 // Issue 4515.
 func TestInstallWithTags(t *testing.T) {
        tooSlow(t)
diff --git a/src/cmd/go/testdata/script/list_symlink.txt b/src/cmd/go/testdata/script/list_symlink.txt
new file mode 100644 (file)
index 0000000..20c85b6
--- /dev/null
@@ -0,0 +1,11 @@
+[!symlink] skip
+
+mkdir $WORK/tmp/src
+symlink $WORK/tmp/src/dir1 -> $WORK/tmp
+cp p.go $WORK/tmp/src/dir1/p.go
+env GOPATH=$WORK/tmp
+go list -f '{{.Root}}' dir1
+stdout '^'$WORK/tmp'$'
+
+-- p.go --
+package p
diff --git a/src/cmd/go/testdata/script/list_symlink_internal.txt b/src/cmd/go/testdata/script/list_symlink_internal.txt
new file mode 100644 (file)
index 0000000..e538072
--- /dev/null
@@ -0,0 +1,26 @@
+[!symlink] skip
+
+mkdir $WORK/tmp/gopath/src/dir1/internal/v
+cp p.go $WORK/tmp/gopath/src/dir1/p.go
+cp v.go $WORK/tmp/gopath/src/dir1/internal/v/v.go
+symlink $WORK/tmp/symdir1 -> $WORK/tmp/gopath/src/dir1
+env GOPATH=$WORK/tmp/gopath
+cd $WORK/tmp/symdir1
+go list -f '{{.Root}}' .
+stdout '^'$WORK/tmp/gopath'$'
+
+# All of these should succeed, not die in internal-handling code.
+go run p.go &
+go build &
+go install &
+
+wait
+
+-- p.go --
+package main
+
+import _ `dir1/internal/v`
+
+func main() {}
+-- v.go --
+package v
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/list_symlink_vendor_issue14054.txt b/src/cmd/go/testdata/script/list_symlink_vendor_issue14054.txt
new file mode 100644 (file)
index 0000000..68b7fd9
--- /dev/null
@@ -0,0 +1,27 @@
+[!symlink] skip
+
+mkdir $WORK/tmp/gopath/src/dir1/vendor/v
+cp p.go $WORK/tmp/gopath/src/dir1/p.go
+cp v.go $WORK/tmp/gopath/src/dir1/vendor/v/v.go
+symlink $WORK/tmp/symdir1 -> $WORK/tmp/gopath/src/dir1
+env GOPATH=$WORK/tmp/gopath
+cd $WORK/tmp/symdir1
+
+go list -f '{{.Root}}' .
+stdout '^'$WORK/tmp/gopath'$'
+
+# All of these should succeed, not die in vendor-handling code.
+go run p.go &
+go build &
+go install &
+
+wait
+
+-- p.go --
+package main
+
+import _ `v`
+
+func main () {}
+-- v.go --
+package v
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/list_symlink_vendor_issue15201.txt b/src/cmd/go/testdata/script/list_symlink_vendor_issue15201.txt
new file mode 100644 (file)
index 0000000..9892161
--- /dev/null
@@ -0,0 +1,20 @@
+[!symlink] skip
+
+mkdir $WORK/tmp/gopath/src/x/y/_vendor/src/x
+symlink $WORK/tmp/gopath/src/x/y/_vendor/src/x/y -> ../../..
+mkdir $WORK/tmp/gopath/src/x/y/_vendor/src/x/y/w
+cp w.go $WORK/tmp/gopath/src/x/y/w/w.go
+symlink $WORK/tmp/gopath/src/x/y/w/vendor -> ../_vendor/src
+mkdir $WORK/tmp/gopath/src/x/y/_vendor/src/x/y/z
+cp z.go $WORK/tmp/gopath/src/x/y/z/z.go
+
+env GOPATH=$WORK/tmp/gopath/src/x/y/_vendor${:}$WORK/tmp/gopath
+cd $WORK/tmp/gopath/src
+go list ./...
+
+-- w.go --
+package w
+
+import "x/y/z"
+-- z.go --
+package z
\ No newline at end of file