mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-06-30 19:42:46 -05:00
adding 'set-exit-code' flag
Defaults to false. When true, sets the exit-code to 1 if any tests failed. This is useful for automation.
This commit is contained in:
@ -9,11 +9,13 @@ import (
|
||||
var (
|
||||
noXMLHeader bool
|
||||
packageName string
|
||||
setExitCode bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&noXMLHeader, "no-xml-header", false, "do not print xml header")
|
||||
flag.StringVar(&packageName, "package-name", "", "specify a package name (compiled test have no package name in output)")
|
||||
flag.BoolVar(&setExitCode, "set-exit-code", false, "set exit code to 1 if tests failed")
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -32,4 +34,8 @@ func main() {
|
||||
fmt.Printf("Error writing XML: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if setExitCode && report.Failures() > 0 {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user