From 53cf346cdfb484e59cdebef654bcd820d51f84db Mon Sep 17 00:00:00 2001 From: Harsha Narayana Date: Thu, 26 Oct 2023 17:32:35 +0530 Subject: [PATCH] fixed broken exit code settings during panic recovery --- pkg/env/env.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/env/env.go b/pkg/env/env.go index 8a8d4d36..9b3ed152 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -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 @@ -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()