[rvelaz] Fix test report when the program writes to stdout

This commit is contained in:
rvelaz 2018-01-05 17:07:20 +01:00
parent a009038a63
commit 0e171eb667
4 changed files with 43 additions and 1 deletions

View File

@ -738,6 +738,32 @@ var testCases = []TestCase{
},
},
},
{
name: "19-pass.txt",
reportName: "19-report.xml",
report: &parser.Report{
Packages: []parser.Package{
{
Name: "package/name",
Time: 160,
Tests: []*parser.Test{
{
Name: "TestZ",
Time: 60,
Result: parser.PASS,
Output: []string{},
},
{
Name: "TestA",
Time: 100,
Result: parser.PASS,
Output: []string{},
},
},
},
},
},
},
}
func TestParser(t *testing.T) {

View File

@ -40,7 +40,7 @@ type Test struct {
}
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.+)?$`)
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(.*)`)

6
tests/19-pass.txt Normal file
View File

@ -0,0 +1,6 @@
=== RUN TestZ
some inline text--- PASS: TestZ (0.06 seconds)
=== RUN TestA
--- PASS: TestA (0.10 seconds)
PASS
ok package/name 0.160s

10
tests/19-report.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite tests="2" failures="0" time="0.160" name="package/name">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="name" name="TestZ" time="0.060"></testcase>
<testcase classname="name" name="TestA" time="0.100"></testcase>
</testsuite>
</testsuites>