Skip to content

Instantly share code, notes, and snippets.

@Ovid
Created December 26, 2012 09:56
Show Gist options
  • Select an option

  • Save Ovid/4379250 to your computer and use it in GitHub Desktop.

Select an option

Save Ovid/4379250 to your computer and use it in GitHub Desktop.
A simple way of seeing if one .prove file has different test results from another (used with "prove --state=save")
#!/usr/bin/env perl
use Modern::Perl;
use App::Prove::State;
my ( $prove1, $prove2 ) = @ARGV;
unless ( -f $prove1 and -f $prove2 ) {
die "Pass .prove files, please";
}
# XXX Must fix this in App::Prove. We want to be able to read and parse these
# .prove files even if we're in a different directory.
no warnings 'redefine';
local *App::Prove::State::_prune_and_stamp = sub { };
my $first = App::Prove::State->new( { store => $prove1 } )->results;
my %first_tests = map { $_ => $first->test($_) } $first->test_names;
my $second = App::Prove::State->new( { store => $prove2 } )->results;
my %second_tests = map { $_ => $second->test($_) } $second->test_names;
foreach my $test ( sort keys %first_tests ) {
unless ( exists $second_tests{$test} ) {
header($prove1, $prove2);
say "Test '$test' found in '$prove1' but not '$prove2'";
}
}
foreach my $test ( sort keys %second_tests ) {
unless ( exists $first_tests{$test} ) {
header($prove1, $prove2);
say "Test '$test' found in '$prove2' but not '$prove1'";
next;
}
my $first_result = $first_tests{$test}->result;
my $second_result = $second_tests{$test}->result;
if ( $first_result != $second_result ) {
header($prove1, $prove2);
say
"Test '$test' results are different: $first_result failure(s) versus $second_result failure(s)";
}
}
sub header {
my ( $prove1, $prove2 ) = @_;
state $header_printed = 0;
return if $header_printed;
say "provediff results for '$prove1' versus '$prove2'";
$header_printed = 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment