mirror of
https://github.com/golang/go
synced 2024-11-17 22:54:48 -07:00
cmd/go: convert TestSymlink* to the script framework
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>
This commit is contained in:
parent
1bf9d3cc5b
commit
1331113405
@ -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)
|
||||
|
11
src/cmd/go/testdata/script/list_symlink.txt
vendored
Normal file
11
src/cmd/go/testdata/script/list_symlink.txt
vendored
Normal file
@ -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
|
26
src/cmd/go/testdata/script/list_symlink_internal.txt
vendored
Normal file
26
src/cmd/go/testdata/script/list_symlink_internal.txt
vendored
Normal file
@ -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
|
27
src/cmd/go/testdata/script/list_symlink_vendor_issue14054.txt
vendored
Normal file
27
src/cmd/go/testdata/script/list_symlink_vendor_issue14054.txt
vendored
Normal file
@ -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
|
20
src/cmd/go/testdata/script/list_symlink_vendor_issue15201.txt
vendored
Normal file
20
src/cmd/go/testdata/script/list_symlink_vendor_issue15201.txt
vendored
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user