Atlas › Test

DeduplicatesDuplicateLines

Exact test identity: go.temporal.io/server/tools/testrunner/TestParseFailedTestsFromOutput/DeduplicatesDuplicateLines

Package
go.temporal.io/server/tools/testrunner
Suite / test hierarchy
TestParseFailedTestsFromOutput/DeduplicatesDuplicateLines
Test
DeduplicatesDuplicateLines
Introduced at
DeduplicatesDuplicateLines Frontier kind: Test frontier
Covered ranges
9
Covered lines
23
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/tools/testrunner/log.go 23 covered LOC · 9 ranges

Open complete file

173
174 // addUniqueTest appends name to tests if not already seen.
175 > func addUniqueTest(tests *[]string, seen map[string]struct{}, name string) { log.go
176 > if _, ok := seen[name]; ok {
177 > return log.go
178 > }
179 > seen[name] = struct{}{} log.go
180 > *tests = append(*tests, name)
181 }
182
183 // parseTripleDashTestName parses Go test failure lines and returns the test name if present.
184 > func parseTripleDashTestName(line string) (string, bool) { log.go
185 > if !strings.HasPrefix(line, goTestFailLinePrefix) {
186 return "", false
187 }
188 > name := strings.TrimSpace(strings.TrimPrefix(line, goTestFailLinePrefix)) log.go
189 > name, _, _ = strings.Cut(name, " ")
190 > if !strings.HasPrefix(name, "Test") {
191 return "", false
192 }
193 > return name, true log.go
194 }
195
328 // It looks for Go test failure lines produced as tests complete, and is
329 // used when the test binary was killed externally before producing a JUnit XML.
330 > func parseFailedTestsFromOutput(stdout string) []string { log.go
331 > var failed []string
332 > seen := make(map[string]struct{})
333 > for line := range strings.SplitSeq(strings.ReplaceAll(stdout, "\r\n", "\n"), "\n") {
334 > line = strings.TrimSpace(line)
335 > if !strings.HasPrefix(line, goTestFailLinePrefix) {
336 > continue
337 }
338 > if name, ok := parseTripleDashTestName(line); ok { log.go
339 > addUniqueTest(&failed, seen, name)
340 > }
341 }
342 > return failed log.go
343 }
344