1
0
mirror of https://github.com/golang/go synced 2024-11-11 22:20:22 -07:00

go/types: nest all test data under the testdata directory

Having multiple subdirectories of go/types containing test data is
slightly problematic:
 - If ever we were to include a .go file in one of these directories,
   we'd inadvertently create a visible package.
 - It's difficult to add other content in testdata/, since TestTestdata
   scans the entire directory.

Move everything down a level, into testdata/{fixedbugs,examples,check},
and update tests accordingly.

Change-Id: Idd074c94b7b261d678934330539e41a48c2a9dc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/314829
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Rob Findley 2021-04-28 14:40:53 -04:00 committed by Robert Findley
parent c4c68fb57f
commit 47cb0c46b2
102 changed files with 7 additions and 5 deletions

View File

@ -47,8 +47,8 @@ import (
var (
haltOnError = flag.Bool("halt", false, "halt on error")
listErrors = flag.Bool("errlist", false, "list errors")
testFiles = flag.String("files", "", "comma-separated list of test files")
goVersion = flag.String("lang", "", "Go language version (e.g. \"go1.12\"")
testFiles = flag.String("files", "", "comma-separated list of test files for TestManual")
goVersion = flag.String("lang", "", "Go language version (e.g. \"go1.12\") for TestManual")
)
var fset = token.NewFileSet()
@ -297,9 +297,10 @@ func checkFiles(t *testing.T, sizes Sizes, goVersion string, filenames []string,
}
}
// TestCheck is for manual testing of selected input files, provided with -files.
// TestManual is for manual testing of selected input files, provided with
// -files.
// The accepted Go language version can be controlled with the -lang flag.
func TestCheck(t *testing.T) {
func TestManual(t *testing.T) {
if *testFiles == "" {
return
}
@ -322,13 +323,14 @@ func TestIndexRepresentability(t *testing.T) {
checkFiles(t, &StdSizes{4, 4}, "", []string{"index.go"}, [][]byte{[]byte(src)})
}
func TestTestdata(t *testing.T) { DefPredeclaredTestFuncs(); testDir(t, "testdata") }
func TestCheck(t *testing.T) { DefPredeclaredTestFuncs(); testDir(t, "check") }
func TestExamples(t *testing.T) { testDir(t, "examples") }
func TestFixedbugs(t *testing.T) { testDir(t, "fixedbugs") }
func testDir(t *testing.T, dir string) {
testenv.MustHaveGoBuild(t)
dir = filepath.Join("testdata", dir)
fis, err := os.ReadDir(dir)
if err != nil {
t.Error(err)

Some files were not shown because too many files have changed in this diff Show More