| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
package check_perldiag; |
| 4 |
|
| 5 |
# ABSTRACT: check a localized version of L<perldiag> for consistency |
| 6 |
|
| 7 |
use strict; |
| 8 |
use warnings; |
| 9 |
|
| 10 |
use Pod::Find (); |
| 11 |
use Pod::POM (); |
| 12 |
|
| 13 |
my $localized_perldiag = $ARGV[0]; |
| 14 |
|
| 15 |
die "No perldiag specified" unless $localized_perldiag; |
| 16 |
|
| 17 |
my $localized_pod_filename = Pod::Find::pod_where({-inc => 1}, $localized_perldiag); |
| 18 |
my $default_pod_filename = Pod::Find::pod_where({-inc => 1}, 'perldiag'); |
| 19 |
|
| 20 |
my $parser = Pod::POM->new(); |
| 21 |
my $pom_local = $parser->parse_file($localized_pod_filename); |
| 22 |
if (!$pom_local) { |
| 23 |
die "Could not parse localized perldiag: " . $parser->error(); |
| 24 |
} |
| 25 |
|
| 26 |
my $pom_default = $parser->parse_file($default_pod_filename); |
| 27 |
if (!$pom_default) { |
| 28 |
die "Could not parse default perldiag: " . $parser->error(); |
| 29 |
} |
| 30 |
|
| 31 |
my (@local_errors, @default_errors); |
| 32 |
foreach my $item ($pom_local->head1->[1]->over->[0]->item) { |
| 33 |
push @local_errors, $item->title; |
| 34 |
} |
| 35 |
|
| 36 |
foreach my $item ($pom_default->head1->[1]->over->[0]->item) { |
| 37 |
push @default_errors, $item->title; |
| 38 |
} |
| 39 |
|
| 40 |
if ($#local_errors != $#default_errors) { |
| 41 |
print "Unequal number of errors: localized - $#local_errors, default - $#default_errors.\n"; |
| 42 |
} |
| 43 |
|
| 44 |
for (my $i = 0; $i <= $#local_errors; $i++) { |
| 45 |
if ($local_errors[$i] ne $default_errors[$i]) { |
| 46 |
print 'Got: "' . $local_errors[$i] . '", expected: "' . $default_errors[$i] . '".' . "\n"; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
__END__ |
| 51 |
|
| 52 |
=head1 NAME |
| 53 |
|
| 54 |
check_perldiag - check a localized version of perldiag for consistency |
| 55 |
|
| 56 |
=head1 SYNOPSIS |
| 57 |
|
| 58 |
From the command line: |
| 59 |
|
| 60 |
check_perldiag POD2::FR::perldiag |
| 61 |
|
| 62 |
=head1 DESCRIPTION |
| 63 |
|
| 64 |
This script compares a translated version of L<perldiag> with the default L<perldiag> installed with perl. It compares each error message in the two files and tells you if they do not match. A warning is issued if the two files contain a different number of error messages defined. |