diff --git a/pkg/parser/gotest/gotest.go b/pkg/parser/gotest/gotest.go index 188b536..afd2a36 100644 --- a/pkg/parser/gotest/gotest.go +++ b/pkg/parser/gotest/gotest.go @@ -55,9 +55,11 @@ type parser struct { func (p *parser) parseLine(line string) { if strings.HasPrefix(line, "=== RUN ") { - p.runTest(line[8:]) + p.runTest(strings.TrimSpace(line[8:])) } else if strings.HasPrefix(line, "=== PAUSE ") { + p.pauseTest(strings.TrimSpace(line[10:])) } else if strings.HasPrefix(line, "=== CONT ") { + p.contTest(strings.TrimSpace(line[9:])) } else if matches := regexEndTest.FindStringSubmatch(line); len(matches) == 5 { p.endTest(line, matches[1], matches[2], matches[3], matches[4]) } else if matches := regexStatus.FindStringSubmatch(line); len(matches) == 2 { @@ -82,6 +84,7 @@ func (p *parser) findTest(name string) int { return p.events[i].Id } } + fmt.Printf("could not find test %q\n", name) return -1 } @@ -90,7 +93,23 @@ func (p *parser) runTest(name string) { p.add(Event{ Type: "run_test", Id: p.id, - Name: strings.TrimSpace(name), + Name: name, + }) +} + +func (p *parser) pauseTest(name string) { + p.add(Event{ + Type: "pause_test", + Id: p.findTest(name), + Name: name, + }) +} + +func (p *parser) contTest(name string) { + p.add(Event{ + Type: "cont_test", + Id: p.findTest(name), + Name: name, }) } diff --git a/pkg/parser/gotest/gotest_test.go b/pkg/parser/gotest/gotest_test.go index 2590e8f..f79387c 100644 --- a/pkg/parser/gotest/gotest_test.go +++ b/pkg/parser/gotest/gotest_test.go @@ -298,7 +298,27 @@ var tests = []struct { {Type: "summary", Result: "ok", Name: "package/name", Duration: 160 * time.Millisecond}, }}, {"20-parallel", - []Event{}}, + []Event{ + {Type: "run_test", Id: 1, Name: "FirstTest"}, + {Type: "output", Data: "Message from first"}, + {Type: "pause_test", Id: 1, Name: "FirstTest"}, + {Type: "run_test", Id: 2, Name: "SecondTest"}, + {Type: "output", Data: "Message from second"}, + {Type: "pause_test", Id: 2, Name: "SecondTest"}, + {Type: "cont_test", Id: 1, Name: "FirstTest"}, + {Type: "output", Data: "Supplemental from first"}, + {Type: "run_test", Id: 3, Name: "ThirdTest"}, + {Type: "output", Data: "Message from third"}, + {Type: "end_test", Id: 3, Name: "ThirdTest", Result: "FAIL", Duration: 10 * time.Millisecond}, + {Type: "output", Data: "\tparallel_test.go:32: ThirdTest error"}, + {Type: "end_test", Id: 1, Name: "FirstTest", Result: "FAIL", Duration: 2 * time.Second}, + {Type: "output", Data: "\tparallel_test.go:14: FirstTest error"}, + {Type: "end_test", Id: 2, Name: "SecondTest", Result: "FAIL", Duration: 1 * time.Second}, + {Type: "output", Data: "\tparallel_test.go:23: SecondTest error"}, + {Type: "status", Result: "FAIL"}, + {Type: "output", Data: "exit status 1"}, + {Type: "summary", Result: "FAIL", Name: "pkg/parallel", Duration: 3010 * time.Millisecond}, + }}, {"21-cached", []Event{}}, {"22-whitespace",