]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestRunPkg to the script framework
authorMichael Matloob <matloob@golang.org>
Mon, 30 Dec 2019 19:55:57 +0000 (14:55 -0500)
committerMichael Matloob <matloob@golang.org>
Mon, 6 Jan 2020 16:22:05 +0000 (16:22 +0000)
Part of the effort to convert all non-parallel cmd/go tests to the script
framework.

Updates #17751
Updates #36320

Change-Id: I2bc0b1e5c03e2c49b5c79ac24a908a202840d5d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/212879
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/run_hello_pkg.txt [new file with mode: 0644]

index 7d37f512bf50e9c68ae68cc6745257f772820f35..364186ff53fb2b577c6443f733c372f43323fa12 100644 (file)
@@ -1026,18 +1026,6 @@ func TestInternalPackagesOutsideGOROOTAreRespected(t *testing.T) {
        tg.grepBoth(`testinternal2(\/|\\)p\.go\:3\:8\: use of internal package .*internal/w not allowed`, "wrote error message for testdata/testinternal2")
 }
 
-func TestRunPkg(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       dir := filepath.Join(tg.pwd(), "testdata")
-       tg.setenv("GOPATH", dir)
-       tg.run("run", "hello")
-       tg.grepStderr("hello, world", "did not find hello, world")
-       tg.cd(filepath.Join(dir, "src/hello"))
-       tg.run("run", ".")
-       tg.grepStderr("hello, world", "did not find hello, world")
-}
-
 func TestInternalPackageErrorsAreHandled(t *testing.T) {
        tg := testgo(t)
        defer tg.cleanup()
diff --git a/src/cmd/go/testdata/script/run_hello_pkg.txt b/src/cmd/go/testdata/script/run_hello_pkg.txt
new file mode 100644 (file)
index 0000000..03fba13
--- /dev/null
@@ -0,0 +1,14 @@
+cd $GOPATH
+go run hello
+stderr 'hello, world'
+
+cd src/hello
+go run .
+stderr 'hello, world'
+
+-- hello/hello.go --
+package main
+
+func main() {
+       println("hello, world")
+}