mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-07-06 14:02:52 -05:00
Add "go-version" flag
Makes it so that the value of the "go.version" property in the output XML can be customized by the caller using the "go-version" flag. If the flag is unspecified, falls back to the previous behavior of using runtime.Version() as the value. Fixes #48
This commit is contained in:
@ -59,7 +59,7 @@ type JUnitFailure struct {
|
||||
|
||||
// JUnitReportXML writes a JUnit xml representation of the given report to w
|
||||
// in the format described at http://windyroad.org/dl/Open%20Source/JUnit.xsd
|
||||
func JUnitReportXML(report *parser.Report, noXMLHeader bool, w io.Writer) error {
|
||||
func JUnitReportXML(report *parser.Report, noXMLHeader bool, goVersion string, w io.Writer) error {
|
||||
suites := JUnitTestSuites{}
|
||||
|
||||
// convert Report to JUnit test suites
|
||||
@ -79,7 +79,11 @@ func JUnitReportXML(report *parser.Report, noXMLHeader bool, w io.Writer) error
|
||||
}
|
||||
|
||||
// properties
|
||||
ts.Properties = append(ts.Properties, JUnitProperty{"go.version", runtime.Version()})
|
||||
if goVersion == "" {
|
||||
// if goVersion was not specified as a flag, fall back to version reported by runtime
|
||||
goVersion = runtime.Version()
|
||||
}
|
||||
ts.Properties = append(ts.Properties, JUnitProperty{"go.version", goVersion})
|
||||
if pkg.CoveragePct != "" {
|
||||
ts.Properties = append(ts.Properties, JUnitProperty{"coverage.statements.pct", pkg.CoveragePct})
|
||||
}
|
||||
|
Reference in New Issue
Block a user