From cf7a46c1da8ff0619f60231a72de254c4c2e44b0 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Mon, 30 Dec 2019 14:55:57 -0500 Subject: [PATCH] cmd/go: convert TestRunPkg to the script framework 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 Reviewed-by: Jay Conrod --- src/cmd/go/go_test.go | 12 ------------ src/cmd/go/testdata/script/run_hello_pkg.txt | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 src/cmd/go/testdata/script/run_hello_pkg.txt diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 7d37f512bf..364186ff53 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -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 index 0000000000..03fba13c77 --- /dev/null +++ b/src/cmd/go/testdata/script/run_hello_pkg.txt @@ -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") +} -- 2.48.1