diff --git a/go-junit-report_test.go b/go-junit-report_test.go
index 1091294..ed4be99 100644
--- a/go-junit-report_test.go
+++ b/go-junit-report_test.go
@@ -72,12 +72,19 @@ func testRun(inputFile, reportFile string, config TestConfig, t *testing.T) {
t.Fatalf("error loading report file: %v", err)
}
- parser := gotest.New(
+ options := []gotest.Option{
gotest.PackageName(config.packageName),
gotest.TimestampFunc(func() time.Time {
return time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC)
}),
- )
+ }
+
+ var parser Parser
+ if strings.HasSuffix(inputFile, ".gojson.txt") {
+ parser = gotest.NewJSON(options...)
+ } else {
+ parser = gotest.New(options...)
+ }
report, err := parser.Parse(input)
if err != nil {
diff --git a/testdata/100-pass.gojson.txt b/testdata/100-pass.gojson.txt
new file mode 100644
index 0000000..df3eba3
--- /dev/null
+++ b/testdata/100-pass.gojson.txt
@@ -0,0 +1,7 @@
+{"Time":"2019-10-09T00:00:00.708039352+00:00","Action":"run","Package":"package/name/ok","Test":"TestOK"}
+{"Time":"2019-10-09T00:00:00.708139047+00:00","Action":"output","Package":"package/name/ok","Test":"TestOK","Output":"=== RUN TestOK\n"}
+{"Time":"2019-10-09T00:00:00.708148292+00:00","Action":"output","Package":"package/name/ok","Test":"TestOK","Output":"--- PASS: TestOK (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.708154115+00:00","Action":"pass","Package":"package/name/ok","Test":"TestOK","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.708157995+00:00","Action":"output","Package":"package/name/ok","Output":"PASS\n"}
+{"Time":"2019-10-09T00:00:00.708199504+00:00","Action":"output","Package":"package/name/ok","Output":"ok \tpackage/name/ok\t0.001s\n"}
+{"Time":"2019-10-09T00:00:00.708212177+00:00","Action":"pass","Package":"package/name/ok","Elapsed":0.001}
diff --git a/testdata/100-report.xml b/testdata/100-report.xml
new file mode 100644
index 0000000..1bf1363
--- /dev/null
+++ b/testdata/100-report.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/testdata/101-fail.gojson.txt b/testdata/101-fail.gojson.txt
new file mode 100644
index 0000000..7d3e59d
--- /dev/null
+++ b/testdata/101-fail.gojson.txt
@@ -0,0 +1,16 @@
+{"Time":"2019-10-09T00:00:00.978937959+00:00","Action":"run","Package":"package/name/fail","Test":"TestOne"}
+{"Time":"2019-10-09T00:00:00.979041013+00:00","Action":"output","Package":"package/name/fail","Test":"TestOne","Output":"=== RUN TestOne\n"}
+{"Time":"2019-10-09T00:00:00.979048927+00:00","Action":"output","Package":"package/name/fail","Test":"TestOne","Output":" main_test.go:6: Error message\n"}
+{"Time":"2019-10-09T00:00:00.979053125+00:00","Action":"output","Package":"package/name/fail","Test":"TestOne","Output":" main_test.go:7: Longer\n"}
+{"Time":"2019-10-09T00:00:00.97905703+00:00","Action":"output","Package":"package/name/fail","Test":"TestOne","Output":" error\n"}
+{"Time":"2019-10-09T00:00:00.979060012+00:00","Action":"output","Package":"package/name/fail","Test":"TestOne","Output":" message.\n"}
+{"Time":"2019-10-09T00:00:00.979064328+00:00","Action":"output","Package":"package/name/fail","Test":"TestOne","Output":"--- FAIL: TestOne (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.979067283+00:00","Action":"fail","Package":"package/name/fail","Test":"TestOne","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.979071228+00:00","Action":"run","Package":"package/name/fail","Test":"TestTwo"}
+{"Time":"2019-10-09T00:00:00.979073638+00:00","Action":"output","Package":"package/name/fail","Test":"TestTwo","Output":"=== RUN TestTwo\n"}
+{"Time":"2019-10-09T00:00:00.979076797+00:00","Action":"output","Package":"package/name/fail","Test":"TestTwo","Output":"--- PASS: TestTwo (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.979079302+00:00","Action":"pass","Package":"package/name/fail","Test":"TestTwo","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.979081855+00:00","Action":"output","Package":"package/name/fail","Output":"FAIL\n"}
+{"Time":"2019-10-09T00:00:00.979133907+00:00","Action":"output","Package":"package/name/fail","Output":"exit status 1\n"}
+{"Time":"2019-10-09T00:00:00.979146205+00:00","Action":"output","Package":"package/name/fail","Output":"FAIL\tpackage/name/fail\t0.001s\n"}
+{"Time":"2019-10-09T00:00:00.979150031+00:00","Action":"fail","Package":"package/name/fail","Elapsed":0.001}
diff --git a/testdata/101-report.xml b/testdata/101-report.xml
new file mode 100644
index 0000000..47bdb40
--- /dev/null
+++ b/testdata/101-report.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/102-broken.gojson.txt b/testdata/102-broken.gojson.txt
new file mode 100644
index 0000000..76dc5cb
--- /dev/null
+++ b/testdata/102-broken.gojson.txt
@@ -0,0 +1,5 @@
+# package/name/broken [package/name/broken.test]
+./main.go:4:6: unused declared but not used
+./main.go:5:2: undefined: fmt
+./main.go:5:48: undefined: value
+FAIL package/name/broken [build failed]
diff --git a/testdata/102-report.xml b/testdata/102-report.xml
new file mode 100644
index 0000000..b77589d
--- /dev/null
+++ b/testdata/102-report.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/103-report.xml b/testdata/103-report.xml
new file mode 100644
index 0000000..a9aae8b
--- /dev/null
+++ b/testdata/103-report.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/103-subtests.gojson.txt b/testdata/103-subtests.gojson.txt
new file mode 100644
index 0000000..b500961
--- /dev/null
+++ b/testdata/103-subtests.gojson.txt
@@ -0,0 +1,21 @@
+{"Time":"2019-10-09T00:00:00.284172551+00:00","Action":"run","Package":"package/name/subtest","Test":"TestMultiple"}
+{"Time":"2019-10-09T00:00:00.284270018+00:00","Action":"output","Package":"package/name/subtest","Test":"TestMultiple","Output":"=== RUN TestMultiple\n"}
+{"Time":"2019-10-09T00:00:00.284277654+00:00","Action":"run","Package":"package/name/subtest","Test":"TestMultiple/Empty_string"}
+{"Time":"2019-10-09T00:00:00.284280691+00:00","Action":"output","Package":"package/name/subtest","Test":"TestMultiple/Empty_string","Output":"=== RUN TestMultiple/Empty_string\n"}
+{"Time":"2019-10-09T00:00:00.28428418+00:00","Action":"run","Package":"package/name/subtest","Test":"TestMultiple/Single"}
+{"Time":"2019-10-09T00:00:00.284287002+00:00","Action":"output","Package":"package/name/subtest","Test":"TestMultiple/Single","Output":"=== RUN TestMultiple/Single\n"}
+{"Time":"2019-10-09T00:00:00.284291242+00:00","Action":"output","Package":"package/name/subtest","Test":"TestMultiple/Single","Output":" pkg_test.go:20: Do(\"a\"): got aaaaaaaaaa, want a\n"}
+{"Time":"2019-10-09T00:00:00.284294939+00:00","Action":"run","Package":"package/name/subtest","Test":"TestMultiple/Multi"}
+{"Time":"2019-10-09T00:00:00.284297402+00:00","Action":"output","Package":"package/name/subtest","Test":"TestMultiple/Multi","Output":"=== RUN TestMultiple/Multi\n"}
+{"Time":"2019-10-09T00:00:00.284301367+00:00","Action":"output","Package":"package/name/subtest","Test":"TestMultiple","Output":"--- FAIL: TestMultiple (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.284304576+00:00","Action":"output","Package":"package/name/subtest","Test":"TestMultiple/Empty_string","Output":" --- PASS: TestMultiple/Empty_string (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.284307585+00:00","Action":"pass","Package":"package/name/subtest","Test":"TestMultiple/Empty_string","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.284310972+00:00","Action":"output","Package":"package/name/subtest","Test":"TestMultiple/Single","Output":" --- FAIL: TestMultiple/Single (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.284313906+00:00","Action":"fail","Package":"package/name/subtest","Test":"TestMultiple/Single","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.284316515+00:00","Action":"output","Package":"package/name/subtest","Test":"TestMultiple/Multi","Output":" --- PASS: TestMultiple/Multi (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.284319052+00:00","Action":"pass","Package":"package/name/subtest","Test":"TestMultiple/Multi","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.284321427+00:00","Action":"fail","Package":"package/name/subtest","Test":"TestMultiple","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.284323862+00:00","Action":"output","Package":"package/name/subtest","Output":"FAIL\n"}
+{"Time":"2019-10-09T00:00:00.284344993+00:00","Action":"output","Package":"package/name/subtest","Output":"exit status 1\n"}
+{"Time":"2019-10-09T00:00:00.284351108+00:00","Action":"output","Package":"package/name/subtest","Output":"FAIL\tpackage/name/subtest\t0.001s\n"}
+{"Time":"2019-10-09T00:00:00.284354151+00:00","Action":"fail","Package":"package/name/subtest","Elapsed":0.001}
diff --git a/testdata/104-race.gojson.txt b/testdata/104-race.gojson.txt
new file mode 100644
index 0000000..4882de2
--- /dev/null
+++ b/testdata/104-race.gojson.txt
@@ -0,0 +1,52 @@
+{"Time":"2019-10-09T00:00:00.009775942+00:00","Action":"run","Package":"package/name/race","Test":"TestRace"}
+{"Time":"2019-10-09T00:00:00.009912969+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"=== RUN TestRace\n"}
+{"Time":"2019-10-09T00:00:00.010694278+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"==================\n"}
+{"Time":"2019-10-09T00:00:00.010704964+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"WARNING: DATA RACE\n"}
+{"Time":"2019-10-09T00:00:00.010709822+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"Write at 0x00c000016308 by goroutine 8:\n"}
+{"Time":"2019-10-09T00:00:00.010715347+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" package/name/race.Race.func1()\n"}
+{"Time":"2019-10-09T00:00:00.01072067+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /src/package/name/race/pkg.go:7 +0x39\n"}
+{"Time":"2019-10-09T00:00:00.010727891+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"\n"}
+{"Time":"2019-10-09T00:00:00.010733019+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"Previous read at 0x00c000016308 by goroutine 7:\n"}
+{"Time":"2019-10-09T00:00:00.010737579+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" package/name/race.Race()\n"}
+{"Time":"2019-10-09T00:00:00.010742091+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /src/package/name/race/pkg.go:10 +0x104\n"}
+{"Time":"2019-10-09T00:00:00.010747459+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" package/name/race.TestRace()\n"}
+{"Time":"2019-10-09T00:00:00.010751912+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /src/package/name/race/pkg_test.go:6 +0x24\n"}
+{"Time":"2019-10-09T00:00:00.010756378+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.tRunner()\n"}
+{"Time":"2019-10-09T00:00:00.010760742+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /go-src/go1.18/src/testing/testing.go:1439 +0x213\n"}
+{"Time":"2019-10-09T00:00:00.010765116+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.(*T).Run.func1()\n"}
+{"Time":"2019-10-09T00:00:00.01076937+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /go-src/go1.18/src/testing/testing.go:1486 +0x47\n"}
+{"Time":"2019-10-09T00:00:00.010773791+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"\n"}
+{"Time":"2019-10-09T00:00:00.010777779+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"Goroutine 8 (running) created at:\n"}
+{"Time":"2019-10-09T00:00:00.010781771+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" package/name/race.Race()\n"}
+{"Time":"2019-10-09T00:00:00.010785612+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /src/package/name/race/pkg.go:6 +0xfa\n"}
+{"Time":"2019-10-09T00:00:00.010789234+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" package/name/race.TestRace()\n"}
+{"Time":"2019-10-09T00:00:00.010793289+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /src/package/name/race/pkg_test.go:6 +0x24\n"}
+{"Time":"2019-10-09T00:00:00.010797344+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.tRunner()\n"}
+{"Time":"2019-10-09T00:00:00.010801445+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /go-src/go1.18/src/testing/testing.go:1439 +0x213\n"}
+{"Time":"2019-10-09T00:00:00.010805494+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.(*T).Run.func1()\n"}
+{"Time":"2019-10-09T00:00:00.010814391+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /go-src/go1.18/src/testing/testing.go:1486 +0x47\n"}
+{"Time":"2019-10-09T00:00:00.010819498+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"\n"}
+{"Time":"2019-10-09T00:00:00.010823969+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"Goroutine 7 (running) created at:\n"}
+{"Time":"2019-10-09T00:00:00.010828574+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.(*T).Run()\n"}
+{"Time":"2019-10-09T00:00:00.010832764+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /go-src/go1.18/src/testing/testing.go:1486 +0x724\n"}
+{"Time":"2019-10-09T00:00:00.010837162+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.runTests.func1()\n"}
+{"Time":"2019-10-09T00:00:00.010841644+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /go-src/go1.18/src/testing/testing.go:1839 +0x99\n"}
+{"Time":"2019-10-09T00:00:00.010846126+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.tRunner()\n"}
+{"Time":"2019-10-09T00:00:00.010850492+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /go-src/go1.18/src/testing/testing.go:1439 +0x213\n"}
+{"Time":"2019-10-09T00:00:00.010854942+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.runTests()\n"}
+{"Time":"2019-10-09T00:00:00.010859154+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /go-src/go1.18/src/testing/testing.go:1837 +0x7e4\n"}
+{"Time":"2019-10-09T00:00:00.010863593+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.(*M).Run()\n"}
+{"Time":"2019-10-09T00:00:00.010867851+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" /go-src/go1.18/src/testing/testing.go:1719 +0xa71\n"}
+{"Time":"2019-10-09T00:00:00.010872159+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" main.main()\n"}
+{"Time":"2019-10-09T00:00:00.010876434+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" _testmain.go:47 +0x2e4\n"}
+{"Time":"2019-10-09T00:00:00.010881203+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"==================\n"}
+{"Time":"2019-10-09T00:00:00.010887367+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":" testing.go:1312: race detected during execution of test\n"}
+{"Time":"2019-10-09T00:00:00.010895484+00:00","Action":"output","Package":"package/name/race","Test":"TestRace","Output":"--- FAIL: TestRace (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.01090098+00:00","Action":"fail","Package":"package/name/race","Test":"TestRace","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.010906342+00:00","Action":"cont","Package":"package/name/race"}
+{"Time":"2019-10-09T00:00:00.010911088+00:00","Action":"output","Package":"package/name/race","Output":"=== CONT \n"}
+{"Time":"2019-10-09T00:00:00.010915454+00:00","Action":"output","Package":"package/name/race","Output":" testing.go:1312: race detected during execution of test\n"}
+{"Time":"2019-10-09T00:00:00.010921778+00:00","Action":"output","Package":"package/name/race","Output":"FAIL\n"}
+{"Time":"2019-10-09T00:00:00.011439867+00:00","Action":"output","Package":"package/name/race","Output":"exit status 1\n"}
+{"Time":"2019-10-09T00:00:00.011448729+00:00","Action":"output","Package":"package/name/race","Output":"FAIL\tpackage/name/race\t0.005s\n"}
+{"Time":"2019-10-09T00:00:00.011452178+00:00","Action":"fail","Package":"package/name/race","Elapsed":0.005}
diff --git a/testdata/104-report.xml b/testdata/104-report.xml
new file mode 100644
index 0000000..7916635
--- /dev/null
+++ b/testdata/104-report.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/105-panic.gojson.txt b/testdata/105-panic.gojson.txt
new file mode 100644
index 0000000..4dbe961
--- /dev/null
+++ b/testdata/105-panic.gojson.txt
@@ -0,0 +1,8 @@
+{"Time":"2019-10-09T00:00:00.596409464+00:00","Action":"output","Package":"package/name/panic","Output":"panic: init\n"}
+{"Time":"2019-10-09T00:00:00.596508615+00:00","Action":"output","Package":"package/name/panic","Output":"\n"}
+{"Time":"2019-10-09T00:00:00.596515201+00:00","Action":"output","Package":"package/name/panic","Output":"goroutine 1 [running]:\n"}
+{"Time":"2019-10-09T00:00:00.596518457+00:00","Action":"output","Package":"package/name/panic","Output":"package/name/panic.init.0()\n"}
+{"Time":"2019-10-09T00:00:00.596521268+00:00","Action":"output","Package":"package/name/panic","Output":"\t/src/package/name/panic/main_test.go:6 +0x27\n"}
+{"Time":"2019-10-09T00:00:00.596604261+00:00","Action":"output","Package":"package/name/panic","Output":"exit status 2\n"}
+{"Time":"2019-10-09T00:00:00.596615441+00:00","Action":"output","Package":"package/name/panic","Output":"FAIL\tpackage/name/panic\t0.003s\n"}
+{"Time":"2019-10-09T00:00:00.596619695+00:00","Action":"fail","Package":"package/name/panic","Elapsed":0.003}
diff --git a/testdata/105-report.xml b/testdata/105-report.xml
new file mode 100644
index 0000000..5f3a460
--- /dev/null
+++ b/testdata/105-report.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/106-report.xml b/testdata/106-report.xml
new file mode 100644
index 0000000..663c63c
--- /dev/null
+++ b/testdata/106-report.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/106-testmain.gojson.txt b/testdata/106-testmain.gojson.txt
new file mode 100644
index 0000000..4eed39b
--- /dev/null
+++ b/testdata/106-testmain.gojson.txt
@@ -0,0 +1,19 @@
+{"Time":"2019-10-09T00:00:00.439383963+00:00","Action":"run","Package":"package/name/main/ack","Test":"TestAck"}
+{"Time":"2019-10-09T00:00:00.439487748+00:00","Action":"output","Package":"package/name/main/ack","Test":"TestAck","Output":"=== RUN TestAck\n"}
+{"Time":"2019-10-09T00:00:00.439496258+00:00","Action":"output","Package":"package/name/main/ack","Test":"TestAck","Output":" ack_test.go:13: ack\n"}
+{"Time":"2019-10-09T00:00:00.439503036+00:00","Action":"output","Package":"package/name/main/ack","Test":"TestAck","Output":"--- PASS: TestAck (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.439507387+00:00","Action":"pass","Package":"package/name/main/ack","Test":"TestAck","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.439513347+00:00","Action":"output","Package":"package/name/main/ack","Output":"PASS\n"}
+{"Time":"2019-10-09T00:00:00.439517752+00:00","Action":"output","Package":"package/name/main/ack","Output":"ok \tpackage/name/main/ack\t(cached)\n"}
+{"Time":"2019-10-09T00:00:00.439522697+00:00","Action":"pass","Package":"package/name/main/ack","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.439813777+00:00","Action":"run","Package":"package/name/main/ok","Test":"TestOk"}
+{"Time":"2019-10-09T00:00:00.4398418+00:00","Action":"output","Package":"package/name/main/ok","Test":"TestOk","Output":"=== RUN TestOk\n"}
+{"Time":"2019-10-09T00:00:00.439848365+00:00","Action":"output","Package":"package/name/main/ok","Test":"TestOk","Output":" ok_test.go:13: ok\n"}
+{"Time":"2019-10-09T00:00:00.439855774+00:00","Action":"output","Package":"package/name/main/ok","Test":"TestOk","Output":"--- PASS: TestOk (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.439860255+00:00","Action":"pass","Package":"package/name/main/ok","Test":"TestOk","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.43986525+00:00","Action":"output","Package":"package/name/main/ok","Output":"PASS\n"}
+{"Time":"2019-10-09T00:00:00.439870064+00:00","Action":"output","Package":"package/name/main/ok","Output":"ok \tpackage/name/main/ok\t(cached)\n"}
+{"Time":"2019-10-09T00:00:00.439881025+00:00","Action":"pass","Package":"package/name/main/ok","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.494446083+00:00","Action":"output","Package":"package/name/main/fail","Output":"TestMain failed, returning early\n"}
+{"Time":"2019-10-09T00:00:00.494579248+00:00","Action":"output","Package":"package/name/main/fail","Output":"FAIL\tpackage/name/main/fail\t0.001s\n"}
+{"Time":"2019-10-09T00:00:00.494593522+00:00","Action":"fail","Package":"package/name/main/fail","Elapsed":0.001}
diff --git a/testdata/107-report.xml b/testdata/107-report.xml
new file mode 100644
index 0000000..c5e050f
--- /dev/null
+++ b/testdata/107-report.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/107-skip.gojson.txt b/testdata/107-skip.gojson.txt
new file mode 100644
index 0000000..a5e435d
--- /dev/null
+++ b/testdata/107-skip.gojson.txt
@@ -0,0 +1,13 @@
+{"Time":"2019-10-09T00:00:00.329193863+00:00","Action":"run","Package":"package/name/skip","Test":"TestSkip"}
+{"Time":"2019-10-09T00:00:00.329288607+00:00","Action":"output","Package":"package/name/skip","Test":"TestSkip","Output":"=== RUN TestSkip\n"}
+{"Time":"2019-10-09T00:00:00.32929713+00:00","Action":"output","Package":"package/name/skip","Test":"TestSkip","Output":" skip_test.go:6: skip message\n"}
+{"Time":"2019-10-09T00:00:00.329302577+00:00","Action":"output","Package":"package/name/skip","Test":"TestSkip","Output":"--- SKIP: TestSkip (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.329305698+00:00","Action":"skip","Package":"package/name/skip","Test":"TestSkip","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.329309504+00:00","Action":"run","Package":"package/name/skip","Test":"TestSkipNow"}
+{"Time":"2019-10-09T00:00:00.329312988+00:00","Action":"output","Package":"package/name/skip","Test":"TestSkipNow","Output":"=== RUN TestSkipNow\n"}
+{"Time":"2019-10-09T00:00:00.329315853+00:00","Action":"output","Package":"package/name/skip","Test":"TestSkipNow","Output":" skip_test.go:10: log message\n"}
+{"Time":"2019-10-09T00:00:00.329319388+00:00","Action":"output","Package":"package/name/skip","Test":"TestSkipNow","Output":"--- SKIP: TestSkipNow (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.329322008+00:00","Action":"skip","Package":"package/name/skip","Test":"TestSkipNow","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.329324691+00:00","Action":"output","Package":"package/name/skip","Output":"PASS\n"}
+{"Time":"2019-10-09T00:00:00.329392899+00:00","Action":"output","Package":"package/name/skip","Output":"ok \tpackage/name/skip\t0.001s\n"}
+{"Time":"2019-10-09T00:00:00.329615729+00:00","Action":"pass","Package":"package/name/skip","Elapsed":0.001}
diff --git a/testdata/108-paniclate.gojson.txt b/testdata/108-paniclate.gojson.txt
new file mode 100644
index 0000000..6575ad9
--- /dev/null
+++ b/testdata/108-paniclate.gojson.txt
@@ -0,0 +1,15 @@
+{"Time":"2019-10-09T00:00:00.660908821+00:00","Action":"run","Package":"package/name/paniclate","Test":"TestOne"}
+{"Time":"2019-10-09T00:00:00.660994505+00:00","Action":"output","Package":"package/name/paniclate","Test":"TestOne","Output":"=== RUN TestOne\n"}
+{"Time":"2019-10-09T00:00:00.661001176+00:00","Action":"output","Package":"package/name/paniclate","Test":"TestOne","Output":" main_test.go:13: ok\n"}
+{"Time":"2019-10-09T00:00:00.661007326+00:00","Action":"output","Package":"package/name/paniclate","Test":"TestOne","Output":"--- PASS: TestOne (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.661010216+00:00","Action":"pass","Package":"package/name/paniclate","Test":"TestOne","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.661014007+00:00","Action":"output","Package":"package/name/paniclate","Output":"PASS\n"}
+{"Time":"2019-10-09T00:00:00.663185752+00:00","Action":"output","Package":"package/name/paniclate","Output":"panic: panic\n"}
+{"Time":"2019-10-09T00:00:00.663196708+00:00","Action":"output","Package":"package/name/paniclate","Output":"\n"}
+{"Time":"2019-10-09T00:00:00.663201293+00:00","Action":"output","Package":"package/name/paniclate","Output":"goroutine 1 [running]:\n"}
+{"Time":"2019-10-09T00:00:00.663206374+00:00","Action":"output","Package":"package/name/paniclate","Output":"package/name/paniclate.TestMain(...)\n"}
+{"Time":"2019-10-09T00:00:00.663209509+00:00","Action":"output","Package":"package/name/paniclate","Output":"\t/src/package/name/paniclate/main_test.go:9\n"}
+{"Time":"2019-10-09T00:00:00.663213452+00:00","Action":"output","Package":"package/name/paniclate","Output":"main.main()\n"}
+{"Time":"2019-10-09T00:00:00.663216003+00:00","Action":"output","Package":"package/name/paniclate","Output":"\t_testmain.go:49 +0x17f\n"}
+{"Time":"2019-10-09T00:00:00.66336185+00:00","Action":"output","Package":"package/name/paniclate","Output":"FAIL\tpackage/name/paniclate\t0.003s\n"}
+{"Time":"2019-10-09T00:00:00.663374091+00:00","Action":"fail","Package":"package/name/paniclate","Elapsed":0.003}
diff --git a/testdata/108-report.xml b/testdata/108-report.xml
new file mode 100644
index 0000000..c3a4a6b
--- /dev/null
+++ b/testdata/108-report.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/109-bench.gojson.txt b/testdata/109-bench.gojson.txt
new file mode 100644
index 0000000..1c1166e
--- /dev/null
+++ b/testdata/109-bench.gojson.txt
@@ -0,0 +1,26 @@
+{"Time":"2019-10-09T00:00:00.143083156+00:00","Action":"run","Package":"package/name/bench","Test":"TestA"}
+{"Time":"2019-10-09T00:00:00.143175255+00:00","Action":"output","Package":"package/name/bench","Test":"TestA","Output":"=== RUN TestA\n"}
+{"Time":"2019-10-09T00:00:00.143186363+00:00","Action":"output","Package":"package/name/bench","Test":"TestA","Output":" a_test.go:6: ok\n"}
+{"Time":"2019-10-09T00:00:00.143192278+00:00","Action":"output","Package":"package/name/bench","Test":"TestA","Output":"--- PASS: TestA (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.143196049+00:00","Action":"pass","Package":"package/name/bench","Test":"TestA","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.143200628+00:00","Action":"run","Package":"package/name/bench","Test":"TestZ"}
+{"Time":"2019-10-09T00:00:00.143204984+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":"=== RUN TestZ\n"}
+{"Time":"2019-10-09T00:00:00.143208135+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":" z_test.go:6: ok\n"}
+{"Time":"2019-10-09T00:00:00.143212704+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":"--- PASS: TestZ (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.143526651+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":"goos: linux\n"}
+{"Time":"2019-10-09T00:00:00.143536046+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":"goarch: amd64\n"}
+{"Time":"2019-10-09T00:00:00.143541285+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":"pkg: package/name/bench\n"}
+{"Time":"2019-10-09T00:00:00.143551889+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":"BenchmarkTest\n"}
+{"Time":"2019-10-09T00:00:00.143725381+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":" bench_test.go:12: 1\n"}
+{"Time":"2019-10-09T00:00:00.143902878+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":" bench_test.go:12: 100\n"}
+{"Time":"2019-10-09T00:00:00.144064852+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":" bench_test.go:12: 10000\n"}
+{"Time":"2019-10-09T00:00:00.144742621+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":" bench_test.go:12: 1000000\n"}
+{"Time":"2019-10-09T00:00:00.171286312+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":" bench_test.go:12: 100000000\n"}
+{"Time":"2019-10-09T00:00:00.612105586+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":" bench_test.go:12: 1000000000\n"}
+{"Time":"2019-10-09T00:00:00.612121122+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":"BenchmarkTest-8 \t1000000000\t 0.4407 ns/op\n"}
+{"Time":"2019-10-09T00:00:00.612131677+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":"BenchmarkOtherTest\n"}
+{"Time":"2019-10-09T00:00:00.903727128+00:00","Action":"output","Package":"package/name/bench","Test":"TestZ","Output":"BenchmarkOtherTest-8 \t1000000000\t 0.2639 ns/op\n"}
+{"Time":"2019-10-09T00:00:00.903751664+00:00","Action":"pass","Package":"package/name/bench","Test":"TestZ","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.903759733+00:00","Action":"output","Package":"package/name/bench","Output":"PASS\n"}
+{"Time":"2019-10-09T00:00:00.904057742+00:00","Action":"output","Package":"package/name/bench","Output":"ok \tpackage/name/bench\t0.762s\n"}
+{"Time":"2019-10-09T00:00:00.904069084+00:00","Action":"pass","Package":"package/name/bench","Elapsed":0.762}
diff --git a/testdata/109-report.xml b/testdata/109-report.xml
new file mode 100644
index 0000000..e7a7957
--- /dev/null
+++ b/testdata/109-report.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/110-benchfail.gojson.txt b/testdata/110-benchfail.gojson.txt
new file mode 100644
index 0000000..8ba8a2b
--- /dev/null
+++ b/testdata/110-benchfail.gojson.txt
@@ -0,0 +1,19 @@
+{"Time":"2019-10-09T00:00:00.025742278+00:00","Action":"output","Package":"package/name/benchfail","Output":"goos: linux\n"}
+{"Time":"2019-10-09T00:00:00.025842393+00:00","Action":"output","Package":"package/name/benchfail","Output":"goarch: amd64\n"}
+{"Time":"2019-10-09T00:00:00.025848233+00:00","Action":"output","Package":"package/name/benchfail","Output":"pkg: package/name/benchfail\n"}
+{"Time":"2019-10-09T00:00:00.025857524+00:00","Action":"output","Package":"package/name/benchfail","Output":"BenchmarkError\n"}
+{"Time":"2019-10-09T00:00:00.025926237+00:00","Action":"output","Package":"package/name/benchfail","Output":" bench_test.go:6: error message\n"}
+{"Time":"2019-10-09T00:00:00.025968693+00:00","Action":"output","Package":"package/name/benchfail","Test":"BenchmarkError","Output":"--- FAIL: BenchmarkError\n"}
+{"Time":"2019-10-09T00:00:00.025973906+00:00","Action":"output","Package":"package/name/benchfail","Test":"BenchmarkError","Output":"BenchmarkFatal\n"}
+{"Time":"2019-10-09T00:00:00.026152458+00:00","Action":"output","Package":"package/name/benchfail","Test":"BenchmarkError","Output":" bench_test.go:10: fatal message\n"}
+{"Time":"2019-10-09T00:00:00.026171221+00:00","Action":"fail","Package":"package/name/benchfail","Test":"BenchmarkError"}
+{"Time":"2019-10-09T00:00:00.026174732+00:00","Action":"output","Package":"package/name/benchfail","Test":"BenchmarkFatal","Output":"--- FAIL: BenchmarkFatal\n"}
+{"Time":"2019-10-09T00:00:00.026188643+00:00","Action":"output","Package":"package/name/benchfail","Test":"BenchmarkFatal","Output":"BenchmarkSkip\n"}
+{"Time":"2019-10-09T00:00:00.026346331+00:00","Action":"output","Package":"package/name/benchfail","Test":"BenchmarkFatal","Output":" bench_test.go:14: skip message\n"}
+{"Time":"2019-10-09T00:00:00.026352372+00:00","Action":"fail","Package":"package/name/benchfail","Test":"BenchmarkFatal"}
+{"Time":"2019-10-09T00:00:00.026355025+00:00","Action":"output","Package":"package/name/benchfail","Test":"BenchmarkSkip","Output":"--- SKIP: BenchmarkSkip\n"}
+{"Time":"2019-10-09T00:00:00.026358242+00:00","Action":"skip","Package":"package/name/benchfail","Test":"BenchmarkSkip"}
+{"Time":"2019-10-09T00:00:00.026361938+00:00","Action":"output","Package":"package/name/benchfail","Output":"FAIL\n"}
+{"Time":"2019-10-09T00:00:00.026550031+00:00","Action":"output","Package":"package/name/benchfail","Output":"exit status 1\n"}
+{"Time":"2019-10-09T00:00:00.026562733+00:00","Action":"output","Package":"package/name/benchfail","Output":"FAIL\tpackage/name/benchfail\t0.002s\n"}
+{"Time":"2019-10-09T00:00:00.026568631+00:00","Action":"fail","Package":"package/name/benchfail","Elapsed":0.002}
diff --git a/testdata/111-empty.gojson.txt b/testdata/111-empty.gojson.txt
new file mode 100644
index 0000000..afbac45
--- /dev/null
+++ b/testdata/111-empty.gojson.txt
@@ -0,0 +1,4 @@
+{"Time":"2019-10-09T00:00:00.740642406+00:00","Action":"output","Package":"package/name/empty","Output":"testing: warning: no tests to run\n"}
+{"Time":"2019-10-09T00:00:00.740741069+00:00","Action":"output","Package":"package/name/empty","Output":"PASS\n"}
+{"Time":"2019-10-09T00:00:00.740776164+00:00","Action":"output","Package":"package/name/empty","Output":"ok \tpackage/name/empty\t0.001s\n"}
+{"Time":"2019-10-09T00:00:00.74078812+00:00","Action":"pass","Package":"package/name/empty","Elapsed":0.001}
diff --git a/testdata/112-parallel.gojson.txt b/testdata/112-parallel.gojson.txt
new file mode 100644
index 0000000..4f1e5f7
--- /dev/null
+++ b/testdata/112-parallel.gojson.txt
@@ -0,0 +1,41 @@
+{"Time":"2019-10-09T00:00:00.357524357+00:00","Action":"run","Package":"package/name/parallel","Test":"TestP1"}
+{"Time":"2019-10-09T00:00:00.35763106+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP1","Output":"=== RUN TestP1\n"}
+{"Time":"2019-10-09T00:00:00.357639447+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP1","Output":"=== PAUSE TestP1\n"}
+{"Time":"2019-10-09T00:00:00.357642993+00:00","Action":"pause","Package":"package/name/parallel","Test":"TestP1"}
+{"Time":"2019-10-09T00:00:00.357647811+00:00","Action":"run","Package":"package/name/parallel","Test":"TestP2"}
+{"Time":"2019-10-09T00:00:00.357650618+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP2","Output":"=== RUN TestP2\n"}
+{"Time":"2019-10-09T00:00:00.357653576+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP2","Output":"=== PAUSE TestP2\n"}
+{"Time":"2019-10-09T00:00:00.35765612+00:00","Action":"pause","Package":"package/name/parallel","Test":"TestP2"}
+{"Time":"2019-10-09T00:00:00.357659179+00:00","Action":"run","Package":"package/name/parallel","Test":"TestP3"}
+{"Time":"2019-10-09T00:00:00.357661598+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP3","Output":"=== RUN TestP3\n"}
+{"Time":"2019-10-09T00:00:00.357664327+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP3","Output":"=== PAUSE TestP3\n"}
+{"Time":"2019-10-09T00:00:00.357666658+00:00","Action":"pause","Package":"package/name/parallel","Test":"TestP3"}
+{"Time":"2019-10-09T00:00:00.357669385+00:00","Action":"cont","Package":"package/name/parallel","Test":"TestP1"}
+{"Time":"2019-10-09T00:00:00.357672779+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP1","Output":"=== CONT TestP1\n"}
+{"Time":"2019-10-09T00:00:00.357675573+00:00","Action":"cont","Package":"package/name/parallel","Test":"TestP3"}
+{"Time":"2019-10-09T00:00:00.357677968+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP3","Output":"=== CONT TestP3\n"}
+{"Time":"2019-10-09T00:00:00.357680531+00:00","Action":"cont","Package":"package/name/parallel","Test":"TestP2"}
+{"Time":"2019-10-09T00:00:00.357683223+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP2","Output":"=== CONT TestP2\n"}
+{"Time":"2019-10-09T00:00:00.357686021+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP2","Output":" pkg_test.go:19: t.Log(P2)\n"}
+{"Time":"2019-10-09T00:00:00.357688933+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP2","Output":"fmt.Printf(P2)\n"}
+{"Time":"2019-10-09T00:00:00.357691543+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP2","Output":" pkg_test.go:23: P2 error\n"}
+{"Time":"2019-10-09T00:00:00.357695428+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP2","Output":"--- FAIL: TestP2 (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.357698172+00:00","Action":"fail","Package":"package/name/parallel","Test":"TestP2","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.357701575+00:00","Action":"cont","Package":"package/name/parallel","Test":"TestP3"}
+{"Time":"2019-10-09T00:00:00.35770407+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP3","Output":"=== CONT TestP3\n"}
+{"Time":"2019-10-09T00:00:00.357706546+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP3","Output":" pkg_test.go:28: t.Log(P3)\n"}
+{"Time":"2019-10-09T00:00:00.357709127+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP3","Output":"fmt.Printf(P3)\n"}
+{"Time":"2019-10-09T00:00:00.357711692+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP3","Output":" pkg_test.go:32: P3 error\n"}
+{"Time":"2019-10-09T00:00:00.357714665+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP3","Output":"--- FAIL: TestP3 (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.357717319+00:00","Action":"fail","Package":"package/name/parallel","Test":"TestP3","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.357719718+00:00","Action":"cont","Package":"package/name/parallel","Test":"TestP1"}
+{"Time":"2019-10-09T00:00:00.357725608+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP1","Output":"=== CONT TestP1\n"}
+{"Time":"2019-10-09T00:00:00.357728586+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP1","Output":" pkg_test.go:10: t.Log(P1)\n"}
+{"Time":"2019-10-09T00:00:00.357731205+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP1","Output":"fmt.Printf(P1)\n"}
+{"Time":"2019-10-09T00:00:00.357733751+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP1","Output":" pkg_test.go:14: P1 error\n"}
+{"Time":"2019-10-09T00:00:00.357736767+00:00","Action":"output","Package":"package/name/parallel","Test":"TestP1","Output":"--- FAIL: TestP1 (0.00s)\n"}
+{"Time":"2019-10-09T00:00:00.357739279+00:00","Action":"fail","Package":"package/name/parallel","Test":"TestP1","Elapsed":0}
+{"Time":"2019-10-09T00:00:00.357741786+00:00","Action":"output","Package":"package/name/parallel","Output":"FAIL\n"}
+{"Time":"2019-10-09T00:00:00.357761811+00:00","Action":"output","Package":"package/name/parallel","Output":"exit status 1\n"}
+{"Time":"2019-10-09T00:00:00.357766968+00:00","Action":"output","Package":"package/name/parallel","Output":"FAIL\tpackage/name/parallel\t0.001s\n"}
+{"Time":"2019-10-09T00:00:00.357770181+00:00","Action":"fail","Package":"package/name/parallel","Elapsed":0.001}
diff --git a/testdata/112-report.xml b/testdata/112-report.xml
new file mode 100644
index 0000000..41934eb
--- /dev/null
+++ b/testdata/112-report.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/generate-golden.go b/testdata/generate-golden.go
index eda2c64..f4498a4 100644
--- a/testdata/generate-golden.go
+++ b/testdata/generate-golden.go
@@ -12,6 +12,7 @@ import (
"strings"
"time"
+ "github.com/jstemmer/go-junit-report/v2/pkg/gtr"
"github.com/jstemmer/go-junit-report/v2/pkg/junit"
"github.com/jstemmer/go-junit-report/v2/pkg/parser/gotest"
)
@@ -90,21 +91,35 @@ func createReportFromInput(inputFile, outputFile string, write bool) error {
defer f.Close()
out = f
}
- return writeReport(in, out, fileSettings[inputFile])
-}
-func writeReport(in io.Reader, out io.Writer, settings Settings) error {
- parser := gotest.New(
+ settings := fileSettings[inputFile]
+
+ options := []gotest.Option{
gotest.PackageName(settings.packageName),
gotest.TimestampFunc(func() time.Time {
return time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC)
}),
- )
+ }
+
+ var parser Parser
+ if strings.HasSuffix(inputFile, ".gojson.txt") {
+ parser = gotest.NewJSON(options...)
+ } else {
+ parser = gotest.New(options...)
+ }
report, err := parser.Parse(in)
if err != nil {
return err
}
+ return writeReport(report, out, settings)
+}
+
+type Parser interface {
+ Parse(r io.Reader) (gtr.Report, error)
+}
+
+func writeReport(report gtr.Report, out io.Writer, settings Settings) error {
for i := range report.Packages {
report.Packages[i].SetProperty("go.version", "1.0")
}
@@ -124,6 +139,6 @@ func writeReport(in io.Reader, out io.Writer, settings Settings) error {
if err := enc.Flush(); err != nil {
return err
}
- _, err = fmt.Fprintf(out, "\n")
+ _, err := fmt.Fprintf(out, "\n")
return err
}