[m-rev.] diff: fix failing tests on almery

Mark Brown mark at cs.mu.OZ.AU
Mon Dec 13 12:23:05 AEDT 2004


(I posted this last Friday but it apparently didn't get through -- trying
again.)

Estimated hours taken: 0.5
Branches: main

Fix failing tests in tests/general/string_format/.  These tests rely on the
output file being sorted by the 'sort' command prior to being compared with
the expected output.  They were failing due to different behaviour with newer
versions of 'sort'.

The fix is to sort the expected output as well as the actual output before
comparing them.

tests/general/string_format/Mmakefile:
	Sort the expected output files before comparison, and ensure that
	the generated files are cleaned up afterwards.

Index: tests/general/string_format/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/general/string_format/Mmakefile,v
retrieving revision 1.10
diff -u -r1.10 Mmakefile
--- tests/general/string_format/Mmakefile	12 Jan 2003 22:33:14 -0000	1.10
+++ tests/general/string_format/Mmakefile	10 Dec 2004 16:10:59 -0000
@@ -73,33 +73,40 @@
 #
 # This is adapted from the rule in ../../Mmake.common.  The only
 # differences are that we only cat the first 50 lines to stdout, as
-# generally it is quite big and that we sort the output before the
-# comparison, as the IL and C backends use a different ordering for
-# lexical comparisons.
+# generally it is quite big and that we sort both the output and the
+# expected output before the comparison, as the IL and C backends use
+# a different ordering for lexical comparisons.  The reason for sorting
+# the expected output as well is to allow for different behaviour in
+# different versions of sort.
 #
 %.res: %.exp %.out
-	@echo "Comparing $*.sorted_out with $*.exp*,"
+	@echo "Comparing $*.sorted_out with $*.sorted_exp*,"
 	@echo "	results in $@"
 	@-rm -f $@ $*.res[1-5]
 	@sort $*.out > $*.sorted_out
-	@{ diff $(DIFF_OPTS) $*.exp $*.sorted_out > $*.res1 && \
-		echo "Matched $*.exp" && \
+	@sort $*.exp > $*.sorted_exp
+	@{ diff $(DIFF_OPTS) $*.sorted_exp $*.sorted_out > $*.res1 && \
+		echo "Matched $*.sorted_exp" && \
 		cp $*.res1 $@; } || \
 	{ test -f $*.exp2 && \
-		diff $(DIFF_OPTS) $*.exp2 $*.sorted_out > $*.res2 && \
-		echo "Matched $*.exp2" && \
+		@sort $*.exp2 > $*.sorted_exp2 \
+		diff $(DIFF_OPTS) $*.sorted_exp2 $*.sorted_out > $*.res2 && \
+		echo "Matched $*.sorted_exp2" && \
 		cp $*.res2 $@; } || \
 	{ test -f $*.exp3 && \
-		diff $(DIFF_OPTS) $*.exp3 $*.sorted_out > $*.res3 && \
-		echo "Matched $*.exp3" && \
+		@sort $*.exp3 > $*.sorted_exp3 \
+		diff $(DIFF_OPTS) $*.sorted_exp3 $*.sorted_out > $*.res3 && \
+		echo "Matched $*.sorted_exp3" && \
 		cp $*.res3 $@; } || \
 	{ test -f $*.exp4 && \
-		diff $(DIFF_OPTS) $*.exp4 $*.sorted_out > $*.res4 && \
-		echo "Matched $*.exp4" && \
+		@sort $*.exp4 > $*.sorted_exp4 \
+		diff $(DIFF_OPTS) $*.sorted_exp4 $*.sorted_out > $*.res4 && \
+		echo "Matched $*.sorted_exp4" && \
 		cp $*.res4 $@; } || \
 	{ test -f $*.exp5 && \
-		diff $(DIFF_OPTS) $*.exp5 $*.sorted_out > $*.res5 && \
-		echo "Matched $*.exp5" && \
+		@sort $*.exp5 > $*.sorted_exp5 \
+		diff $(DIFF_OPTS) $*.sorted_exp5 $*.sorted_out > $*.res5 && \
+		echo "Matched $*.sorted_exp5" && \
 		cp $*.res5 $@; } || \
 	{ shortest=`wc -l $*.res[1-5] | grep -v total | sort -n | \
 		head -1 | awk '{ print $$2; }' `; \
@@ -112,11 +119,11 @@
 
 #-----------------------------------------------------------------------------#
 
-realclean_local: clean_sorted_outs
-clean_local: clean_sorted_outs
+realclean_local: clean_sorted_files
+clean_local: clean_sorted_files
 
-clean_sorted_outs:
-	rm -f *.sorted_out
+clean_sorted_files:
+	rm -f *.sorted_out *.sorted_exp*
 
 #-----------------------------------------------------------------------------#
 #-----------------------------------------------------------------------------#
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list