mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-06 21:48:08 -05:00
Fix 1.7 compatbility
This commit is contained in:
parent
24d394d799
commit
faed36da23
@ -2,6 +2,8 @@ language: go
|
|||||||
|
|
||||||
go:
|
go:
|
||||||
- tip
|
- tip
|
||||||
|
- 1.7
|
||||||
|
- 1.6
|
||||||
- 1.5
|
- 1.5
|
||||||
- 1.4.2
|
- 1.4.2
|
||||||
- 1.3.3
|
- 1.3.3
|
||||||
|
@ -436,6 +436,52 @@ var testCases = []TestCase{
|
|||||||
Result: parser.PASS,
|
Result: parser.PASS,
|
||||||
Output: []string{},
|
Output: []string{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "TestFour",
|
||||||
|
Time: 20,
|
||||||
|
Result: parser.FAIL,
|
||||||
|
Output: []string{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "TestFour/#00",
|
||||||
|
Time: 0,
|
||||||
|
Result: parser.FAIL,
|
||||||
|
Output: []string{
|
||||||
|
"example.go:12: Expected abc OBTAINED:",
|
||||||
|
" xyz",
|
||||||
|
"example.go:123: Expected and obtained are different.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "TestFour/#01",
|
||||||
|
Time: 0,
|
||||||
|
Result: parser.SKIP,
|
||||||
|
Output: []string{
|
||||||
|
"example.go:1234: Not supported yet.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "TestFour/#02",
|
||||||
|
Time: 0,
|
||||||
|
Result: parser.PASS,
|
||||||
|
Output: []string{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "TestFive",
|
||||||
|
Time: 0,
|
||||||
|
Result: parser.SKIP,
|
||||||
|
Output: []string{
|
||||||
|
"example.go:1392: Not supported yet.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "TestSix",
|
||||||
|
Time: 0,
|
||||||
|
Result: parser.FAIL,
|
||||||
|
Output: []string{
|
||||||
|
"example.go:371: This should not fail!",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -499,7 +545,7 @@ func TestParser(t *testing.T) {
|
|||||||
testOutput := strings.Join(test.Output, "\n")
|
testOutput := strings.Join(test.Output, "\n")
|
||||||
expTestOutput := strings.Join(expTest.Output, "\n")
|
expTestOutput := strings.Join(expTest.Output, "\n")
|
||||||
if testOutput != expTestOutput {
|
if testOutput != expTestOutput {
|
||||||
t.Errorf("Test.Output ==\n%s\n, want\n%s", testOutput, expTestOutput)
|
t.Errorf("Test.Output (%s) ==\n%s\n, want\n%s", test.Name, testOutput, expTestOutput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if pkg.CoveragePct != expPkg.CoveragePct {
|
if pkg.CoveragePct != expPkg.CoveragePct {
|
||||||
|
@ -43,6 +43,7 @@ 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$`)
|
regexCoverage = regexp.MustCompile(`^coverage:\s+(\d+\.\d+)%\s+of\s+statements$`)
|
||||||
regexResult = regexp.MustCompile(`^(ok|FAIL)\s+(.+)\s(\d+\.\d+)s(?:\s+coverage:\s+(\d+\.\d+)%\s+of\s+statements)?$`)
|
regexResult = regexp.MustCompile(`^(ok|FAIL)\s+(.+)\s(\d+\.\d+)s(?:\s+coverage:\s+(\d+\.\d+)%\s+of\s+statements)?$`)
|
||||||
|
regexOutput = regexp.MustCompile(`( )*\t(.*)`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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
|
||||||
@ -123,13 +124,15 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
|
|||||||
testsTime += testTime
|
testsTime += testTime
|
||||||
} else if matches := regexCoverage.FindStringSubmatch(line); len(matches) == 2 {
|
} else if matches := regexCoverage.FindStringSubmatch(line); len(matches) == 2 {
|
||||||
coveragePct = matches[1]
|
coveragePct = matches[1]
|
||||||
} else if strings.HasPrefix(line, "\t") {
|
} else if matches := regexOutput.FindStringSubmatch(line); len(matches) == 3 {
|
||||||
// test output
|
// Sub-tests start with one or more series of 4-space indents, followed by a hard tab,
|
||||||
|
// followed by the test output
|
||||||
|
// Top-level tests start with a hard tab.
|
||||||
test := findTest(tests, cur)
|
test := findTest(tests, cur)
|
||||||
if test == nil {
|
if test == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
test.Output = append(test.Output, line[1:])
|
test.Output = append(test.Output, matches[2])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,5 +22,23 @@
|
|||||||
--- PASS: TestThree/a#1 (0.02s)
|
--- PASS: TestThree/a#1 (0.02s)
|
||||||
--- PASS: TestThree/a#1/b#1 (0.03s)
|
--- PASS: TestThree/a#1/b#1 (0.03s)
|
||||||
--- PASS: TestThree/a#1/b#1/c#1 (0.04s)
|
--- PASS: TestThree/a#1/b#1/c#1 (0.04s)
|
||||||
PASS
|
=== RUN TestFour
|
||||||
ok package/name 0.050s
|
=== RUN TestFour/#00
|
||||||
|
=== RUN TestFour/#01
|
||||||
|
=== RUN TestFour/#02
|
||||||
|
--- FAIL: TestFour (0.02s)
|
||||||
|
--- FAIL: TestFour/#00 (0.00s)
|
||||||
|
example.go:12: Expected abc OBTAINED:
|
||||||
|
xyz
|
||||||
|
example.go:123: Expected and obtained are different.
|
||||||
|
--- SKIP: TestFour/#01 (0.00s)
|
||||||
|
example.go:1234: Not supported yet.
|
||||||
|
--- PASS: TestFour/#02 (0.00s)
|
||||||
|
=== RUN TestFive
|
||||||
|
--- SKIP: TestFive (0.00s)
|
||||||
|
example.go:1392: Not supported yet.
|
||||||
|
=== RUN TestSix
|
||||||
|
--- FAIL: TestSix (0.00s)
|
||||||
|
example.go:371: This should not fail!
|
||||||
|
FAIL
|
||||||
|
FAIL package/name 0.050s
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite tests="12" failures="0" time="0.050" name="package/name">
|
<testsuite tests="18" failures="3" time="0.050" name="package/name">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="go.version" value="go1.7"></property>
|
<property name="go.version" value="1.0"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase classname="name" name="TestOne" time="0.010"></testcase>
|
<testcase classname="name" name="TestOne" time="0.010"></testcase>
|
||||||
<testcase classname="name" name="TestOne/Child" time="0.020"></testcase>
|
<testcase classname="name" name="TestOne/Child" time="0.020"></testcase>
|
||||||
@ -16,5 +16,21 @@
|
|||||||
<testcase classname="name" name="TestThree/a#1" time="0.020"></testcase>
|
<testcase classname="name" name="TestThree/a#1" time="0.020"></testcase>
|
||||||
<testcase classname="name" name="TestThree/a#1/b#1" time="0.030"></testcase>
|
<testcase classname="name" name="TestThree/a#1/b#1" time="0.030"></testcase>
|
||||||
<testcase classname="name" name="TestThree/a#1/b#1/c#1" time="0.040"></testcase>
|
<testcase classname="name" name="TestThree/a#1/b#1/c#1" time="0.040"></testcase>
|
||||||
|
<testcase classname="name" name="TestFour" time="0.020">
|
||||||
|
<failure message="Failed" type=""></failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="name" name="TestFour/#00" time="0.000">
|
||||||
|
<failure message="Failed" type="">example.go:12: Expected abc OBTAINED:
	xyz
example.go:123: Expected and obtained are different.</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="name" name="TestFour/#01" time="0.000">
|
||||||
|
<skipped message="example.go:1234: Not supported yet."></skipped>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="name" name="TestFour/#02" time="0.000"></testcase>
|
||||||
|
<testcase classname="name" name="TestFive" time="0.000">
|
||||||
|
<skipped message="example.go:1392: Not supported yet."></skipped>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="name" name="TestSix" time="0.000">
|
||||||
|
<failure message="Failed" type="">example.go:371: This should not fail!</failure>
|
||||||
|
</testcase>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user