From: Michael Matloob Date: Mon, 30 Dec 2019 21:56:00 +0000 (-0500) Subject: cmd/go: convert TestRunInternal to the script test framework X-Git-Tag: go1.14rc1~187 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=421cefdc59fe4797a75558860964e76b4d9befbd;p=gostls13.git cmd/go: convert TestRunInternal to the script test framework This conversion is a bit weird, because the original test runs in the cmd/go directory, while the script test runs in the GOPATH directory. So even though it's not necessary for the new test, it changes dircectory to $WORK, so that its error message regexp can have four components like the original, just changing the old gopath directory 'testdata' the new one 'gopath'. Part of converting all tests to script framework to improve test parallelism. Updates #36320 Updates #17751 Change-Id: Ie5b029c43dc22167278d3104b37c0b57c61326be Reviewed-on: https://go-review.googlesource.com/c/go/+/212814 Run-TryBot: Michael Matloob TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 4efb471411..765dee17db 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1026,16 +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 TestRunInternal(t *testing.T) { - tg := testgo(t) - defer tg.cleanup() - dir := filepath.Join(tg.pwd(), "testdata") - tg.setenv("GOPATH", dir) - tg.run("run", filepath.Join(dir, "src/run/good.go")) - tg.runFail("run", filepath.Join(dir, "src/run/bad.go")) - tg.grepStderr(`testdata(\/|\\)src(\/|\\)run(\/|\\)bad\.go\:3\:8\: use of internal package run/subdir/internal/private not allowed`, "unexpected error for run/bad.go") -} - func TestRunPkg(t *testing.T) { tg := testgo(t) defer tg.cleanup() diff --git a/src/cmd/go/testdata/script/mod_run_internal.txt b/src/cmd/go/testdata/script/run_internal.txt similarity index 52% rename from src/cmd/go/testdata/script/mod_run_internal.txt rename to src/cmd/go/testdata/script/run_internal.txt index 653ad282be..d02185017b 100644 --- a/src/cmd/go/testdata/script/mod_run_internal.txt +++ b/src/cmd/go/testdata/script/run_internal.txt @@ -1,3 +1,20 @@ +env GO111MODULE=off + +go list -e -f '{{.Incomplete}}' m/runbad1.go +stdout true +! go run m/runbad1.go +stderr 'use of internal package m/x/internal not allowed' + +go list -e -f '{{.Incomplete}}' m/runbad2.go +stdout true +! go run m/runbad2.go +stderr 'use of internal package m/x/internal/y not allowed' + +go list -e -f '{{.Incomplete}}' m/runok.go +stdout false +go run m/runok.go + +cd m env GO111MODULE=on go list -e -f '{{.Incomplete}}' runbad1.go @@ -14,32 +31,33 @@ go list -e -f '{{.Incomplete}}' runok.go stdout false go run runok.go --- go.mod -- + +-- m/go.mod -- module m --- x/internal/internal.go -- +-- m/x/internal/internal.go -- package internal --- x/internal/y/y.go -- +-- m/x/internal/y/y.go -- package y --- internal/internal.go -- +-- m/internal/internal.go -- package internal --- internal/z/z.go -- +-- m/internal/z/z.go -- package z --- runbad1.go -- +-- m/runbad1.go -- package main import _ "m/x/internal" func main() {} --- runbad2.go -- +-- m/runbad2.go -- package main import _ "m/x/internal/y" func main() {} --- runok.go -- +-- m/runok.go -- package main import _ "m/internal" import _ "m/internal/z" diff --git a/src/cmd/go/testdata/src/run/bad.go b/src/cmd/go/testdata/src/run/bad.go deleted file mode 100644 index c1cc3ac6c8..0000000000 --- a/src/cmd/go/testdata/src/run/bad.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -import _ "run/subdir/internal/private" - -func main() {} diff --git a/src/cmd/go/testdata/src/run/good.go b/src/cmd/go/testdata/src/run/good.go deleted file mode 100644 index 0b67dceeee..0000000000 --- a/src/cmd/go/testdata/src/run/good.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -import _ "run/internal" - -func main() {} diff --git a/src/cmd/go/testdata/src/run/internal/internal.go b/src/cmd/go/testdata/src/run/internal/internal.go deleted file mode 100644 index 5bf0569ce8..0000000000 --- a/src/cmd/go/testdata/src/run/internal/internal.go +++ /dev/null @@ -1 +0,0 @@ -package internal diff --git a/src/cmd/go/testdata/src/run/subdir/internal/private/private.go b/src/cmd/go/testdata/src/run/subdir/internal/private/private.go deleted file mode 100644 index 735e4dc819..0000000000 --- a/src/cmd/go/testdata/src/run/subdir/internal/private/private.go +++ /dev/null @@ -1 +0,0 @@ -package private