-if ($Test) {
- printf "1..%d\n", 1 + scalar keys %Build;
- if (@{$state->{inconsistent}}) {
- print "not ok $test\n";
- die @{$state->{inconsistent}};
- }
- print "ok $test\n";
-}
-else {
- warn @{$state->{inconsistent}} if @{$state->{inconsistent}};
-}
-
-sub generate_perlpod {
- my @output;
- my $maxlength = 0;
- foreach (@{$state->{master}}) {
- my $flags = $_->[0];
- next if $flags->{aux};
- next if $flags->{perlpod_omit};
-
- if (@$_ == 2) {
- # Heading
- push @output, "=head2 $_->[1]\n";
- } elsif (@$_ == 5) {
- # Section
- my $start = " " x (4 + $flags->{indent}) . $_->[4];
- $maxlength = length $start if length ($start) > $maxlength;
- push @output, [$start, $_->[3]];
- } elsif (@$_ == 0) {
- # blank line
- push @output, "\n";
- } else {
- my_die "Illegal length " . scalar @$_;
- }
- }
- # want at least 2 spaces padding
- $maxlength += 2;
- $maxlength = ($maxlength + 3) & ~3;
- # sprintf gives $1.....$2 where ... are spaces:
- return unexpand (map {ref $_ ? sprintf "%-${maxlength}s%s\n", @$_ : $_}
- @output);
-}
+# For testing, generated files must be present and we're rebuilding nothing.
+# For normal rebuilding, generated files may not be present, and we mute
+# warnings about inconsistencies in any file we're about to rebuild.
+my $state = $Test
+ ? get_pod_metadata(0, sub {
+ printf "1..%d\n", 1 + scalar keys %Build;
+ if (@_) {
+ print "not ok $test # got Pod metadata\n";
+ die @_;
+ }
+ print "ok $test # got Pod metadata\n";
+ })
+ : get_pod_metadata(1, sub { warn @_ if @_ }, values %Build);