public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Tweak xquery tests so that they pass on OpenBSD
@ 2017-05-08 16:42 Timo Myyrä
  2017-05-08 18:39 ` Per Bothner
  0 siblings, 1 reply; 3+ messages in thread
From: Timo Myyrä @ 2017-05-08 16:42 UTC (permalink / raw)
  To: kawa


OpenBSD's diff doesn't have -B flag so work around it by formatting the
expected test outputs to not have newline in the end. Also tweak sed
command to delete empty lines before diffing files in format-users test.

diff --git a/gnu/xquery/testsuite/Makefile.am b/gnu/xquery/testsuite/Makefile.am
index 81873e67a..0ef9f4d93 100644
--- a/gnu/xquery/testsuite/Makefile.am
+++ b/gnu/xquery/testsuite/Makefile.am
@@ -2,6 +2,7 @@ include $(top_srcdir)/Make-rules
 
 KAWALIB = $(top_builddir)
 KAWA = ../../../bin/kawa.sh
+DIFF = diff -b
 EXTRA_CLEAN = tmp* *.log testing.zip */*.class
 mostlyclean-am: mostlyclean-generic
 	rm -rf Mod1 Mod2
@@ -34,7 +35,7 @@ XQTS_JAVA_FLAGS = -Xmx120m
 check-XQTS: RunXQTS.class
 	CLASSPATH=$(KAWALIB) \
 	  $(JAVA) $(XQTS_JAVA_FLAGS) gnu.xquery.testsuite.RunXQTS $(XQTS_DIR)
-	@if diff -b $(srcdir)/XQTS-trace.exp XQuery-trace.log; \
+	@if $(DIFF) $(srcdir)/XQTS-trace.exp XQuery-trace.log; \
 	  then echo '# XQTS trace output matches'; \
 	  else echo FAIL XQuery trace output mismatch; fi
 
@@ -47,7 +48,7 @@ check-suite:  TestSuite.class
 
 check-maketab1:  maketab1.xql
 	CLASSPATH=".$(CLASSPATH_SEPARATOR)$(KAWALIB)" $(KAWA) $< >tmp2
-	@if diff -b $(srcdir)/tab.html tmp2; then echo '# maketab1 test passes'; else echo FAIL maketab1 test; fi
+	@if $(DIFF) $(srcdir)/tab.html tmp2; then echo '# maketab1 test passes'; else echo FAIL maketab1 test; fi
 
 # FIXME - this does not do the correct thing
 check-desc:
@@ -59,29 +60,29 @@ multab.class:  multab.xql
 check-multab:  multab.class
 	CLASSPATH=".$(CLASSPATH_SEPARATOR)$(KAWALIB)" $(JAVA) multab \
 	  max=10 caption="Multiplication table " out:xml-indent=pretty >tmpmul
-	@if diff -b $(srcdir)/expectedmul.xml tmpmul; then echo '# multab test passes'; else echo FAIL multab test; fi
+	@if $(DIFF) $(srcdir)/expectedmul.xml tmpmul; then echo '# multab test passes'; else echo FAIL multab test; fi
 
 descend.class:  descend.xql
 	$(KAWA) --main --xquery -C $<
 
 check-descend:  descend.class
 	CLASSPATH=".$(CLASSPATH_SEPARATOR)$(KAWALIB)" $(JAVA) descend >tmpdesc
-	@if diff -b $(srcdir)/expdescend.xml tmpdesc; then echo '# descend test passes'; else echo FAIL descend test; fi
+	@if $(DIFF) $(srcdir)/expdescend.xml tmpdesc; then echo '# descend test passes'; else echo FAIL descend test; fi
 
 check-latin1a:
 	$(KAWA) --xquery $(srcdir)/latin1a.xql >tmplatin1a
-	@if diff -b $(srcdir)/latin1a.expected tmplatin1a; then echo '# latin1a test passes'; else echo FAIL latin1a test; fi
+	@if $(DIFF) $(srcdir)/latin1a.expected tmplatin1a; then echo '# latin1a test passes'; else echo FAIL latin1a test; fi
 
 check-xsltest1:
 	$(KAWA) --xslt -f $(srcdir)/xsltest1.xsl $(srcdir)/outline.xml >tmp-xsltest1.log
-	@if diff -b $(srcdir)/xsltest1.expected tmp-xsltest1.log; \
+	@if $(DIFF) $(srcdir)/xsltest1.expected tmp-xsltest1.log; \
 	  then echo '# xsltest1 test passes'; \
 	  else echo FAIL xsltest1 test; fi
 
 check-format-users:
 	$(KAWA) --xslt $(srcdir)/format-users.xsl $(srcdir)/users.xml \
-	  |sed 's/^ *//'>tmp-format-users.html
-	@if diff -b -B $(srcdir)/exp-format-users.html tmp-format-users.html; then echo '#  format-users test passes'; else echo FAIL format-users test; fi
+	  |sed 's/^ *//; /^\s*$$/d' >tmp-format-users.html
+	@if $(DIFF) $(srcdir)/exp-format-users.html tmp-format-users.html; then echo '#  format-users test passes'; else echo FAIL format-users test; fi
 
 ./Mod1/mod1.class: mod1.xql
 	$(CLASSPATH_ENV) $(KAWA) --module-static -d ../../.. -C $<
@@ -93,7 +94,7 @@ usemod.class: usemod.xql ./Mod1/mod1.class ./Mod2/mod2.class ./Mod2/mod2a.class
 	$(CLASSPATH_ENV) $(KAWA) --main -C $<
 check-mod: usemod.class
 	CLASSPATH=".$(CLASSPATH_SEPARATOR)$(KAWALIB)" $(JAVA) usemod >tmp-usemod
-	@if diff -b $(srcdir)/usemod.exp tmp-usemod; \
+	@if $(DIFF) $(srcdir)/usemod.exp tmp-usemod; \
 	  then echo '# usemod test passes'; \
 	  else echo FAIL usemod test; fi
 
@@ -101,7 +102,7 @@ bad-1.log: $(srcdir)/bad-1.xql
 	-CLASSPATH=$(KAWALIB) $(KAWA) -C $< 2>&1 \
 	| sed -e '1d' -e 's|^.*/bad-1.xql|bad-1.xql|' >bad-1.log
 check-bad-1: bad-1.log
-	@if diff -b $(srcdir)/expected-1.errs bad-1.log; \
+	@if $(DIFF) $(srcdir)/expected-1.errs bad-1.log; \
 	  then echo '# bad-1 test passes'; \
 	  else echo FAIL bad-1 test; fi
 
diff --git a/gnu/xquery/testsuite/exp-format-users.html b/gnu/xquery/testsuite/exp-format-users.html
index d7d511708..bc9e6f581 100644
--- a/gnu/xquery/testsuite/exp-format-users.html
+++ b/gnu/xquery/testsuite/exp-format-users.html
@@ -29,4 +29,4 @@
 <td>Rip Van Winkle</td>
 <td>B</td>
 </tr>
-</table>
+</table>
\ No newline at end of file
diff --git a/gnu/xquery/testsuite/latin1a.expected b/gnu/xquery/testsuite/latin1a.expected
index fe6fcc12e..7dd81ec47 100644
--- a/gnu/xquery/testsuite/latin1a.expected
+++ b/gnu/xquery/testsuite/latin1a.expected
@@ -1 +1 @@
-<p>Norwegian letters: ae:&#xE6; oe:&#xF8; aa:&#xE5;</p>
+<p>Norwegian letters: ae:&#xE6; oe:&#xF8; aa:&#xE5;</p>
\ No newline at end of file
-- 
2.12.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] Tweak xquery tests so that they pass on OpenBSD
  2017-05-08 16:42 [PATCH 1/2] Tweak xquery tests so that they pass on OpenBSD Timo Myyrä
@ 2017-05-08 18:39 ` Per Bothner
  2017-05-09  4:02   ` Timo Myyrä
  0 siblings, 1 reply; 3+ messages in thread
From: Per Bothner @ 2017-05-08 18:39 UTC (permalink / raw)
  To: Timo Myyrä, kawa

On 05/07/2017 09:11 PM, Timo Myyrä wrote:
> 
> OpenBSD's diff doesn't have -B flag so work around it by formatting the
> expected test outputs to not have newline in the end. 

I'm not comfortable changing checked-in text files so they don't end
in a newline, like text files should.

Ideally the output should always (or at least by default) end in a newline.
Perhaps close should automatically call freshLine.  However, you have to
be careful with binary files - and it becomes non-obvious with hybrid
text/binary files, which Kawa supports.

So not sure what to do.  It needs some thought.

As a work-round until then, I suggest we add a newline to the end of the output.
For example:
	echo >>tmp-format-users.html
Or perhaps we can have sed add the newline.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] Tweak xquery tests so that they pass on OpenBSD
  2017-05-08 18:39 ` Per Bothner
@ 2017-05-09  4:02   ` Timo Myyrä
  0 siblings, 0 replies; 3+ messages in thread
From: Timo Myyrä @ 2017-05-09  4:02 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

Per Bothner <per@bothner.com> writes:

> On 05/07/2017 09:11 PM, Timo Myyrä wrote:
>>
>> OpenBSD's diff doesn't have -B flag so work around it by formatting the
>> expected test outputs to not have newline in the end. 
>
> I'm not comfortable changing checked-in text files so they don't end
> in a newline, like text files should.
>
> Ideally the output should always (or at least by default) end in a newline.
> Perhaps close should automatically call freshLine.  However, you have to
> be careful with binary files - and it becomes non-obvious with hybrid
> text/binary files, which Kawa supports.
>
> So not sure what to do.  It needs some thought.
>
> As a work-round until then, I suggest we add a newline to the end of the output.
> For example:
> 	echo >>tmp-format-users.html
> Or perhaps we can have sed add the newline.

Hmm,
I don't think kawa itself should emit newlines unless its told to. 

As the sed command already strips whitespace besides newlines, could it be just
expanded to zap newlines as well. Or pipe to `tr -d '\n'`.

With XML the formatting doesn't matter so it would probably be easiest to
compare expected output if its formatted as single long string?

Timo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-09  4:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 16:42 [PATCH 1/2] Tweak xquery tests so that they pass on OpenBSD Timo Myyrä
2017-05-08 18:39 ` Per Bothner
2017-05-09  4:02   ` Timo Myyrä

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).