How could I time out hanging tests in a Perl test harness?
I tried using the Test::Timer
module, but I can't seem to make it link up nicely with the TAP::Harness
in order to have an embedded timeout function for each test. Plus, I don't want to test if a bit of code takes x
time to complete, I just want to run my tests and timeout in case they hung for any reason.
There was a similar question on PerlMonks recently.
Install Time::Limit.
This module will allow you to set time limits for individual test files:
use Test::More;
use Time::Limit "30"; # 30 seconds, quote marks are necessary!
Or set an overall time limit for running the entire test suite:
prove -MTime::Limit=120 t/*.t
If you're using forkprove
instead of prove
, then you need the time limiter to kill the entire process group:
forkprove -MTime::Limit=-group,120 t/*.t
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With