[m-rev.] for review: pipe expected output through command

Peter Ross pro at missioncriticalit.com
Sat Nov 23 03:12:45 AEDT 2002


Hi,

for fjh to review

===================================================================


Estimated hours taken: 0.5
Branches: main

Allow the user to pipe the expected output of a mercury program
through another command.  This allows one to avoid problems on systems
where the expected output is stored in a different format to that
generated by an executable.

tests/Mmake.common:
	Define the output variable CAT before including Mmake.params
	so that it can be overridden.

tests/Mmake.common:
tests/general/string_format/Mmakefile:
	Pipe the expected output through CAT before placing it in the .out
	file.

Index: Mmake.common
===================================================================
RCS file: /home/mercury1/repository/tests/Mmake.common,v
retrieving revision 1.35
diff -u -r1.35 Mmake.common
--- Mmake.common	3 Nov 2002 14:28:10 -0000	1.35
+++ Mmake.common	22 Nov 2002 16:03:25 -0000
@@ -19,6 +19,7 @@
 
 MAIN_TARGET = runtests
 
+CAT=cat
 -include $(TESTS_DIR)/Mmake.params
 
 # Avoid trying to make this file with `mmc --make' if it doesn't exist.
@@ -99,23 +100,23 @@
 	@echo "Comparing $*.out with $*.exp*,"
 	@echo "	results in $@"
 	@-rm -f $@ $*.res[1-5]
-	@{ diff $(DIFF_OPTS) $*.exp $*.out > $*.res1 && \
+	@{ $(CAT) < $*.exp | diff $(DIFF_OPTS) - $*.out > $*.res1 && \
 		echo "Matched $*.exp" && \
 		cp $*.res1 $@; } || \
 	{ test -f $*.exp2 && \
-		diff $(DIFF_OPTS) $*.exp2 $*.out > $*.res2 && \
+		$(CAT) < $*.exp2 | diff $(DIFF_OPTS) - $*.out > $*.res2 && \
 		echo "Matched $*.exp2" && \
 		cp $*.res2 $@; } || \
 	{ test -f $*.exp3 && \
-		diff $(DIFF_OPTS) $*.exp3 $*.out > $*.res3 && \
+		$(CAT) < $*.exp3 | diff $(DIFF_OPTS) - $*.out > $*.res3 && \
 		echo "Matched $*.exp3" && \
 		cp $*.res3 $@; } || \
 	{ test -f $*.exp4 && \
-		diff $(DIFF_OPTS) $*.exp4 $*.out > $*.res4 && \
+		$(CAT) < $*.exp4 | diff $(DIFF_OPTS) - $*.out > $*.res4 && \
 		echo "Matched $*.exp4" && \
 		cp $*.res4 $@; } || \
 	{ test -f $*.exp5 && \
-		diff $(DIFF_OPTS) $*.exp5 $*.out > $*.res5 && \
+		$(CAT) < $*.exp5 | diff $(DIFF_OPTS) - $*.out > $*.res5 && \
 		echo "Matched $*.exp5" && \
 		cp $*.res5 $@; } || \
 	{ shortest=`wc -l $*.res[1-5] | grep -v total | sort -n | \
Index: general/string_format/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/general/string_format/Mmakefile,v
retrieving revision 1.6
diff -u -r1.6 Mmakefile
--- general/string_format/Mmakefile	22 Nov 2002 14:09:30 -0000	1.6
+++ general/string_format/Mmakefile	22 Nov 2002 16:03:32 -0000
@@ -76,29 +76,29 @@
 	@echo "Comparing $*.sorted_out with $*.exp*,"
 	@echo "	results in $@"
 	@-rm -f $@ $*.res[1-5]
-	@cat $*.out | sort > $*.sorted_out
-	@{ diff $(DIFF_OPTS) $*.exp $*.sorted_out > $*.res1 && \
+	@cat $*.out | sort > $*.sorted
+	@{ $(CAT) < $*.exp | diff $(DIFF_OPTS) - $*.sorted > $*.res1 && \
 		echo "Matched $*.exp" && \
 		cp $*.res1 $@; } || \
 	{ test -f $*.exp2 && \
-		diff $(DIFF_OPTS) $*.exp2 $*.sorted_out > $*.res2 && \
+		$(CAT) < $*.exp2 | diff $(DIFF_OPTS) - $*.sorted > $*.res2 && \
 		echo "Matched $*.exp2" && \
 		cp $*.res2 $@; } || \
 	{ test -f $*.exp3 && \
-		diff $(DIFF_OPTS) $*.exp3 $*.sorted_out > $*.res3 && \
+		$(CAT) < $*.exp3 | diff $(DIFF_OPTS) - $*.sorted > $*.res3 && \
 		echo "Matched $*.exp3" && \
 		cp $*.res3 $@; } || \
 	{ test -f $*.exp4 && \
-		diff $(DIFF_OPTS) $*.exp4 $*.sorted_out > $*.res4 && \
+		$(CAT) < $*.exp4 | diff $(DIFF_OPTS) - $*.sorted > $*.res4 && \
 		echo "Matched $*.exp4" && \
 		cp $*.res4 $@; } || \
 	{ test -f $*.exp5 && \
-		diff $(DIFF_OPTS) $*.exp5 $*.sorted_out > $*.res5 && \
+		$(CAT) < $*.exp5 | diff $(DIFF_OPTS) - $*.sorted > $*.res5 && \
 		echo "Matched $*.exp5" && \
 		cp $*.res5 $@; } || \
 	{ shortest=`wc -l $*.res[1-5] | grep -v total | sort -n | \
 		head -1 | awk '{ print $$2; }' `; \
-		echo "** $*.sorted_out did not match the expected output"; \
+		echo "** $*.sorted did not match the expected output"; \
 		echo "** (closest match was $$shortest)"; \
 		echo "** The diff is located in $@"; \
 		cp $$shortest $@; \
@@ -107,11 +107,11 @@
 
 #-----------------------------------------------------------------------------#
 
-realclean_local: clean_sorted_outs
-clean_local: clean_sorted_outs
+realclean_local: clean_sorteds
+clean_local: clean_sorteds
 
-clean_sorted_outs:
-	rm -f *.sorted_out
+clean_sorteds:
+	rm -f *.sorted
 
 #-----------------------------------------------------------------------------#
 #-----------------------------------------------------------------------------#

--------------------------------------------------------------------------
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