| 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: Without --fail-on-resource-skip, tests with unavailable resources |
| 10 |
# are skipped and the overall run succeeds (exit 0). |
| 11 |
yath( |
| 12 |
command => 'test', |
| 13 |
args => [$dir, '--ext=tx', "-D$dir", '-R+UnavailableResource'], |
| 14 |
exit => 0, |
| 15 |
test => sub { |
| 16 |
my $out = shift; |
| 17 |
like($out->{output}, qr/SKIP/i, "Output mentions skipped tests"); |
| 18 |
unlike($out->{output}, qr/FAILED/i, "No failures reported"); |
| 19 |
}, |
| 20 |
); |
| 21 |
|
| 22 |
# Test 2: With --fail-on-resource-skip, tests with unavailable resources |
| 23 |
# are marked as failures and the overall run fails (exit != 0). |
| 24 |
yath( |
| 25 |
command => 'test', |
| 26 |
args => [$dir, '--ext=tx', "-D$dir", '-R+UnavailableResource', '--fail-on-resource-skip'], |
| 27 |
exit => T(), |
| 28 |
test => sub { |
| 29 |
my $out = shift; |
| 30 |
like($out->{output}, qr/FAIL.*Some resources are not available/s, "Output shows failures for unavailable resources"); |
| 31 |
like($out->{output}, qr/FAILED/, "Overall result is FAILED"); |
| 32 |
like($out->{output}, qr/UnavailableResource/, "Output mentions the unavailable resource name"); |
| 33 |
}, |
| 34 |
); |
| 35 |
|
| 36 |
# Test 3: With --no-fail-on-resource-skip (explicit default), same as test 1. |
| 37 |
yath( |
| 38 |
command => 'test', |
| 39 |
args => [$dir, '--ext=tx', "-D$dir", '-R+UnavailableResource', '--no-fail-on-resource-skip'], |
| 40 |
exit => 0, |
| 41 |
test => sub { |
| 42 |
my $out = shift; |
| 43 |
like($out->{output}, qr/SKIP/i, "Output mentions skipped tests with explicit --no-fail-on-resource-skip"); |
| 44 |
unlike($out->{output}, qr/FAILED/i, "No failures with explicit --no-fail-on-resource-skip"); |
| 45 |
}, |
| 46 |
); |
| 47 |
|
| 48 |
done_testing; |