MCPcopy Create free account
hub / github.com/temporalio/temporal / parseTestTimeouts

Function parseTestTimeouts

tools/testrunner/log.go:20–47  ·  view source on GitHub ↗

parseTestTimeouts parses the stdout of a test run and returns the stacktrace and names of tests that timed out.

(stdout string)

Source from the content-addressed store, hash-verified

18
19// parseTestTimeouts parses the stdout of a test run and returns the stacktrace and names of tests that timed out.
20func parseTestTimeouts(stdout string) (stacktrace string, timedoutTests []string) {
21 lines := strings.Split(strings.ReplaceAll(stdout, "\r\n", "\n"), "\n")
22 for i := 0; i < len(lines); i++ {
23 line := lines[i]
24 if strings.HasPrefix(line, "FAIL") {
25 // ignore
26 } else if strings.HasPrefix(line, "panic: test timed out after") {
27 // parse names of tests that timed out
28 for {
29 i++
30 line = strings.TrimSpace(lines[i])
31 if strings.HasPrefix(line, "Test") {
32 timedoutTests = append(timedoutTests, strings.Split(line, " ")[0])
33 }
34 if line == "" {
35 break
36 }
37 }
38 } else if len(timedoutTests) > 0 {
39 // collect stracktrace
40 stacktrace += line + "\n"
41 }
42 }
43
44 stacktrace = fmt.Sprintf("%d timed out test(s):\n\t%v\n\n%v",
45 len(timedoutTests), strings.Join(timedoutTests, "\n\t"), testOnlyStacktrace(stacktrace))
46 return
47}
48
49// testOnlyStacktrace removes all but the test stacktraces from the full stacktrace.
50func testOnlyStacktrace(stacktrace string) string {

Callers 2

TestParseTestTimeoutsFunction · 0.85
runTestsMethod · 0.85

Calls 2

testOnlyStacktraceFunction · 0.85
SplitMethod · 0.65

Tested by 1

TestParseTestTimeoutsFunction · 0.68