[m-rev.] diff: improve *.err_res messages

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Apr 7 15:49:40 AEST 2003


Estimated hours taken: 0.25
Branches: main

tests/Mmake.common:
	Improve the error messages for failed tests in tests/invalid.

Workspace: /home/earth/fjh/ws-earth3/mercury
Index: tests/Mmake.common
===================================================================
RCS file: /home/mercury1/repository/tests/Mmake.common,v
retrieving revision 1.41
diff -u -d -r1.41 Mmake.common
--- tests/Mmake.common	29 Jan 2003 08:12:25 -0000	1.41
+++ tests/Mmake.common	7 Apr 2003 05:43:30 -0000
@@ -140,15 +140,35 @@
 # Some tests have more than one possible valid output, so
 # we allow the test to pass if it matches any of the .err_exp* files.
 %.err_res: %.err %.err_exp
-	@-rm -f $@
-	@diff $(DIFF_OPTS) $*.err_exp $*.err > $@ || \
-		{ [ -f $*.err_exp2 ] && \
-		  diff $(DIFF_OPTS) $*.err_exp2 $*.err > $@; } || \
-		{ [ -f $*.err_exp3 ] && \
-		  diff $(DIFF_OPTS) $*.err_exp3 $*.err > $@; } || \
-		{ [ -f $*.err_exp4 ] && \
-		  diff $(DIFF_OPTS) $*.err_exp4 $*.err > $@; } || \
-		{ cat $*.err && exit 1; }
+	@echo "Comparing $*.err with $*.err_exp*,"
+	@echo "	results in $@"
+	@-rm -f $@ $*.err_res[1-5]
+	@{ diff $(DIFF_OPTS) $*.err_exp $*.err > $*.err_res1 && \
+		echo "Matched $*.err_exp" && \
+		cp $*.err_res1 $@; } || \
+	{ test -f $*.err_exp2 && \
+		diff $(DIFF_OPTS) $*.err_exp2 $*.err > $*.err_res2 && \
+		echo "Matched $*.err_exp2" && \
+		cp $*.err_res2 $@; } || \
+	{ test -f $*.err_exp3 && \
+		diff $(DIFF_OPTS) $*.err_exp3 $*.err > $*.err_res3 && \
+		echo "Matched $*.err_exp3" && \
+		cp $*.err_res3 $@; } || \
+	{ test -f $*.err_exp4 && \
+		diff $(DIFF_OPTS) $*.err_exp4 $*.err > $*.err_res4 && \
+		echo "Matched $*.err_exp4" && \
+		cp $*.err_res4 $@; } || \
+	{ test -f $*.err_exp5 && \
+		diff $(DIFF_OPTS) $*.err_exp5 $*.err > $*.err_res5 && \
+		echo "Matched $*.err_exp5" && \
+		cp $*.err_res5 $@; } || \
+	{ shortest=`wc -l $*.err_res[1-5] | grep -v total | sort -n | \
+		head -1 | awk '{ print $$2; }' `; \
+		echo "** $*.err did not match the expected output"; \
+		echo "** (closest match was $$shortest)"; \
+		cp $$shortest $@; \
+		cat $@; \
+		exit 1; }
 
 #-----------------------------------------------------------------------------#
 
@@ -166,7 +186,7 @@
 	rm -f *.out
 
 clean_res:
-	rm -f *.res*
+	rm -f *.res* *.err_res*
 
 clean_logs:
 	rm -f *.log

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.

--------------------------------------------------------------------
This message could not be encrypted because no digital certificate
was found for your address. However, you can encrypt your reply with
the certificate attached below. Details at www.unicrypt.com.au

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3083 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20030407/e1e6653c/attachment.bin>


More information about the reviews mailing list