t9003-ssdiff-xml.pl 1.37 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
#!/usr/bin/perl -w
# -----------------------------------------------------------------------------

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

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

my $xmllint = &GnumericTest::find_program ("xmllint");

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";

30
    my $cmd = "$ssdiff --xml $first $second | $xmllint --nonet --noout - 2>&1";
31
    print STDERR "$cmd\n" if $GnumericTest::verbose;
32
    my $output = `$cmd 2>&1`;
33
    my $err = $?; # from xmllint
34
    if ($err) {
35
        &GnumericTest::dump_indented ($output || '(no output)');
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
        $nbad++;
	die "Failed command: $cmd [$err]\n" if $err > (1 << 8);
    } else {
        if ($output eq '') {
            $ngood++;
        } else {
            &GnumericTest::dump_indented ($output);
            $nbad++;
        }
    }
}

&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";
}