Add state to ignore trailing output

This commit is contained in:
Ingmar Stein 2017-07-26 08:06:07 +02:00
parent 0f1caf6c3e
commit 862454a821
3 changed files with 18 additions and 21 deletions

View File

@ -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",

View File

@ -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)
}
}

View File

@ -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&#xA;2 0xc4200153d0&#xA;==================&#xA;WARNING: DATA RACE&#xA;Write at 0x00c4200153d0 by goroutine 7:&#xA; race_test.TestRace.func1()&#xA; race_test.go:13 +0x3b&#xA;&#xA;Previous write at 0x00c4200153d0 by goroutine 6:&#xA; race_test.TestRace()&#xA; race_test.go:15 +0x136&#xA; testing.tRunner()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107&#xA;&#xA;Goroutine 7 (running) created at:&#xA; race_test.TestRace()&#xA; race_test.go:14 +0x125&#xA; testing.tRunner()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107&#xA;&#xA;Goroutine 6 (running) created at:&#xA; testing.(*T).Run()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:697 +0x543&#xA; testing.runTests.func1()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:882 +0xaa&#xA; testing.tRunner()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107&#xA; testing.runTests()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:888 +0x4e0&#xA; testing.(*M).Run()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:822 +0x1c3&#xA; main.main()&#xA; _test/_testmain.go:52 +0x20f&#xA;==================&#xA;testing.go:610: race detected during execution of test&#xA;exit status 1</failure>
<failure message="Failed" type="">test output&#xA;2 0xc4200153d0&#xA;==================&#xA;WARNING: DATA RACE&#xA;Write at 0x00c4200153d0 by goroutine 7:&#xA; race_test.TestRace.func1()&#xA; race_test.go:13 +0x3b&#xA;&#xA;Previous write at 0x00c4200153d0 by goroutine 6:&#xA; race_test.TestRace()&#xA; race_test.go:15 +0x136&#xA; testing.tRunner()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107&#xA;&#xA;Goroutine 7 (running) created at:&#xA; race_test.TestRace()&#xA; race_test.go:14 +0x125&#xA; testing.tRunner()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107&#xA;&#xA;Goroutine 6 (running) created at:&#xA; testing.(*T).Run()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:697 +0x543&#xA; testing.runTests.func1()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:882 +0xaa&#xA; testing.tRunner()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107&#xA; testing.runTests()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:888 +0x4e0&#xA; testing.(*M).Run()&#xA; /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:822 +0x1c3&#xA; main.main()&#xA; _test/_testmain.go:52 +0x20f&#xA;==================&#xA;testing.go:610: race detected during execution of test</failure>
</testcase>
</testsuite>
</testsuites>