| 1 |
use Test2::V0; |
| 2 |
|
| 3 |
use App::Yath::Tester qw/yath/; |
| 4 |
|
| 5 |
my $dir = __FILE__; |
| 6 |
$dir =~ s{\.t$}{}g; |
| 7 |
$dir =~ s{^\./}{}; |
| 8 |
|
| 9 |
# Test 1: resource-timeout fires when a resource stalls |
| 10 |
# StalledResource lets the first test run, then blocks all subsequent tests. |
| 11 |
# With --resource-timeout=2, yath should abort after 2 seconds of being unable |
| 12 |
# to start any new tests. |
| 13 |
yath( |
| 14 |
command => 'test', |
| 15 |
args => [$dir, '--ext=tx', '-j2', "-D$dir", '-R+StalledResource', '--resource-timeout=2'], |
| 16 |
exit => T(), |
| 17 |
test => sub { |
| 18 |
my $out = shift; |
| 19 |
like($out->{output}, qr/Resource timeout after/, "Got resource timeout message"); |
| 20 |
}, |
| 21 |
); |
| 22 |
|
| 23 |
# Test 2: no timeout when --resource-timeout is 0 (disabled) and tests complete normally |
| 24 |
# Without the stalled resource, both tests should pass fine and no timeout message appears. |
| 25 |
yath( |
| 26 |
command => 'test', |
| 27 |
args => [$dir, '--ext=tx', '-j2', '--resource-timeout=0'], |
| 28 |
exit => 0, |
| 29 |
test => sub { |
| 30 |
my $out = shift; |
| 31 |
unlike($out->{output}, qr/Resource timeout after/, "No resource timeout when disabled"); |
| 32 |
}, |
| 33 |
); |
| 34 |
|
| 35 |
done_testing; |