Shutdown: help the style leak printer out a bit.
[gnumeric.git] / test / t9003-ssdiff-xml.pl
blobda797ea6eb988e0843dd5d208eae78b84c9ecfb2
1 #!/usr/bin/perl -w
2 # -----------------------------------------------------------------------------
4 use strict;
5 use lib ($0 =~ m|^(.*/)| ? $1 : ".");
6 use GnumericTest;
8 &message ("Check ssdiff's xml mode");
10 my $xmllint = &GnumericTest::find_program ("xmllint");
12 my @sources = &GnumericTest::corpus();
14 my $nskipped = 0;
15 my @pairs = ();
16 @sources = grep { -r $_ ? 1 : ($nskipped++, 0) } @sources;
17 while (@sources >= 2) {
18 my $first = shift @sources;
19 my $second = shift @sources;
20 push @pairs, [$first,$second];
23 my $ngood = 0;
24 my $nbad = 0;
25 for my $p (@pairs) {
26 my ($first,$second) = @$p;
28 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 $nbad++;
37 die "Failed command: $cmd [$err]\n" if $err > (1 << 8);
38 } else {
39 if ($output eq '') {
40 $ngood++;
41 } else {
42 &GnumericTest::dump_indented ($output);
43 $nbad++;
48 &GnumericTest::report_skip ("No source files present") if $nbad + $ngood == 0;
50 if ($nskipped > 0) {
51 print STDERR "$nskipped files skipped.\n";
54 if ($nbad > 0) {
55 die "Fail\n";
56 } else {
57 print STDERR "Pass\n";