(path string, regexp *regexp.Regexp)
| 9 | ) |
| 10 | |
| 11 | func functionsInFile(path string, regexp *regexp.Regexp) (tests []string) { |
| 12 | fset := token.NewFileSet() |
| 13 | f, err := parser.ParseFile(fset, path, nil, 0) |
| 14 | if err != nil { |
| 15 | log.Printf("Failed parsing %s: %s", path, err) |
| 16 | return nil |
| 17 | } |
| 18 | for _, d := range f.Decls { |
| 19 | if f, ok := d.(*ast.FuncDecl); ok { |
| 20 | name := f.Name.String() |
| 21 | if regexp == nil || regexp.MatchString(name) { |
| 22 | tests = append(tests, name) |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | return |
| 27 | } |