From 1b60a113960fd0dbe13df61db7654fcc7411ef6e Mon Sep 17 00:00:00 2001 From: Aiden Scandella Date: Sun, 23 Aug 2015 10:54:13 -0700 Subject: [PATCH] Add support for Go 1.5 test results An alternate approach that does not involve regular expressions. Fixes #15 --- go-junit-report_test.go | 26 ++++++++++++++++++++++++++ parser/parser.go | 4 ++-- tests/11-go_1_5.txt | 6 ++++++ tests/11-report.xml | 10 ++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 tests/11-go_1_5.txt create mode 100644 tests/11-report.xml diff --git a/go-junit-report_test.go b/go-junit-report_test.go index a409b9e..76b5669 100644 --- a/go-junit-report_test.go +++ b/go-junit-report_test.go @@ -329,6 +329,32 @@ var testCases = []TestCase{ }, }, }, + { + name: "11-go_1_5.txt", + reportName: "11-report.xml", + report: &parser.Report{ + Packages: []parser.Package{ + { + Name: "package/name", + Time: 50, + Tests: []*parser.Test{ + { + Name: "TestOne", + Time: 20, + Result: parser.PASS, + Output: []string{}, + }, + { + Name: "TestTwo", + Time: 30, + Result: parser.PASS, + Output: []string{}, + }, + }, + }, + }, + }, + }, } func TestParser(t *testing.T) { diff --git a/parser/parser.go b/parser/parser.go index e5e0673..e2b6650 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -78,9 +78,9 @@ func Parse(r io.Reader, pkgName string) (*Report, error) { if strings.HasPrefix(line, "=== RUN ") { // new test - cur = line[8:] + cur = strings.TrimSpace(line[8:]) tests = append(tests, &Test{ - Name: line[8:], + Name: cur, Result: FAIL, Output: make([]string, 0), }) diff --git a/tests/11-go_1_5.txt b/tests/11-go_1_5.txt new file mode 100644 index 0000000..2a40cee --- /dev/null +++ b/tests/11-go_1_5.txt @@ -0,0 +1,6 @@ +=== RUN TestOne +--- PASS: TestOne (0.02s) +=== RUN TestTwo +--- PASS: TestTwo (0.03s) +PASS +ok package/name 0.050s diff --git a/tests/11-report.xml b/tests/11-report.xml new file mode 100644 index 0000000..9aa2c82 --- /dev/null +++ b/tests/11-report.xml @@ -0,0 +1,10 @@ + + + + + + + + + +