Commit 1cb2ffdb authored by Morten Welinder's avatar Morten Welinder

ssdiff: better testing.

Also fix the crash it found.
Also fix the xml.
parent a6a56420
2017-12-03 Morten Welinder <terra@gnome.org>
* src/ssdiff.c (SSDIFF_DTD): Add proper xmlns definition.
* src/mstyle.c (gnm_style_find_differences): Don't crash when
hlink/validation/inputmsg/conditions is NULL in one and not the other.
* src/ssdiff.c (diff_sheets_colrow): New function to compare
row/column sizes.
(highlight_cell_changed): Survive missing cell.
......
......@@ -5,6 +5,7 @@ Morten:
* Test suite improvements.
* Improve sylk writer. Don't ask.
* Teach ssdiff about column/row sizes.
* Fix a few ssdiff crashes.
--------------------------------------------------------------------------
Gnumeric 1.12.37
......
......@@ -543,11 +543,12 @@ gnm_style_find_conflicts (GnmStyle *accum, GnmStyle const *overlay,
#define GNM_INPUT_MSG_EQUAL3(a,b,r) (gnm_input_msg_equal (a,b))
#define RELAX_CHECK(op_,field_,checker_) do { \
#define RELAX_CHECK(op_,field_,checker_) do { \
if (diffs & (1u << (op_)) && \
elem_is_set (a, (op_)) && \
elem_is_set (b, (op_)) && \
checker_ (a->field_, b->field_, relax_sheet)) \
((a->field_ == NULL) != (b->field_ == NULL) || \
checker_ (a->field_, b->field_, relax_sheet))) \
diffs &= ~(1u << (op_)); \
} while (0)
......
......@@ -34,8 +34,8 @@
#include <gsf/gsf-output-stdio.h>
#include <gsf/gsf-input.h>
/* FIXME: Namespace? */
#define DIFF "ssdiff:"
#define DIFF "s:"
#define SSDIFF_DTD "http://www.gnumeric.org/ssdiff.dtd" // No such file yet
static gboolean ssdiff_show_version = FALSE;
static gboolean ssdiff_highlight = FALSE;
......@@ -327,10 +327,16 @@ static const GnmDiffActions default_actions = {
static gboolean
xml_diff_start (GnmDiffState *state)
{
char *attr;
state->xml = gsf_xml_out_new (state->output);
state->convs = gnm_xml_io_conventions ();
gsf_xml_out_start_element (state->xml, DIFF "Diff");
attr = g_strdup ("xmlns:" DIFF);
attr[strlen (attr) - 1] = 0;
gsf_xml_out_add_cstr (state->xml, attr, SSDIFF_DTD);
g_free (attr);
return FALSE;
}
......
......@@ -168,6 +168,7 @@ TESTS = t1000-statfuns.pl \
t9000-ssindex.pl \
t9001-ssconvert-resize.pl \
t9002-ssdiff-self.pl \
t9003-ssdiff-xml.pl \
t9100-number-match.pl \
t9999-epilogue.pl
......
......@@ -30,9 +30,9 @@ for my $src (@sources) {
die "Failed command: $cmd [$err]\n" if $err > (1 << 8);
} else {
if ($output =~ m'<\?xml version="1\.0" encoding="UTF-8"\?>
<ssdiff:Diff>
( <ssdiff:Sheet Name=".*" Old="\d+" New="\d+"/>
)*</ssdiff:Diff>') {
<s:Diff xmlns:s=".*">
( <s:Sheet Name=".*" Old="\d+" New="\d+"/>
)*</s:Diff>') {
$ngood++;
} else {
&GnumericTest::dump_indented ($output);
......
#!/usr/bin/perl -w
# -----------------------------------------------------------------------------
use strict;
use lib ($0 =~ m|^(.*/)| ? $1 : ".");
use GnumericTest;
&message ("Check ssdiff's xml mode");
my $xmllint = &GnumericTest::find_program ("xmllint");
my @sources = &GnumericTest::corpus();
my $nskipped = 0;
my @pairs = ();
@sources = grep { -r $_ ? 1 : ($nskipped++, 0) } @sources;
while (@sources >= 2) {
my $first = shift @sources;
my $second = shift @sources;
push @pairs, [$first,$second];
}
my $ngood = 0;
my $nbad = 0;
for my $p (@pairs) {
my ($first,$second) = @$p;
print STDERR "$first vs $second...\n";
my $cmd = "$ssdiff --xml $first $second | xmllint -noout - 2>&1";
my $output = `$cmd 2>&1`;
my $err = $?;
if ($err) {
&GnumericTest::dump_indented ($output);
$nbad++;
die "Failed command: $cmd [$err]\n" if $err > (1 << 8);
} else {
if ($output eq '') {
$ngood++;
} else {
&GnumericTest::dump_indented ($output);
$nbad++;
}
}
}
&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";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment