Skip to content

Commit

Permalink
test for raw content
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Oct 12, 2016
1 parent b6f49af commit d15bc93
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions t/raw.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use strict;
use warnings;
use Test::More;
use constant HAVE_DIFF => eval {
require Test::Differences;
Test::Differences::unified_diff();
1;
};

use CPAN::Changes::Parser;

sub _eq {
if (HAVE_DIFF) {
Test::Differences::eq_or_diff(@_[0..2], { context => 5 });
}
else {
goto &Test::More::is;
}
}

for my $log (@ARGV ? @ARGV : glob('corpus/dists/*.changes')) {
my $content = do {
open my $fh, '<', $log
or die "can't read $log: $!";
local $/;
<$fh>;
};
my $parsed = CPAN::Changes::Parser::_parse($content);
my $raw = $parsed->{raw_preamble};

my @entries = @{ $parsed->{releases} || [] };

while (my $entry = shift @entries) {
$raw .= $entry->{raw};
unshift @entries, @{ $entry->{entries} || [] };
}

_eq $raw, $content, "raw content properly preserved for $log";
}

done_testing;

0 comments on commit d15bc93

Please sign in to comment.