MCPcopy Create free account
hub / github.com/cloudwan/gohan / getTestFiles

Function getTestFiles

extension/framework/framework.go:202–241  ·  view source on GitHub ↗
(args cli.Args, fileExt string)

Source from the content-addressed store, hash-verified

200}
201
202func 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}

Callers 2

TestGetTestFilesFunction · 0.85
TestExtensionsFunction · 0.85

Calls 4

JoinMethod · 0.80
ErrorMethod · 0.65
NameMethod · 0.65
NoticeMethod · 0.65

Tested by 2

TestGetTestFilesFunction · 0.68
TestExtensionsFunction · 0.68