@@ -43,35 +43,37 @@ type rootLevelTest struct {
4343
4444// FindAllRootLevelTests parses the test file and extracts the name,
4545// test code and task id for each top level test (parent test) in the file.
46- func FindAllRootLevelTests (fileName string ) []rootLevelTest {
46+ func FindAllRootLevelTests (fileNames [] string ) []rootLevelTest {
4747 defer handleASTPanic ()
4848 tests := []rootLevelTest {}
4949 fset := token .NewFileSet ()
5050 ppc := parser .ParseComments
51- file , err := parser .ParseFile (fset , fileName , nil , ppc )
52- if err != nil {
53- log .Printf ("error: not able to parse '%s': %s" , fileName , err )
54- return nil
55- }
56- for _ , d := range file .Decls {
57- if f , ok := d .(* ast.FuncDecl ); ok && strings .HasPrefix (f .Name .Name , "Test" ) {
58- taskID := findTaskID (f .Doc )
59- fun := & printer.CommentedNode {Node : f , Comments : file .Comments }
60- var buf bytes.Buffer
61- printErr := printer .Fprint (& buf , fset , fun )
62- if printErr != nil {
63- log .Printf ("warning: failed to print AST for test %s in %s: %s" ,
64- f .Name .Name , fileName , err ,
65- )
66- }
51+ for _ , fileName := range fileNames {
52+ file , err := parser .ParseFile (fset , fileName , nil , ppc )
53+ if err != nil {
54+ log .Printf ("error: not able to parse '%s': %s" , fileName , err )
55+ return nil
56+ }
57+ for _ , d := range file .Decls {
58+ if f , ok := d .(* ast.FuncDecl ); ok && strings .HasPrefix (f .Name .Name , "Test" ) {
59+ taskID := findTaskID (f .Doc )
60+ fun := & printer.CommentedNode {Node : f , Comments : file .Comments }
61+ var buf bytes.Buffer
62+ printErr := printer .Fprint (& buf , fset , fun )
63+ if printErr != nil {
64+ log .Printf ("warning: failed to print AST for test %s in %s: %s" ,
65+ f .Name .Name , fileName , err ,
66+ )
67+ }
6768
68- tests = append (tests , rootLevelTest {
69- name : f .Name .Name ,
70- fileName : fileName ,
71- code : buf .String (),
72- taskID : taskID ,
73- pkgName : file .Name .Name ,
74- })
69+ tests = append (tests , rootLevelTest {
70+ name : f .Name .Name ,
71+ fileName : fileName ,
72+ code : buf .String (),
73+ taskID : taskID ,
74+ pkgName : file .Name .Name ,
75+ })
76+ }
7577 }
7678 }
7779 return tests
0 commit comments