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:
itamarb
2015-04-26 19:54:56 +03:00
committed by itamar b
parent 672f4cd7e2
commit a34e6b2365
2 changed files with 21 additions and 0 deletions

View File

@ -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)
}
}