CI: return directly after an error occurred

This commit is contained in:
Alexander Neumann 2017-11-26 18:42:44 +01:00
parent f178cbf93d
commit a2766ffe0c

View file

@ -484,16 +484,21 @@ func main() {
os.Exit(1)
}
foundError := false
for _, f := range []func() error{env.Prepare, env.RunTests, env.Teardown} {
err := f()
if err != nil {
foundError = true
fmt.Fprintf(os.Stderr, "error: %v\n", err)
}
}
if foundError {
err := env.Prepare()
if err != nil {
fmt.Fprintf(os.Stderr, "error preparing: %v\n", err)
os.Exit(1)
}
err = env.RunTests()
if err != nil {
fmt.Fprintf(os.Stderr, "error running tests: %v\n", err)
os.Exit(2)
}
err = env.Teardown()
if err != nil {
fmt.Fprintf(os.Stderr, "error during teardown: %v\n", err)
os.Exit(3)
}
}