Skip to content

Commit 9cf1614

Browse files
committed
test case extractor: use a glob and read *_test.go to include any additional test files
1 parent 24488d7 commit 9cf1614

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

testrunner/ast.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"go/token"
1313
"go/types"
1414
"log"
15-
"os"
1615
"path/filepath"
1716
"regexp"
1817
"strconv"
@@ -375,11 +374,10 @@ func processRange(metadata *subTData, rastmt *ast.RangeStmt) bool {
375374
// resolveTestData resolves test data variable declared in cases_test.go (if exists)
376375
// and returns type information for identifier resolution
377376
func resolveTestData(fset *token.FileSet, f *ast.File, file string) *types.Info {
378-
filepaths := []string{file}
379-
// Add cases_test.go if it exists.
380-
dataFile := filepath.Join(filepath.Dir(file), "cases_test.go")
381-
if _, err := os.Stat(dataFile); err == nil {
382-
filepaths = append(filepaths, dataFile)
377+
glob := filepath.Join(filepath.Dir(file), "*_test.go")
378+
filepaths, err := filepath.Glob(glob)
379+
if err != nil {
380+
return nil
383381
}
384382

385383
files := []*ast.File{f}

0 commit comments

Comments
 (0)