[gnumeric] tests, ods: improve determinism.



commit 696c18e3cdb1bb864e6665805e6ff621e38ccea5
Author: Morten Welinder <terra gnome org>
Date:   Wed May 21 23:10:21 2014 -0400

    tests, ods: improve determinism.

 ChangeLog                             |    5 ++
 plugins/openoffice/openoffice-write.c |  105 ++++++++++++++++++++++++++-------
 test/t6160-ods-deterministic.pl       |   13 ++--
 3 files changed, 96 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4885f23..6b8dd5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-05-21  Morten Welinder  <terra gnome org>
+
+       * plugins/openoffice/openoffice-write.c (odf_write_office_styles)
+       (odf_write_graph_styles): Make this much more deterministic.
+
 2014-05-20  Morten Welinder  <terra gnome org>
 
        * plugins/openoffice/openoffice-write.c
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 3c7e53d..faddcdd 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -5237,6 +5237,22 @@ odf_store_data_style_for_style_with_name (GnmStyleRegion *sr, G_GNUC_UNUSED char
        }
 }
 
+static int
+by_key_str (gpointer key_a, G_GNUC_UNUSED gpointer val_a,
+           gpointer key_b, G_GNUC_UNUSED gpointer val_b,
+           G_GNUC_UNUSED gpointer user)
+{
+       return strcmp (key_a, key_b);
+}
+
+static int
+by_value_str (G_GNUC_UNUSED gpointer key_a, gpointer val_a,
+             G_GNUC_UNUSED gpointer key_b, gpointer val_b,
+             G_GNUC_UNUSED gpointer user)
+{
+       return strcmp (val_a, val_b);
+}
+
 static void
 odf_write_office_styles (GnmOOExport *state)
 {
@@ -5245,9 +5261,17 @@ odf_write_office_styles (GnmOOExport *state)
        /* We need to make sure all the data styles for the named styles are included */
        g_hash_table_foreach (state->named_cell_style_regions, (GHFunc) 
odf_store_data_style_for_style_with_name, state);
 
-       g_hash_table_foreach (state->xl_styles, (GHFunc) odf_write_xl_style, state);
+       gnm_hash_table_foreach_ordered
+               (state->xl_styles,
+                (GHFunc) odf_write_xl_style,
+                by_value_str,
+                state);
 
-       g_hash_table_foreach (state->named_cell_style_regions, (GHFunc) odf_save_this_style_with_name, state);
+       gnm_hash_table_foreach_ordered
+               (state->named_cell_style_regions,
+                (GHFunc) odf_save_this_style_with_name,
+                by_value_str,
+                state);
 
        g_hash_table_foreach (state->text_colours, (GHFunc) odf_write_text_colours, state);
 
@@ -5271,11 +5295,35 @@ odf_write_office_styles (GnmOOExport *state)
                gsf_xml_out_end_element (state->xml); /* </style:default-style */
        }
 
-       g_hash_table_foreach (state->graph_dashes, (GHFunc) odf_write_dash_info, state);
-       g_hash_table_foreach (state->graph_hatches, (GHFunc) odf_write_hatch_info, state);
-       g_hash_table_foreach (state->graph_gradients, (GHFunc) odf_write_gradient_info, state);
-       g_hash_table_foreach (state->graph_fill_images, (GHFunc) odf_write_fill_images_info, state);
-       g_hash_table_foreach (state->arrow_markers, (GHFunc) odf_write_arrow_marker_info, state);
+       gnm_hash_table_foreach_ordered
+               (state->graph_dashes,
+                (GHFunc) odf_write_dash_info,
+                by_key_str,
+                state);
+
+       gnm_hash_table_foreach_ordered
+               (state->graph_hatches,
+                (GHFunc) odf_write_hatch_info,
+                by_value_str,
+                state);
+
+       gnm_hash_table_foreach_ordered
+               (state->graph_gradients,
+                (GHFunc) odf_write_gradient_info,
+                by_value_str,
+                state);
+
+       gnm_hash_table_foreach_ordered
+               (state->graph_fill_images,
+                (GHFunc) odf_write_fill_images_info,
+                by_value_str,
+                state);
+
+       gnm_hash_table_foreach_ordered
+               (state->arrow_markers,
+                (GHFunc) odf_write_arrow_marker_info,
+                by_value_str,
+                state);
 
        g_hash_table_remove_all (state->graph_dashes);
        g_hash_table_remove_all (state->graph_hatches);
@@ -5747,12 +5795,35 @@ odf_write_graph_styles (GnmOOExport *state, GsfOutput *child)
                                        state->odf_version_string);
        gsf_xml_out_start_element (state->xml, OFFICE "styles");
 
-       g_hash_table_foreach (state->graph_dashes, (GHFunc) odf_write_dash_info, state);
-       g_hash_table_foreach (state->graph_hatches, (GHFunc) odf_write_hatch_info, state);
-       g_hash_table_foreach (state->graph_gradients, (GHFunc) odf_write_gradient_info, state);
-       g_hash_table_foreach (state->graph_fill_images, (GHFunc) odf_write_fill_images_info, state);
+       gnm_hash_table_foreach_ordered
+               (state->graph_dashes,
+                (GHFunc) odf_write_dash_info,
+                by_key_str,
+                state);
+
+       gnm_hash_table_foreach_ordered
+               (state->graph_hatches,
+                (GHFunc) odf_write_hatch_info,
+                by_value_str,
+                state);
+
+       gnm_hash_table_foreach_ordered
+               (state->graph_gradients,
+                (GHFunc) odf_write_gradient_info,
+                by_value_str,
+                state);
+
+       gnm_hash_table_foreach_ordered
+               (state->graph_fill_images,
+                (GHFunc) odf_write_fill_images_info,
+                by_value_str,
+                state);
 
-       g_hash_table_foreach (state->xl_styles, (GHFunc) odf_write_xl_style, state);
+       gnm_hash_table_foreach_ordered
+               (state->xl_styles,
+                (GHFunc) odf_write_xl_style,
+                by_value_str,
+                state);
 
        gsf_xml_out_end_element (state->xml); /* </office:styles> */
        gsf_xml_out_end_element (state->xml); /* </office:document-styles> */
@@ -6010,14 +6081,6 @@ odf_write_image_manifest (SheetObject *image, char const *name, GnmOOExport *sta
 
 }
 
-static int
-by_value_str (G_GNUC_UNUSED gpointer key_a, gpointer val_a,
-             G_GNUC_UNUSED gpointer key_b, gpointer val_b,
-             G_GNUC_UNUSED gpointer user)
-{
-       return strcmp (val_a, val_b);
-}
-
 static void
 odf_write_manifest (GnmOOExport *state, GsfOutput *child)
 {
diff --git a/test/t6160-ods-deterministic.pl b/test/t6160-ods-deterministic.pl
index 7c07d82..108da86 100755
--- a/test/t6160-ods-deterministic.pl
+++ b/test/t6160-ods-deterministic.pl
@@ -14,7 +14,7 @@ my @sources =
     ("$samples/excel/address.xls",
      "$samples/excel/bitwise.xls",
      "$samples/excel/chart-tests-excel.xls",
-     "$samples/excel/datefuns.xls",
+     # "$samples/excel/datefuns.xls", # uses NOW()
      "$samples/excel/dbfuns.xls",
      "$samples/excel/engfuns.xls",
      "$samples/excel/finfuns.xls",
@@ -31,11 +31,9 @@ my @sources =
      "$samples/excel/textfuns.xls",
      "$samples/excel/yalta2008.xls",
      "$samples/excel12/cellstyle.xlsx",
-     # xmllint hangs on these files.  (Well, amath finishes but takes too
-     # long.)
-     # "$samples/crlibm.gnumeric",
-     # "$samples/amath.gnumeric",
-     # "$samples/gamma.gnumeric",
+     "$samples/crlibm.gnumeric",
+     "$samples/amath.gnumeric",
+     "$samples/gamma.gnumeric",
      "$samples/linest.xls",
      "$samples/vba-725220.xls",
      "$samples/sumif.xls",
@@ -116,6 +114,9 @@ foreach my $src (@sources) {
            next;
        }
 
+       # May contain time stamp.
+       next if $member eq 'meta.xml';
+
        my $cmd1 = "$unzip -p $tmp1 $member";
        print STDERR "# $cmd1\n" if $GnumericTest::verbose;
        my $data1 = `$cmd1`;


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