t9004-ssdiff-highlight.pl 1.26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#!/usr/bin/perl -w
# -----------------------------------------------------------------------------

use strict;
use lib ($0 =~ m|^(.*/)| ? $1 : ".");
use GnumericTest;

&message ("Check ssdiff's highlight mode");

my $tmp = "junk.gnumeric";
&GnumericTest::junkfile ($tmp);

my @sources = &GnumericTest::corpus();

my $nskipped = 0;
my @pairs = ();
@sources = grep { -r $_ ? 1 : ($nskipped++, 0) } @sources;
while (@sources >= 2) {
    my $first = shift @sources;
    my $second = shift @sources;
    push @pairs, [$first,$second];
}

my $ngood = 0;
my $nbad = 0;
for my $p (@pairs) {
    my ($first,$second) = @$p;

    print STDERR "$first vs $second...\n";

    my $cmd = "$ssdiff --highlight --output=$tmp $first $second";
    print STDERR "$cmd\n" if $GnumericTest::verbose;
    my $output = `$cmd 2>&1`;
    my $err = $?;
    if ($err == (1 << 8)) {
	&GnumericTest::dump_indented ($output);
	$ngood++;
    } else {
        &GnumericTest::dump_indented ($output || '(no output)');
        $nbad++;
	die "Failed command: $cmd [$err]\n" if $err > (1 << 8);
    }
}

&GnumericTest::report_skip ("No source files present") if $nbad + $ngood == 0;

if ($nskipped > 0) {
    print STDERR "$nskipped files skipped.\n";
}

if ($nbad > 0) {
    die "Fail\n";
} else {
    print STDERR "Pass\n";
}