1#!/usr/bin/perl -w
2# -----------------------------------------------------------------------------
3
4use strict;
5use lib ($0 =~ m|^(.*/)| ? $1 : ".");
6use GnumericTest;
7
8&message ("Check that the gnumeric exporter produces the same results every time.");
9
10my $format = "Gnumeric_XmlIO:sax:0";
11
12my @sources = &GnumericTest::corpus();
13# datefuns and docs-samples use NOW()
14@sources = grep { !m{(^|/)(datefuns\.xls|docs-samples\.gnumeric)$} } @sources;
15
16my $nskipped = 0;
17my $ngood = 0;
18my $nbad = 0;
19
20foreach my $src (@sources) {
21    if (!-r $src) {
22	$nskipped++;
23	next;
24    }
25
26    print STDERR "Checking $src\n";
27
28    my @data;
29    foreach my $i (1, 2) {
30	my $tmp = $src;
31	$tmp =~ s|^.*/||;
32	$tmp =~ s|\..*|-$i.gnumeric|;
33	&GnumericTest::junkfile ($tmp);
34	my $cmd = "$ssconvert -T $format $src $tmp";
35	print STDERR "# $cmd\n" if $GnumericTest::verbose;
36	system ($cmd);
37	if (!-r $tmp) {
38	    print STDERR "ssconvert failed to produce $tmp\n";
39	    die "Fail\n";
40	}
41
42	my $d = &GnumericTest::read_file ($tmp);
43
44	# Some formats (notably mps) set this to current time.
45	$d =~ s{<meta:creation-date>[0-9-:TZ]+</meta:creation-date>}{};
46
47	push @data, $d;
48	&GnumericTest::removejunk ($tmp);
49    }
50
51    if ($data[0] ne $data[1]) {
52	print STDERR "Generated output for $src is not deterministic.\n";
53	$nbad++;
54    } else {
55	$ngood++;
56    }
57}
58
59&GnumericTest::report_skip ("No source files present") if $nbad + $ngood == 0;
60
61if ($nskipped > 0) {
62    print STDERR "$nskipped files skipped.\n";
63}
64
65if ($nbad > 0) {
66    die "Fail\n";
67} else {
68    print STDERR "Pass\n";
69}
70