gopkg icon indicating copy to clipboard operation
gopkg copied to clipboard

test: fix TestPoolPanic in gopool

Open ag9920 opened this issue 2 years ago • 0 comments

This PR tries to fix the TestPoolPanic function in gopool. Currently it only contains the following test logic

p := NewPool("test", 100, NewConfig())
p.Go(testPanicFunc)

Maybe the original idea is to see if any panic occurs. But actually, the p.Go goroutine is not guaranteed to be executed before the main goroutine exits. Chances are testPanicFunc never get called. So this test case is actually useless.

I add sync.WaitGroup to wait for sub goroutines to finish. Also we need to check if SetPanicHandler is working correctly, so I compared the actual execute times with expected times to see if provided panic handler does get called every time when panic occurs.

ag9920 avatar Sep 28 '22 04:09 ag9920