Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence noise from corpus test #165

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions t/corpus.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ my(@testfiles, %xmlfiles, %wouldxml);
#use Pod::Simple::Debug (10);
BEGIN {
my $corpusdir = File::Spec->catdir(File::Basename::dirname(Cwd::abs_path(__FILE__)), 'corpus');
diag "Corpusdir: $corpusdir";
note "Corpusdir: $corpusdir";

opendir(my $indir, $corpusdir) or die "Can't opendir $corpusdir : $!";
my @f = map File::Spec::->catfile($corpusdir, $_), readdir($indir);
Expand Down Expand Up @@ -56,20 +56,20 @@ my $HACK = 0;

{
my @x = @testfiles;
diag "Files to test:";
while(@x) { diag " ", join(' ', splice @x,0,3); }
note "Files to test:";
while(@x) { note " ", join(' ', splice @x,0,3); }
}

require Pod::Simple::DumpAsXML;


foreach my $f (@testfiles) {
my $xml = $xmlfiles{$f};
diag "";
note "";
if($xml) {
diag "To test $f against $xml";
note "To test $f against $xml";
} else {
diag "$f has no xml to test it against";
note "$f has no xml to test it against";
}

my $outstring;
Expand All @@ -80,14 +80,12 @@ foreach my $f (@testfiles) {
undef $p;
};

if($@) {
diag "** Couldn't parse $f:\n $@";
ok 0;
is $@, '', "parsed $f without error" or do {
ok 0;
next;
}
};

ok 1, "OK, parsing $f generated " . length($outstring) . " bytes";
note "generated " . length($outstring) . " bytes";

die "Null outstring?" unless $outstring;

Expand All @@ -101,7 +99,7 @@ foreach my $f (@testfiles) {
close($out);
}
unless($xml) {
diag " (no comparison done)";
note " (no comparison done)";
ok 1;
next;
}
Expand All @@ -112,19 +110,13 @@ foreach my $f (@testfiles) {
my $xmlsource = <$in>;
close($in);

diag "There's errata!" if $outstring =~ m/start_line="-321"/;
note "There's errata!" if $outstring =~ m/start_line="-321"/;

$xmlsource =~ s/[\n\r]+/\n/g;
$outstring =~ s/[\n\r]+/\n/g;
if($xmlsource eq $outstring) {
diag " (Perfect match to $xml)";
unlink $outfilename if $HACK == 1;
ok 1;
next;
}

diag " $outfilename and $xml don't match!";
print STDERR `diff $xml $outfilename` if $HACK;
ok 0;
ok $xmlsource eq $outstring, "perfect match to $xml" or do {
diag `diff $xml $outfilename` if $HACK;
};

unlink $outfilename if $HACK == 1;
}
Loading