Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#342 from harshanarayana/bug/GIT-32…
Browse files Browse the repository at this point in the history
…8/mark-test-as-failed-on-panic-recovery

fixed broken exit code settings during panic recovery
  • Loading branch information
k8s-ci-robot authored Oct 27, 2023
2 parents a4b901c + 53cf346 commit 365c4a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (e *testEnv) Finish(funcs ...Func) types.Environment {
// package. This method will all Env.Setup operations prior to
// starting the tests and run all Env.Finish operations after
// before completing the suite.
func (e *testEnv) Run(m *testing.M) int {
func (e *testEnv) Run(m *testing.M) (exitCode int) {
e.panicOnMissingContext()
ctx := e.ctx

Expand All @@ -359,6 +359,9 @@ func (e *testEnv) Run(m *testing.M) int {
panic(rErr)
}
klog.Errorf("Recovering from panic and running finish actions: %s, stack: %s", rErr, string(debug.Stack()))
// Set this exit code value to non 0 to indicate that the test suite has failed
// Not doing this will mark the test suite as passed even though there was a panic
exitCode = 1
}

finishes := e.getFinishActions()
Expand Down

0 comments on commit 365c4a4

Please sign in to comment.