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

Allow polling until a test succeeds #201

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

Conversation

alexfmpe
Copy link
Contributor

@alexfmpe alexfmpe commented Nov 2, 2022

#200 turned out to be caused by the test not being yet finished in time. Duplicating the delay here

threadDelay $ (taskCount * timeForOneTask) `div` threadCount
consistently yield test success for me.
FWIW, I'm running Ryzen 1800X, meaning 8 cores 16 threads. I suspect this test might need even more time on machines with less cores, unless it's IO bound?
Another downside is this makes the test duration increase from around 26s to around 34s on my machine.

This PR suggests an alternative: to keep running the test until success, subject to a generous timeout, rather than guessing delays and coarsely trade-offing false negatives against test duration.
I've converted only the offending test to validate the approach, but AFAICT the other tests would also benefit.

where
go = do
threadDelay pollInterval
catch test $ \(e :: HUnitFailure) -> go
Copy link
Contributor Author

@alexfmpe alexfmpe Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this type is stated to be internal only:
https://hackage.haskell.org/package/HUnit-1.6.2.0/docs/Test-HUnit-Lang.html#g:1
I didn't find a suitable public API equivalent though

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.

2 participants