mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-07-03 20:52:47 -05:00
gtr: Handle coverage events
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -1618,7 +1619,12 @@ func testNewParser(input, reportFile, packageName string, t *testing.T) {
|
||||
func modifyForBackwardsCompat(testsuites junit.Testsuites) junit.Testsuites {
|
||||
testsuites.XMLName.Local = ""
|
||||
for i, suite := range testsuites.Suites {
|
||||
if covIdx, covProp := getProperty("coverage.statements.pct", suite.Properties); covIdx > -1 {
|
||||
pct, _ := strconv.ParseFloat(covProp.Value, 64)
|
||||
testsuites.Suites[i].Properties[covIdx].Value = fmt.Sprintf("%.2f", pct)
|
||||
}
|
||||
testsuites.Suites[i].Properties = dropProperty("go.version", suite.Properties)
|
||||
|
||||
for j := range suite.Testcases {
|
||||
testsuites.Suites[i].Testcases[j].Classname = suite.Name
|
||||
}
|
||||
@ -1636,6 +1642,15 @@ func dropProperty(name string, properties []junit.Property) []junit.Property {
|
||||
return props
|
||||
}
|
||||
|
||||
func getProperty(name string, properties []junit.Property) (int, junit.Property) {
|
||||
for i, prop := range properties {
|
||||
if prop.Name == name {
|
||||
return i, prop
|
||||
}
|
||||
}
|
||||
return -1, junit.Property{}
|
||||
}
|
||||
|
||||
func toXML(testsuites junit.Testsuites) (string, error) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
|
Reference in New Issue
Block a user