[gnumeric] ods: check that the strict conformance exporter is deterministic.



commit 70bdb3dce5eb53589680005d17eefedbdc7d6d04
Author: Morten Welinder <terra gnome org>
Date:   Sun Sep 4 08:44:51 2022 -0400

    ods: check that the strict conformance exporter is deterministic.

 NEWS                                   |   1 +
 test/Makefile.am                       |   1 +
 test/t6163-ods-strict-deterministic.pl | 102 +++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
---
diff --git a/NEWS b/NEWS
index c2f36d946..67c443ad5 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Morten:
        * Fix html import problem.  [#669]
        * Fix reading localc extension for engineering format.  [#659]
        * Fix strict-conformance ods problem with E-notation.  [#672]
+       * Improve test suite
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.52
diff --git a/test/Makefile.am b/test/Makefile.am
index 1628531db..b773c7ed7 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -98,6 +98,7 @@ TESTS =       t1000-statfuns.pl                       \
        t6160-ods-deterministic.pl              \
        t6161-xlsx-deterministic.pl             \
        t6162-gnumeric-deterministic.pl         \
+       t6163-ods-strict-deterministic.pl       \
        t6500-strings.pl                        \
        t6501-numbers.pl                        \
        t6502-styles.pl                         \
diff --git a/test/t6163-ods-strict-deterministic.pl b/test/t6163-ods-strict-deterministic.pl
new file mode 100755
index 000000000..8494e471a
--- /dev/null
+++ b/test/t6163-ods-strict-deterministic.pl
@@ -0,0 +1,102 @@
+#!/usr/bin/perl -w
+# -----------------------------------------------------------------------------
+
+use strict;
+use lib ($0 =~ m|^(.*/)| ? $1 : ".");
+use GnumericTest;
+
+&message ("Check that the strict ods exporter produces the same results every time.");
+
+my $format = "Gnumeric_OpenCalc:openoffice";
+my $unzip = &GnumericTest::find_program ("unzip");
+
+my @sources = &GnumericTest::corpus();
+# datefuns and docs-samples use NOW(); the rest take too long.
+@sources = grep { !m{(^|/)(datefuns\.xls|(docs-samples|crlibm|gamma)\.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 %members;
+    my @tmp;
+    foreach my $i (1, 2) {
+       my $tmp = $src;
+       $tmp =~ s|^.*/||;
+       $tmp =~ s|\..*|-$i.ods|;
+       &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";
+       }
+
+       foreach (`$unzip -v $tmp`) {
+           next unless /^----/ ... /^----/;
+           next unless m{^\s*\d.*\s(\S+)$};
+           my $member = $1;
+           if (($members{$member} || 0) & $i) {
+               print STDERR "Duplicate member $member\n";
+               die "Fail\n";
+           }
+           $members{$member} += $i;
+       }
+
+       push @tmp, $tmp;
+    }
+
+    my $tmp1 = $tmp[0];
+    my $tmp2 = $tmp[1];
+
+    foreach my $member (sort keys %members) {
+       if ($members{$member} != 3) {
+           print STDERR "Member $member is not in both files.\n";
+           $nbad++;
+           next;
+       }
+
+       # May contain time stamp.
+       next if $member eq 'meta.xml';
+
+       my $cmd1 = &GnumericTest::quotearg ($unzip, "-p", $tmp1, $member);
+       print STDERR "# $cmd1\n" if $GnumericTest::verbose;
+       my $data1 = `$cmd1`;
+
+       my $cmd2 = &GnumericTest::quotearg ($unzip, "-p", $tmp2, $member);
+       print STDERR "# $cmd2\n" if $GnumericTest::verbose;
+       my $data2 = `$cmd2`;
+
+       if ($data1 ne $data2) {
+           print STDERR "Member $member is different between two files.\n";
+           $nbad++;
+           next;
+       }
+
+       $ngood++;
+    }
+
+    &GnumericTest::removejunk ($tmp1);
+    &GnumericTest::removejunk ($tmp2);
+}
+
+&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";
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]