From be62c3ce27a725011b36e1a0f7fe5832db977db1 Mon Sep 17 00:00:00 2001 From: georgehao Date: Tue, 4 Feb 2025 15:52:24 +0800 Subject: [PATCH] add panic log --- internal/syncx/mutex_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/syncx/mutex_test.go b/internal/syncx/mutex_test.go index d318d02978..f56c94ce73 100644 --- a/internal/syncx/mutex_test.go +++ b/internal/syncx/mutex_test.go @@ -46,7 +46,9 @@ func TestClosableMutex_Unlock(t *testing.T) { cm.MustLock() cm.Unlock() defer func() { - if r := recover(); r == nil { + if r := recover(); r != nil { + t.Log("panic detected:", r) // Log the panic message + } else { t.Fatal("expected Unlock to panic when already unlocked") } }() @@ -60,8 +62,10 @@ func TestClosableMutex_Close(t *testing.T) { cm.MustLock() cm.Close() defer func() { - if r := recover(); r == nil { - t.Fatal("expected Close to panic when already closed") + if r := recover(); r != nil { + t.Log("panic detected:", r) // Log the panic message + } else { + t.Fatal("expected Close to panic when already closed", r) } }() cm.Close()