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

ssdiff: test also highlight mode

Also fix exit code when only sheets added or removed.
parent 1cb2ffdb
2017-12-03 Morten Welinder <terra@gnome.org>
* src/ssdiff.c (SSDIFF_DTD): Add proper xmlns definition.
(diff): Missing or extra sheet counts as a difference.
* src/mstyle.c (gnm_style_find_differences): Don't crash when
hlink/validation/inputmsg/conditions is NULL in one and not the other.
......
......@@ -780,11 +780,18 @@ highlight_diff_start (GnmDiffState *state)
{
const char *dst = state->new.url;
state->highlight_fs = go_file_saver_for_file_name (dst);
if (!ssdiff_output) {
g_printerr (_("%s: Must specify an output file for highlighting.\n"),
g_get_prgname ());
return TRUE;
}
state->highlight_fs = go_file_saver_for_file_name (ssdiff_output);
if (!state->highlight_fs) {
g_printerr (_("%s: Unable to guess exporter to use for %s.\n"),
g_get_prgname (),
dst);
ssdiff_output);
return TRUE;
}
......@@ -1148,6 +1155,8 @@ diff (char const *oldfilename, char const *newfilename,
Sheet *old_sheet = workbook_sheet_by_index (state.old.wb, i);
Sheet *new_sheet = workbook_sheet_by_name (state.new.wb,
old_sheet->name_unquoted);
if (!new_sheet)
state.diff_found = TRUE;
state.actions->sheet_start (&state, old_sheet, new_sheet);
if (new_sheet) {
......@@ -1169,6 +1178,7 @@ diff (char const *oldfilename, char const *newfilename,
if (old_sheet)
; /* Nothing -- already done above. */
else {
state.diff_found = TRUE;
state.actions->sheet_start (&state, NULL, new_sheet);
state.actions->sheet_end (&state);
}
......
......@@ -169,6 +169,7 @@ TESTS = t1000-statfuns.pl \
t9001-ssconvert-resize.pl \
t9002-ssdiff-self.pl \
t9003-ssdiff-xml.pl \
t9004-ssdiff-highlight.pl \
t9100-number-match.pl \
t9999-epilogue.pl
......
......@@ -28,10 +28,11 @@ for my $p (@pairs) {
print STDERR "$first vs $second...\n";
my $cmd = "$ssdiff --xml $first $second | xmllint -noout - 2>&1";
print STDERR "$cmd\n" if $GnumericTest::verbose;
my $output = `$cmd 2>&1`;
my $err = $?;
my $err = $?; # from xmllint
if ($err) {
&GnumericTest::dump_indented ($output);
&GnumericTest::dump_indented ($output || '(no output)');
$nbad++;
die "Failed command: $cmd [$err]\n" if $err > (1 << 8);
} else {
......
#!/usr/bin/perl -w
# -----------------------------------------------------------------------------
use strict;
use lib ($0 =~ m|^(.*/)| ? $1 : ".");
use GnumericTest;
&message ("Check ssdiff's highlight mode");
my $tmp = "junk.gnumeric";
&GnumericTest::junkfile ($tmp);
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 --highlight --output=$tmp $first $second";
print STDERR "$cmd\n" if $GnumericTest::verbose;
my $output = `$cmd 2>&1`;
my $err = $?;
if ($err == (1 << 8)) {
&GnumericTest::dump_indented ($output);
$ngood++;
} else {
&GnumericTest::dump_indented ($output || '(no output)');
$nbad++;
die "Failed command: $cmd [$err]\n" if $err > (1 << 8);
}
}
&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