fix: os.Exit() kills any deferred cleanup functions

os.Exit() itself is now also a deferred function, which will be the last to run.
This commit is contained in:
2024-02-05 11:59:50 -06:00
parent 79f68187bf
commit 02afe67ac3
4 changed files with 24 additions and 4 deletions

View File

@@ -14,6 +14,11 @@ var (
)
func TestMain(m *testing.M) {
ret := 1
defer func() {
os.Exit(ret)
}()
r, err := miniredis.Run()
if err != nil {
panic(err)
@@ -26,7 +31,7 @@ func TestMain(m *testing.M) {
}
defer rh.Close()
os.Exit(m.Run())
ret = m.Run()
}
func TestRedisLogin(t *testing.T) {