From bab26d76b516ab131d0ecb548d9f2534d55ebd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Stemmer?= Date: Sun, 27 Feb 2022 23:27:22 +0000 Subject: [PATCH] gtr: Write test output to JUnit SystemOut Fixes #108 --- pkg/gtr/gtr.go | 4 ++++ testdata/02-report.xml | 1 + testdata/06-report.xml | 1 + testdata/17-report.xml | 1 + testdata/20-report.xml | 1 + testdata/22-report.xml | 3 +++ testdata/23-report.xml | 3 +++ testdata/26-report.xml | 2 ++ testdata/27-report.xml | 3 +++ testdata/28-report.xml | 1 + testdata/29-report.xml | 1 + 11 files changed, 21 insertions(+) diff --git a/pkg/gtr/gtr.go b/pkg/gtr/gtr.go index 5e5fde7..cb06ddf 100644 --- a/pkg/gtr/gtr.go +++ b/pkg/gtr/gtr.go @@ -115,6 +115,10 @@ func JUnit(report Report, hostname string, now time.Time) junit.Testsuites { Hostname: hostname, } + if len(pkg.Output) > 0 { + suite.SystemOut = &junit.Output{Data: formatOutput(pkg.Output, 0)} + } + if pkg.Coverage > 0 { suite.AddProperty("coverage.statements.pct", fmt.Sprintf("%.2f", pkg.Coverage)) } diff --git a/testdata/02-report.xml b/testdata/02-report.xml index 9309da5..74fdb72 100644 --- a/testdata/02-report.xml +++ b/testdata/02-report.xml @@ -8,5 +8,6 @@ file_test.go:11: Error message file_test.go:11: Longer error message. + diff --git a/testdata/06-report.xml b/testdata/06-report.xml index e88ead1..2271733 100644 --- a/testdata/06-report.xml +++ b/testdata/06-report.xml @@ -14,5 +14,6 @@ file_test.go:11: Error message file_test.go:11: Longer error message. + diff --git a/testdata/17-report.xml b/testdata/17-report.xml index d8ba005..005a994 100644 --- a/testdata/17-report.xml +++ b/testdata/17-report.xml @@ -7,5 +7,6 @@ test output 2 0xc4200153d0 ================== WARNING: DATA RACE Write at 0x00c4200153d0 by goroutine 7: race_test.TestRace.func1() race_test.go:13 +0x3b Previous write at 0x00c4200153d0 by goroutine 6: race_test.TestRace() race_test.go:15 +0x136 testing.tRunner() /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107 Goroutine 7 (running) created at: race_test.TestRace() race_test.go:14 +0x125 testing.tRunner() /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107 Goroutine 6 (running) created at: testing.(*T).Run() /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:697 +0x543 testing.runTests.func1() /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:882 +0xaa testing.tRunner() /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107 testing.runTests() /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:888 +0x4e0 testing.(*M).Run() /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:822 +0x1c3 main.main() _test/_testmain.go:52 +0x20f ================== testing.go:610: race detected during execution of test + diff --git a/testdata/20-report.xml b/testdata/20-report.xml index 6cb1bf2..212d0cd 100644 --- a/testdata/20-report.xml +++ b/testdata/20-report.xml @@ -13,5 +13,6 @@ Message from third parallel_test.go:32: ThirdTest error + diff --git a/testdata/22-report.xml b/testdata/22-report.xml index d89e536..3661e0c 100644 --- a/testdata/22-report.xml +++ b/testdata/22-report.xml @@ -6,5 +6,8 @@ + diff --git a/testdata/23-report.xml b/testdata/23-report.xml index 23ab635..c406683 100644 --- a/testdata/23-report.xml +++ b/testdata/23-report.xml @@ -6,5 +6,8 @@ + diff --git a/testdata/26-report.xml b/testdata/26-report.xml index 66c2c8f..a758e87 100644 --- a/testdata/26-report.xml +++ b/testdata/26-report.xml @@ -6,6 +6,7 @@ + @@ -15,5 +16,6 @@ + diff --git a/testdata/27-report.xml b/testdata/27-report.xml index 8d3a0d3..6049ee4 100644 --- a/testdata/27-report.xml +++ b/testdata/27-report.xml @@ -7,5 +7,8 @@ + diff --git a/testdata/28-report.xml b/testdata/28-report.xml index b67511e..5208fb5 100644 --- a/testdata/28-report.xml +++ b/testdata/28-report.xml @@ -5,5 +5,6 @@ + diff --git a/testdata/29-report.xml b/testdata/29-report.xml index 20f849b..edb3434 100644 --- a/testdata/29-report.xml +++ b/testdata/29-report.xml @@ -5,5 +5,6 @@ +