From 3d40526af9a10621a0344a4945498026b19e1a58 Mon Sep 17 00:00:00 2001 From: Favour Chidera Okoli Date: Thu, 17 Oct 2024 20:32:56 +0100 Subject: [PATCH] Fix TestMain cleanup issue #1542 --- rollup/tests/bridge_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rollup/tests/bridge_test.go b/rollup/tests/bridge_test.go index 3ab88f843..54783e0d1 100644 --- a/rollup/tests/bridge_test.go +++ b/rollup/tests/bridge_test.go @@ -63,15 +63,16 @@ func setupDB(t *testing.T) *gorm.DB { } func TestMain(m *testing.M) { - defer func() { - if testApps != nil { - testApps.Free() - } - if rollupApp != nil { - rollupApp.Free() - } - }() - m.Run() + code := m.Run() // Run tests and capture exit code before defer + defer func() { + if testApps != nil { + testApps.Free() + } + if rollupApp != nil { + rollupApp.Free() + } + }() + os.Exit(code) // Ensure proper exit with the test code } func setupEnv(t *testing.T) {