From 234e37bcda2b5efdd685ad11d1bb3d336415648e Mon Sep 17 00:00:00 2001 From: Rob Findley Date: Tue, 11 Aug 2020 13:21:14 -0400 Subject: [PATCH] go/types: remove need to enumerate fixedbugs test files This is a port of CL 244628, updated to move some existing regression tests into the fixedbugs directory, and to use subtests. Also, 'TestFixed' is renamed to 'TestFixedBugs'. Change-Id: I43aac3f75f2bd850567d08e8b008d91aeb717064 Reviewed-on: https://go-review.googlesource.com/c/go/+/247904 Run-TryBot: Robert Findley TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- src/go/types/check_test.go | 32 +++++++++++++++---- .../{testdata => fixedbugs}/issue23203a.src | 0 .../{testdata => fixedbugs}/issue23203b.src | 0 .../{testdata => fixedbugs}/issue26390.src | 2 ++ .../{testdata => fixedbugs}/issue28251.src | 0 .../{testdata => fixedbugs}/issue6977.src | 0 6 files changed, 28 insertions(+), 6 deletions(-) rename src/go/types/{testdata => fixedbugs}/issue23203a.src (100%) rename src/go/types/{testdata => fixedbugs}/issue23203b.src (100%) rename src/go/types/{testdata => fixedbugs}/issue26390.src (83%) rename src/go/types/{testdata => fixedbugs}/issue28251.src (100%) rename src/go/types/{testdata => fixedbugs}/issue6977.src (100%) diff --git a/src/go/types/check_test.go b/src/go/types/check_test.go index 89122d75ff..e01c3de13b 100644 --- a/src/go/types/check_test.go +++ b/src/go/types/check_test.go @@ -34,6 +34,7 @@ import ( "go/token" "internal/testenv" "io/ioutil" + "path/filepath" "regexp" "strings" "testing" @@ -93,11 +94,6 @@ var tests = [][]string{ {"testdata/issues.src"}, {"testdata/blank.src"}, {"testdata/issue25008b.src", "testdata/issue25008a.src"}, // order (b before a) is crucial! - {"testdata/issue26390.src"}, // stand-alone test to ensure case is triggered - {"testdata/issue23203a.src"}, - {"testdata/issue23203b.src"}, - {"testdata/issue28251.src"}, - {"testdata/issue6977.src"}, } var fset = token.NewFileSet() @@ -259,7 +255,7 @@ func checkFiles(t *testing.T, testfiles []string) { // typecheck and collect typechecker errors var conf Config // special case for importC.src - if len(testfiles) == 1 && testfiles[0] == "testdata/importC.src" { + if len(testfiles) == 1 && strings.HasSuffix(testfiles[0], "importC.src") { conf.FakeImportC = true } conf.Importer = importer.Default() @@ -316,3 +312,27 @@ func TestCheck(t *testing.T) { checkFiles(t, files) } } + +func TestFixedBugs(t *testing.T) { testDir(t, "fixedbugs") } + +func testDir(t *testing.T, dir string) { + testenv.MustHaveGoBuild(t) + + fis, err := ioutil.ReadDir(dir) + if err != nil { + t.Fatal(err) + } + + for _, fi := range fis { + testname := filepath.Base(fi.Name()) + testname = strings.TrimSuffix(testname, filepath.Ext(testname)) + t.Run(testname, func(t *testing.T) { + filename := filepath.Join(dir, fi.Name()) + if fi.IsDir() { + t.Errorf("skipped directory %q", filename) + return + } + checkFiles(t, []string{filename}) + }) + } +} diff --git a/src/go/types/testdata/issue23203a.src b/src/go/types/fixedbugs/issue23203a.src similarity index 100% rename from src/go/types/testdata/issue23203a.src rename to src/go/types/fixedbugs/issue23203a.src diff --git a/src/go/types/testdata/issue23203b.src b/src/go/types/fixedbugs/issue23203b.src similarity index 100% rename from src/go/types/testdata/issue23203b.src rename to src/go/types/fixedbugs/issue23203b.src diff --git a/src/go/types/testdata/issue26390.src b/src/go/types/fixedbugs/issue26390.src similarity index 83% rename from src/go/types/testdata/issue26390.src rename to src/go/types/fixedbugs/issue26390.src index b8e67e9bdd..9e0101f581 100644 --- a/src/go/types/testdata/issue26390.src +++ b/src/go/types/fixedbugs/issue26390.src @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// stand-alone test to ensure case is triggered + package issue26390 type A = T diff --git a/src/go/types/testdata/issue28251.src b/src/go/types/fixedbugs/issue28251.src similarity index 100% rename from src/go/types/testdata/issue28251.src rename to src/go/types/fixedbugs/issue28251.src diff --git a/src/go/types/testdata/issue6977.src b/src/go/types/fixedbugs/issue6977.src similarity index 100% rename from src/go/types/testdata/issue6977.src rename to src/go/types/fixedbugs/issue6977.src -- 2.48.1