]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: remove need to enumerate fixedbugs test files
authorRob Findley <rfindley@google.com>
Tue, 11 Aug 2020 17:21:14 +0000 (13:21 -0400)
committerRobert Findley <rfindley@google.com>
Thu, 27 Aug 2020 18:34:42 +0000 (18:34 +0000)
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 <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/check_test.go
src/go/types/fixedbugs/issue23203a.src [moved from src/go/types/testdata/issue23203a.src with 100% similarity]
src/go/types/fixedbugs/issue23203b.src [moved from src/go/types/testdata/issue23203b.src with 100% similarity]
src/go/types/fixedbugs/issue26390.src [moved from src/go/types/testdata/issue26390.src with 83% similarity]
src/go/types/fixedbugs/issue28251.src [moved from src/go/types/testdata/issue28251.src with 100% similarity]
src/go/types/fixedbugs/issue6977.src [moved from src/go/types/testdata/issue6977.src with 100% similarity]

index 89122d75fff17ae543ab279cbc65c16e1aacd3f9..e01c3de13b51cf4ccce79b7fb680d11e3bb95e72 100644 (file)
@@ -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})
+               })
+       }
+}
similarity index 83%
rename from src/go/types/testdata/issue26390.src
rename to src/go/types/fixedbugs/issue26390.src
index b8e67e9bddb6a8b2794c792dfaa73a5ff861098a..9e0101f5819b9c4fbbee387d56408a7a8f51e073 100644 (file)
@@ -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