mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-20 04:28:08 -05:00
Capture more test output, e.g. race detection results
This commit is contained in:
parent
15422cf504
commit
01656fa7f4
@ -71,7 +71,9 @@ var testCases = []TestCase{
|
|||||||
Name: "TestTwo",
|
Name: "TestTwo",
|
||||||
Time: 130,
|
Time: 130,
|
||||||
Result: parser.PASS,
|
Result: parser.PASS,
|
||||||
Output: []string{},
|
Output: []string{
|
||||||
|
"exit status 1",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -201,7 +203,9 @@ var testCases = []TestCase{
|
|||||||
Name: "TestTwo",
|
Name: "TestTwo",
|
||||||
Time: 130,
|
Time: 130,
|
||||||
Result: parser.PASS,
|
Result: parser.PASS,
|
||||||
Output: []string{},
|
Output: []string{
|
||||||
|
"exit status 1",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -642,6 +646,63 @@ var testCases = []TestCase{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "17-race.txt",
|
||||||
|
reportName: "17-report.xml",
|
||||||
|
report: &parser.Report{
|
||||||
|
Packages: []parser.Package{
|
||||||
|
{
|
||||||
|
Name: "race_test",
|
||||||
|
Time: 15,
|
||||||
|
Tests: []*parser.Test{
|
||||||
|
{
|
||||||
|
Name: "TestRace",
|
||||||
|
Time: 0,
|
||||||
|
Result: parser.FAIL,
|
||||||
|
Output: []string{
|
||||||
|
"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",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "18-coverpkg.txt",
|
name: "18-coverpkg.txt",
|
||||||
reportName: "18-report.xml",
|
reportName: "18-report.xml",
|
||||||
|
@ -41,9 +41,10 @@ type Test struct {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
regexStatus = regexp.MustCompile(`^\s*--- (PASS|FAIL|SKIP): (.+) \((\d+\.\d+)(?: seconds|s)\)$`)
|
regexStatus = regexp.MustCompile(`^\s*--- (PASS|FAIL|SKIP): (.+) \((\d+\.\d+)(?: seconds|s)\)$`)
|
||||||
regexCoverage = regexp.MustCompile(`^coverage:\s+(\d+\.\d+)%\s+of\s+statements(?:\sin\s.+)?$`)
|
regexCoverage = regexp.MustCompile(`^coverage:\s+(\d+(?:\.\d+)?)%\s+of\s+statements(?:\sin\s.+)?$`)
|
||||||
regexResult = regexp.MustCompile(`^(ok|FAIL)\s+([^ ]+)\s+(?:(\d+\.\d+)s|(\[\w+ failed]))(?:\s+coverage:\s+(\d+\.\d+)%\sof\sstatements(?:\sin\s.+)?)?$`)
|
regexResult = regexp.MustCompile(`^(ok|FAIL)\s+([^ ]+)\s+(?:(\d+\.\d+)s|(\[\w+ failed]))(?:\s+coverage:\s+(\d+(?:\.\d+))%\sof\sstatements(?:\sin\s.+)?)?$`)
|
||||||
regexOutput = regexp.MustCompile(`( )*\t(.*)`)
|
regexOutput = regexp.MustCompile(`( )*\t(.*)`)
|
||||||
|
regexSummary = regexp.MustCompile(`^(PASS|FAIL|SKIP)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse parses go test output from reader r and returns a report with the
|
// Parse parses go test output from reader r and returns a report with the
|
||||||
@ -170,9 +171,16 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
|
|||||||
} else if capturedPackage != "" {
|
} else if capturedPackage != "" {
|
||||||
// current line is build failure capture for the current built package
|
// current line is build failure capture for the current built package
|
||||||
packageCaptures[capturedPackage] = append(packageCaptures[capturedPackage], line)
|
packageCaptures[capturedPackage] = append(packageCaptures[capturedPackage], line)
|
||||||
|
} else if regexSummary.MatchString(line) {
|
||||||
|
// ignore
|
||||||
} else {
|
} else {
|
||||||
|
test := findTest(tests, cur)
|
||||||
|
if test == nil {
|
||||||
// buffer anything else that we didn't recognize
|
// buffer anything else that we didn't recognize
|
||||||
buffer = append(buffer, line)
|
buffer = append(buffer, line)
|
||||||
|
} else {
|
||||||
|
test.Output = append(test.Output, line)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
40
tests/17-race.txt
Normal file
40
tests/17-race.txt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
=== RUN TestRace
|
||||||
|
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
|
||||||
|
==================
|
||||||
|
--- FAIL: TestRace (0.00s)
|
||||||
|
testing.go:610: race detected during execution of test
|
||||||
|
FAIL
|
||||||
|
exit status 1
|
||||||
|
FAIL race_test 0.015s
|
11
tests/17-report.xml
Normal file
11
tests/17-report.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<testsuites>
|
||||||
|
<testsuite tests="1" failures="1" time="0.015" name="race_test">
|
||||||
|
<properties>
|
||||||
|
<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>
|
||||||
|
</testcase>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
Loading…
x
Reference in New Issue
Block a user