Skip to content

Commit 421cefd

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent c57665f commit 421cefd

File tree

6 files changed

+26
-30
lines changed

6 files changed

+26
-30
lines changed

src/cmd/go/go_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,16 +1026,6 @@ func TestInternalPackagesOutsideGOROOTAreRespected(t *testing.T) {
10261026
tg.grepBoth(`testinternal2(\/|\\)p\.go\:3\:8\: use of internal package .*internal/w not allowed`, "wrote error message for testdata/testinternal2")
10271027
}
10281028

1029-
func TestRunInternal(t *testing.T) {
1030-
tg := testgo(t)
1031-
defer tg.cleanup()
1032-
dir := filepath.Join(tg.pwd(), "testdata")
1033-
tg.setenv("GOPATH", dir)
1034-
tg.run("run", filepath.Join(dir, "src/run/good.go"))
1035-
tg.runFail("run", filepath.Join(dir, "src/run/bad.go"))
1036-
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")
1037-
}
1038-
10391029
func TestRunPkg(t *testing.T) {
10401030
tg := testgo(t)
10411031
defer tg.cleanup()

src/cmd/go/testdata/script/mod_run_internal.txt renamed to src/cmd/go/testdata/script/run_internal.txt

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
env GO111MODULE=off
2+
3+
go list -e -f '{{.Incomplete}}' m/runbad1.go
4+
stdout true
5+
! go run m/runbad1.go
6+
stderr 'use of internal package m/x/internal not allowed'
7+
8+
go list -e -f '{{.Incomplete}}' m/runbad2.go
9+
stdout true
10+
! go run m/runbad2.go
11+
stderr 'use of internal package m/x/internal/y not allowed'
12+
13+
go list -e -f '{{.Incomplete}}' m/runok.go
14+
stdout false
15+
go run m/runok.go
16+
17+
cd m
118
env GO111MODULE=on
219

320
go list -e -f '{{.Incomplete}}' runbad1.go
@@ -14,32 +31,33 @@ go list -e -f '{{.Incomplete}}' runok.go
1431
stdout false
1532
go run runok.go
1633

17-
-- go.mod --
34+
35+
-- m/go.mod --
1836
module m
1937

20-
-- x/internal/internal.go --
38+
-- m/x/internal/internal.go --
2139
package internal
2240

23-
-- x/internal/y/y.go --
41+
-- m/x/internal/y/y.go --
2442
package y
2543

26-
-- internal/internal.go --
44+
-- m/internal/internal.go --
2745
package internal
2846

29-
-- internal/z/z.go --
47+
-- m/internal/z/z.go --
3048
package z
3149

32-
-- runbad1.go --
50+
-- m/runbad1.go --
3351
package main
3452
import _ "m/x/internal"
3553
func main() {}
3654

37-
-- runbad2.go --
55+
-- m/runbad2.go --
3856
package main
3957
import _ "m/x/internal/y"
4058
func main() {}
4159

42-
-- runok.go --
60+
-- m/runok.go --
4361
package main
4462
import _ "m/internal"
4563
import _ "m/internal/z"

src/cmd/go/testdata/src/run/bad.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/cmd/go/testdata/src/run/good.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/cmd/go/testdata/src/run/internal/internal.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/cmd/go/testdata/src/run/subdir/internal/private/private.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)