MCPcopy
hub / github.com/tailscale/tailscale / testFuncNames

Function testFuncNames

cmd/testwrapper/testwrapper.go:234–257  ·  view source on GitHub ↗

testFuncNames scans a Go source file and returns the names of all top-level test functions (Test*, Benchmark*, Example*, Fuzz*).

(path string)

Source from the content-addressed store, hash-verified

232// testFuncNames scans a Go source file and returns the names of all top-level
233// test functions (Test*, Benchmark*, Example*, Fuzz*).
234func testFuncNames(path string) ([]string, error) {
235 f, err := os.Open(path)
236 if err != nil {
237 return nil, err
238 }
239 defer f.Close()
240 var names []string
241 sc := bufio.NewScanner(f)
242 for sc.Scan() {
243 rest, ok := strings.CutPrefix(sc.Text(), "func ")
244 if !ok {
245 continue
246 }
247 for _, prefix := range []string{"Test", "Benchmark", "Example", "Fuzz"} {
248 if strings.HasPrefix(rest, prefix) {
249 if i := strings.IndexByte(rest, '('); i > 0 {
250 names = append(names, rest[:i])
251 }
252 break
253 }
254 }
255 }
256 return names, sc.Err()
257}
258
259// runTests runs the tests in pt and sends the results on ch. It sends a
260// testAttempt for each test and a final testAttempt per pkg with pkgFinished

Callers 1

testsForShardFunction · 0.85

Calls 5

ScanMethod · 0.80
TextMethod · 0.80
CloseMethod · 0.65
OpenMethod · 0.45
ErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…