[gnumeric] ssdiff: test also highlight mode
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ssdiff: test also highlight mode
- Date: Mon, 4 Dec 2017 02:20:18 +0000 (UTC)
commit 1e2bf959cba3063055c0a7bfdd9a0ff39fb5a0e7
Author: Morten Welinder <terra gnome org>
Date: Sun Dec 3 21:19:33 2017 -0500
ssdiff: test also highlight mode
Also fix exit code when only sheets added or removed.
ChangeLog | 1 +
src/ssdiff.c | 14 ++++++++-
test/Makefile.am | 1 +
test/t9003-ssdiff-xml.pl | 5 ++-
test/t9004-ssdiff-highlight.pl | 55 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 72 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1ab51d7..e76ef45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
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.
diff --git a/src/ssdiff.c b/src/ssdiff.c
index 356fc9a..917bdf8 100644
--- a/src/ssdiff.c
+++ b/src/ssdiff.c
@@ -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);
}
diff --git a/test/Makefile.am b/test/Makefile.am
index e4a8f92..444ce5c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -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
diff --git a/test/t9003-ssdiff-xml.pl b/test/t9003-ssdiff-xml.pl
index 60c13b6..c7f6f57 100755
--- a/test/t9003-ssdiff-xml.pl
+++ b/test/t9003-ssdiff-xml.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 {
diff --git a/test/t9004-ssdiff-highlight.pl b/test/t9004-ssdiff-highlight.pl
new file mode 100755
index 0000000..a2f81e2
--- /dev/null
+++ b/test/t9004-ssdiff-highlight.pl
@@ -0,0 +1,55 @@
+#!/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";
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]