t6162-gnumeric-deterministic.pl 1.52 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
#!/usr/bin/perl -w
# -----------------------------------------------------------------------------

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

&message ("Check that the gnumeric exporter produces the same results every time.");

my $format = "Gnumeric_XmlIO:sax:0";

my @sources = &GnumericTest::corpus();
# datefuns and docs-samples use NOW()
@sources = grep { !m{(^|/)(datefuns\.xls|docs-samples\.gnumeric)$} } @sources;

my $nskipped = 0;
my $ngood = 0;
my $nbad = 0;

foreach my $src (@sources) {
    if (!-r $src) {
	$nskipped++;
	next;
    }

    print STDERR "Checking $src\n";

    my @data;
    foreach my $i (1, 2) {
	my $tmp = $src;
	$tmp =~ s|^.*/||;
	$tmp =~ s|\..*|-$i.gnumeric|;
	&GnumericTest::junkfile ($tmp);
	my $cmd = "$ssconvert -T $format $src $tmp";
	print STDERR "# $cmd\n" if $GnumericTest::verbose;
	system ($cmd);
	if (!-r $tmp) {
	    print STDERR "ssconvert failed to produce $tmp\n";
	    die "Fail\n";
	}

42 43 44 45 46 47
	my $d = &GnumericTest::read_file ($tmp);

	# Some formats (notably mps) set this to current time.
	$d =~ s{<meta:creation-date>[0-9-:TZ]+</meta:creation-date>}{};

	push @data, $d;
48 49 50 51
	&GnumericTest::removejunk ($tmp);
    }

    if ($data[0] ne $data[1]) {
52
	print STDERR "Generated output for $src is not deterministic.\n";
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
	$nbad++;
    } else {
	$ngood++;
    }
}

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