]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestRunInternal to the script test framework
authorMichael Matloob <matloob@golang.org>
Mon, 30 Dec 2019 21:56:00 +0000 (16:56 -0500)
committerMichael Matloob <matloob@golang.org>
Fri, 3 Jan 2020 19:05:59 +0000 (19:05 +0000)
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 <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/run_internal.txt [moved from src/cmd/go/testdata/script/mod_run_internal.txt with 52% similarity]
src/cmd/go/testdata/src/run/bad.go [deleted file]
src/cmd/go/testdata/src/run/good.go [deleted file]
src/cmd/go/testdata/src/run/internal/internal.go [deleted file]
src/cmd/go/testdata/src/run/subdir/internal/private/private.go [deleted file]

index 4efb471411e040c2abb9dc9f2b7b13577710df16..765dee17dbcd72abec4cdc8bcdfe13cd0fc4febb 100644 (file)
@@ -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()
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 653ad282be1ca5f671b65979a47e80c4c66bf854..d02185017b37a750198c37b181a29679f0dbc297 100644 (file)
@@ -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 (file)
index c1cc3ac..0000000
+++ /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 (file)
index 0b67dce..0000000
+++ /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 (file)
index 5bf0569..0000000
+++ /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 (file)
index 735e4dc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package private