mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-05 05:00:15 -05:00
add flag -no-xml-header
This commit is contained in:
parent
6982e7a3a3
commit
8cd3db55e5
@ -1,11 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
var noXmlHeader bool
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&noXmlHeader, "no-xml-header", false, "do not print xml header")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
// Read input
|
||||
report, err := Parse(os.Stdin)
|
||||
if err != nil {
|
||||
@ -14,7 +23,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Write xml
|
||||
err = JUnitReportXML(report, os.Stdout)
|
||||
err = JUnitReportXML(report, noXmlHeader, os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Printf("Error writing XML: %s\n", err)
|
||||
os.Exit(1)
|
||||
|
@ -52,7 +52,7 @@ func NewJUnitProperty(name, value string) JUnitProperty {
|
||||
|
||||
// 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 *Report, w io.Writer) error {
|
||||
func JUnitReportXML(report *Report, noXmlHeader bool, w io.Writer) error {
|
||||
suites := []JUnitTestSuite{}
|
||||
|
||||
// convert Report to JUnit test suites
|
||||
@ -111,7 +111,9 @@ func JUnitReportXML(report *Report, w io.Writer) error {
|
||||
|
||||
writer := bufio.NewWriter(w)
|
||||
|
||||
writer.WriteString(xml.Header)
|
||||
if !noXmlHeader {
|
||||
writer.WriteString(xml.Header)
|
||||
}
|
||||
writer.Write(bytes)
|
||||
writer.WriteByte('\n')
|
||||
writer.Flush()
|
||||
|
Loading…
x
Reference in New Issue
Block a user