Skip to content

Commit

Permalink
corpus.t: document $HACK variable, don't write files by default
Browse files Browse the repository at this point in the history
Having .xml_out files lying around is mainly useful for debugging
failing tests, but shouldn't be the default because otherwise testing
fails if t/ is a read-only directory.
  • Loading branch information
mauke authored and khwilliamson committed Jun 29, 2024
1 parent b171dec commit 2ec503c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions t/corpus.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ BEGIN {
plan tests => (2*@testfiles - 1);
}

my $HACK = 1;
my $HACK = 0;
# 1: write generated XML dump to *.xml_out files for debugging
# 2: write generated XML to *.xml files, updating/overwriting test corpus

#@testfiles = ('nonesuch.txt');

{
Expand Down Expand Up @@ -115,13 +118,13 @@ foreach my $f (@testfiles) {
$outstring =~ s/[\n\r]+/\n/g;
if($xmlsource eq $outstring) {
diag " (Perfect match to $xml)";
unlink $outfilename unless $outfilename =~ m/\.xml$/is;
unlink $outfilename if $HACK == 1;
ok 1;
next;
}

diag " $outfilename and $xml don't match!";
print STDERR `diff $xml $outfilename`;
print STDERR `diff $xml $outfilename` if $HACK;
ok 0;

}

0 comments on commit 2ec503c

Please sign in to comment.