mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-05-20 10:54:28 -05:00
Add state to ignore trailing output
This commit is contained in:
parent
0f1caf6c3e
commit
862454a821
@ -71,9 +71,7 @@ var testCases = []TestCase{
|
||||
Name: "TestTwo",
|
||||
Time: 130,
|
||||
Result: parser.PASS,
|
||||
Output: []string{
|
||||
"exit status 1",
|
||||
},
|
||||
Output: []string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -203,9 +201,7 @@ var testCases = []TestCase{
|
||||
Name: "TestTwo",
|
||||
Time: 130,
|
||||
Result: parser.PASS,
|
||||
Output: []string{
|
||||
"exit status 1",
|
||||
},
|
||||
Output: []string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -312,9 +308,7 @@ var testCases = []TestCase{
|
||||
Name: "TestB",
|
||||
Time: 300,
|
||||
Result: parser.PASS,
|
||||
Output: []string{
|
||||
"coverage: 10% of statements",
|
||||
},
|
||||
Output: []string{},
|
||||
},
|
||||
},
|
||||
CoveragePct: "10.0",
|
||||
@ -697,7 +691,6 @@ var testCases = []TestCase{
|
||||
" _test/_testmain.go:52 +0x20f",
|
||||
"==================",
|
||||
"testing.go:610: race detected during execution of test",
|
||||
"exit status 1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -724,9 +717,7 @@ var testCases = []TestCase{
|
||||
Name: "TestB",
|
||||
Time: 300,
|
||||
Result: parser.PASS,
|
||||
Output: []string{
|
||||
"coverage: 10% of statements in fmt, encoding/xml",
|
||||
},
|
||||
Output: []string{},
|
||||
},
|
||||
},
|
||||
CoveragePct: "10.0",
|
||||
|
@ -64,6 +64,9 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
|
||||
// current test
|
||||
var cur string
|
||||
|
||||
// keep track if we've already seen a summary for the current test
|
||||
var seenSummary bool
|
||||
|
||||
// coverage percentage report for current package
|
||||
var coveragePct string
|
||||
|
||||
@ -98,6 +101,7 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
|
||||
|
||||
// clear the current build package, so output lines won't be added to that build
|
||||
capturedPackage = ""
|
||||
seenSummary = false
|
||||
} else if matches := regexResult.FindStringSubmatch(line); len(matches) == 6 {
|
||||
if matches[5] != "" {
|
||||
coveragePct = matches[5]
|
||||
@ -172,15 +176,17 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
|
||||
// current line is build failure capture for the current built package
|
||||
packageCaptures[capturedPackage] = append(packageCaptures[capturedPackage], line)
|
||||
} else if regexSummary.MatchString(line) {
|
||||
// ignore
|
||||
// don't store any output after the summary
|
||||
seenSummary = true
|
||||
} else {
|
||||
test := findTest(tests, cur)
|
||||
if test == nil {
|
||||
// buffer anything else that we didn't recognize
|
||||
buffer = append(buffer, line)
|
||||
} else {
|
||||
test.Output = append(test.Output, line)
|
||||
if !seenSummary {
|
||||
if test := findTest(tests, cur); test != nil {
|
||||
test.Output = append(test.Output, line)
|
||||
continue
|
||||
}
|
||||
}
|
||||
// buffer anything else that we didn't recognize
|
||||
buffer = append(buffer, line)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<property name="go.version" value="1.0"></property>
|
||||
</properties>
|
||||
<testcase classname="race_test" name="TestRace" time="0.000">
|
||||
<failure message="Failed" type="">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
exit status 1</failure>
|
||||
<failure message="Failed" type="">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</failure>
|
||||
</testcase>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
Loading…
x
Reference in New Issue
Block a user