From a7ad52d8255db366b65ae74ca39e7f712a99c63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Stemmer?= Date: Sat, 28 Apr 2018 18:21:42 +0100 Subject: [PATCH] parser/gotest: Parse cached tests --- pkg/parser/gotest/gotest.go | 6 +++--- pkg/parser/gotest/gotest_test.go | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/parser/gotest/gotest.go b/pkg/parser/gotest/gotest.go index afd2a36..760d80f 100644 --- a/pkg/parser/gotest/gotest.go +++ b/pkg/parser/gotest/gotest.go @@ -28,7 +28,7 @@ var ( regexEndTest = regexp.MustCompile(`((?: )*)--- (PASS|FAIL|SKIP): ([^ ]+) \((\d+\.\d+)(?: seconds|s)\)`) regexStatus = regexp.MustCompile(`^(PASS|FAIL|SKIP)$`) regexSummary = regexp.MustCompile(`^(ok|FAIL)\s+([^ ]+)\s+` + - `(?:(\d+\.\d+)s|\(cached\)|(\[\w+ failed]))` + + `(?:(\d+\.\d+)s|(\(cached\)|\[\w+ failed]))` + `(?:\s+coverage:\s+(\d+\.\d+)%\sof\sstatements(?:\sin\s(.+))?)?$`) regexCoverage = regexp.MustCompile(`^coverage:\s+(\d+|\d+\.\d+)%\s+of\s+statements(?:\sin\s(.+))?$`) ) @@ -135,13 +135,13 @@ func (p *parser) status(result string) { }) } -func (p *parser) summary(result, name, duration, failure, covpct, packages string) { +func (p *parser) summary(result, name, duration, data, covpct, packages string) { p.add(Event{ Type: "summary", Result: result, Name: name, Duration: parseSeconds(duration), - Data: failure, + Data: data, CovPct: parseCoverage(covpct), CovPackages: parsePackages(packages), }) diff --git a/pkg/parser/gotest/gotest_test.go b/pkg/parser/gotest/gotest_test.go index f79387c..a12fde0 100644 --- a/pkg/parser/gotest/gotest_test.go +++ b/pkg/parser/gotest/gotest_test.go @@ -320,7 +320,12 @@ var tests = []struct { {Type: "summary", Result: "FAIL", Name: "pkg/parallel", Duration: 3010 * time.Millisecond}, }}, {"21-cached", - []Event{}}, + []Event{ + {Type: "run_test", Id: 1, Name: "TestOne"}, + {Type: "end_test", Id: 1, Name: "TestOne", Result: "PASS"}, + {Type: "status", Result: "PASS"}, + {Type: "summary", Result: "ok", Name: "package/one", Data: "(cached)"}, + }}, {"22-whitespace", []Event{}}, }