Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix TestPoolPanic in gopool #155

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Conversation

ag9920
Copy link

@ag9920 ag9920 commented Sep 28, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant