bless($self, $class);
}
-sub diff($$)
+sub from_file($)
{
- my ($fh1, $fh2) = @_;
- my $ret = {};
+ my ($path) = @_;
my $statistics = {
TESTS_UNEXPECTED_OK => 0,
TESTS_EXPECTED_OK => 0,
TESTS_ERROR => 0,
TESTS_SKIP => 0,
};
- my $old = new Subunit::Diff();
- parse_results($old, $statistics, $fh1);
- my $new = new Subunit::Diff();
- parse_results($new, $statistics, $fh2);
+
+ my $ret = new Subunit::Diff();
+ open(IN, $path) or return;
+ parse_results($ret, $statistics, IN);
+ close(IN);
+ return $ret;
+}
+
+sub diff($$)
+{
+ my ($old, $new) = @_;
+ my $ret = {};
foreach my $testname (keys %$old) {
if ($new->{$testname} ne $old->{$testname}) {
use lib "$RealBin";
use Subunit::Diff;
-open(FH1, $ARGV[0]) or die("Unable to open $ARGV[0]: $!");
-open(FH2, $ARGV[1]) or die("Unable to open $ARGV[1]: $!");
+my $old = Subunit::Diff::from_file($ARGV[0]);
+my $new = Subunit::Diff::from_file($ARGV[1]);
-my $ret = Subunit::Diff::diff(*FH1, *FH2);
-
-close(FH1);
-close(FH2);
+my $ret = Subunit::Diff::diff($old, $new);
foreach my $e (keys %$ret) {
printf "%s: %s -> %s\n", $e, $ret->{$e}[0], $ret->{$e}[1];