Skip to content

Commit 7273da3

Browse files
committed
t/01-l10n.t: Skip tests properly
If a PO file is not found, e.g. the tests are run out of the source tree, t/01-l10n.t failed on mismatching test plan: t/01-l10n.t .. 1..12 # Skipping tests for 'de': locale/de/LC_MESSAGES/rdapper.po not found. # Skipping tests for 'es': locale/es/LC_MESSAGES/rdapper.po not found. # Skipping tests for 'fr': locale/fr/LC_MESSAGES/rdapper.po not found. # Skipping tests for 'pt': locale/pt/LC_MESSAGES/rdapper.po not found. not ok 1 - planned to run 12 but done_testing() expects 0 # Failed test 'planned to run 12 but done_testing() expects 0' # at t/01-l10n.t line 56. # Looks like you planned 12 tests but ran 1. # Looks like you failed 1 test of 1 run. Dubious, test returned 1 (wstat 256, 0x100) Failed 12/12 subtests This patch skips the tests using skip() to count the skipped tests properly. (Next fix should be testing MO files instead of PO files.)
1 parent 806012e commit 7273da3

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

t/01-l10n.t

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ plan tests => $total_tests;
3737
foreach my $lang_code ( sort keys %lang_tests ) {
3838
my $po_file = File::Spec->catfile('locale', $lang_code, 'LC_MESSAGES', 'rdapper.po');
3939

40-
unless (-f $po_file) {
41-
diag("Skipping tests for '$lang_code': $po_file not found.");
42-
next;
43-
}
40+
SKIP: {
41+
skip("Skipping tests for '$lang_code': $po_file not found.",
42+
scalar keys %{ $lang_tests{$lang_code} }) unless -f $po_file;
4443

45-
# Parse the .po file into a hash
46-
my %translations = parse_po_file($po_file);
44+
# Parse the .po file into a hash
45+
my %translations = parse_po_file($po_file);
4746

48-
# Run the specific tests for this language
49-
foreach my $original ( sort keys %{ $lang_tests{$lang_code} } ) {
50-
my $expected = $lang_tests{$lang_code}->{$original};
51-
my $translated = $translations{$original} // '';
52-
is($translated, $expected, "[$lang_code] '$original' -> '$expected'");
47+
# Run the specific tests for this language
48+
foreach my $original ( sort keys %{ $lang_tests{$lang_code} } ) {
49+
my $expected = $lang_tests{$lang_code}->{$original};
50+
my $translated = $translations{$original} // '';
51+
is($translated, $expected, "[$lang_code] '$original' -> '$expected'");
52+
}
5353
}
5454
}
5555

@@ -73,4 +73,4 @@ sub parse_po_file {
7373
}
7474
close $fh;
7575
return %data;
76-
}
76+
}

0 commit comments

Comments
 (0)