mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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:
parent
c4c68fb57f
commit
47cb0c46b2
102 changed files with 7 additions and 5 deletions
|
|
@ -47,8 +47,8 @@ import (
|
||||||
var (
|
var (
|
||||||
haltOnError = flag.Bool("halt", false, "halt on error")
|
haltOnError = flag.Bool("halt", false, "halt on error")
|
||||||
listErrors = flag.Bool("errlist", false, "list errors")
|
listErrors = flag.Bool("errlist", false, "list errors")
|
||||||
testFiles = flag.String("files", "", "comma-separated list of test files")
|
testFiles = flag.String("files", "", "comma-separated list of test files for TestManual")
|
||||||
goVersion = flag.String("lang", "", "Go language version (e.g. \"go1.12\"")
|
goVersion = flag.String("lang", "", "Go language version (e.g. \"go1.12\") for TestManual")
|
||||||
)
|
)
|
||||||
|
|
||||||
var fset = token.NewFileSet()
|
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.
|
// The accepted Go language version can be controlled with the -lang flag.
|
||||||
func TestCheck(t *testing.T) {
|
func TestManual(t *testing.T) {
|
||||||
if *testFiles == "" {
|
if *testFiles == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -322,13 +323,14 @@ func TestIndexRepresentability(t *testing.T) {
|
||||||
checkFiles(t, &StdSizes{4, 4}, "", []string{"index.go"}, [][]byte{[]byte(src)})
|
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 TestExamples(t *testing.T) { testDir(t, "examples") }
|
||||||
func TestFixedbugs(t *testing.T) { testDir(t, "fixedbugs") }
|
func TestFixedbugs(t *testing.T) { testDir(t, "fixedbugs") }
|
||||||
|
|
||||||
func testDir(t *testing.T, dir string) {
|
func testDir(t *testing.T, dir string) {
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
|
dir = filepath.Join("testdata", dir)
|
||||||
fis, err := os.ReadDir(dir)
|
fis, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue