| 200 | } |
| 201 | |
| 202 | func getTestFiles(args cli.Args, fileExt string) []string { |
| 203 | paths := args |
| 204 | if len(paths) == 0 { |
| 205 | paths = append(paths, ".") |
| 206 | } |
| 207 | |
| 208 | pattern := regexp.MustCompile(`^test_.*\.` + fileExt + `$`) |
| 209 | seen := map[string]bool{} |
| 210 | testFiles := []string{} |
| 211 | for _, path := range paths { |
| 212 | filepath.Walk(path, func(filePath string, info os.FileInfo, err error) error { |
| 213 | if err != nil { |
| 214 | log.Error(fmt.Sprintf("Failed to process '%s': %s", filePath, err.Error())) |
| 215 | return nil |
| 216 | } |
| 217 | |
| 218 | if info.IsDir() { |
| 219 | return nil |
| 220 | } |
| 221 | |
| 222 | if !pattern.MatchString(info.Name()) { |
| 223 | return nil |
| 224 | } |
| 225 | |
| 226 | filePath = filepath.Clean(filePath) |
| 227 | |
| 228 | if !seen[filePath] { |
| 229 | testFiles = append(testFiles, filePath) |
| 230 | seen[filePath] = true |
| 231 | } |
| 232 | |
| 233 | return nil |
| 234 | }) |
| 235 | } |
| 236 | |
| 237 | log.Notice("Found %d test file(s) of type '%s' in path(s): %s", |
| 238 | len(testFiles), fileExt, strings.Join(paths, ", ")) |
| 239 | |
| 240 | return testFiles |
| 241 | } |