[m-rev.] for review: fix parallel test failures

Simon Taylor stayl at cs.mu.OZ.AU
Tue Sep 3 17:09:32 AEST 2002


Estimated hours taken: 0.2
Branches: main

tests/Mmake.common:
	Don't run the tests in each directory in parallel.
	This avoids problems with targets being made by multiple
	mmake processes at the same time, and being cleaned up
	before all users are finished with them. The subdirectories
	are still run in parallel.

	The %.log targets now return an exit status of 1
	if the test fails.

Index: Mmake.common
===================================================================
RCS file: /home/mercury1/repository/tests/Mmake.common,v
retrieving revision 1.28
diff -u -u -r1.28 Mmake.common
--- Mmake.common	2 Sep 2002 03:39:52 -0000	1.28
+++ Mmake.common	3 Sep 2002 06:08:40 -0000
@@ -244,8 +244,6 @@
 #
 # Run a single test, cleaning up if it succeeds, or producing
 # a log file and gzipping the executable the test fails.
-# Note that the %.log target does not fail if the test fails --
-# we really want `--keep-going' to be the default for this Mmakefile.
 #
 .PHONY: %.log
 %.log: start_runtests_local
@@ -263,6 +261,7 @@
 		echo FAILED TEST $(THIS_DIR)/$* in grade $(GRADE) \
 			| tee -a $@; \
 		echo $* >> FAILED_TESTS; \
+		exit 1; \
 	else \
 		{ mmake $$test.runtest 2>&1 || touch $*.failed; } \
 			| tee -a $@; \
@@ -274,6 +273,7 @@
 			echo FAILED TEST $(THIS_DIR)/$* in grade $(GRADE) \
 				| tee -a $@; \
 			echo $* >> FAILED_TESTS; \
+			exit 1; \
 		else \
 			rm -f $@; \
 			rm -f $$test.out* $$test.*res*; \
@@ -282,20 +282,27 @@
 		fi; \
 	fi
 
+# XXX The tests cannot be run in parallel because where several test
+# cases depend on the same target, the different invocations of mmake
+# above may all attempt to create the target at the same time.
+# Also, `mmake $$test.realclean' would be run before all users
+# of the target are finished with it.
 TEST_LOGS = $(THIS_DIR_TESTS_TO_RUN:%=%.log)
-runtests_local: $(TEST_LOGS)
+runtests_local:
 	@touch DUMMY.log
-	@cat *.log > $(ERROR_OUTPUT_FILE)
-	@rm -f *.log
-	@if [ -s $(ERROR_OUTPUT_FILE) ]; then \
-		echo "FAILED tests in $(THIS_DIR) in grade $(GRADE)"; \
-		exit 1; \
-	else \
+	@if mmake -k -j1 $(TEST_LOGS) && \
+		cat *.log > $(ERROR_OUTPUT_FILE) && \
+		rm -f *.log && \
+		[ ! -s $(ERROR_OUTPUT_FILE) ]; \
+	then \
 		echo "FINISHED tests in $(THIS_DIR) in grade $(GRADE)"; \
 		echo cleaning up the directory after the tests; \
 		mmake $(RM_JFACTOR) realclean_local > /dev/null 2>&1; \
 		rm core > /dev/null 2>&1; \
 		touch CLEAN; \
+	else \
+		echo "FAILED tests in $(THIS_DIR) in grade $(GRADE)"; \
+		exit 1; \
 	fi
 
 endif	# THIS_DIR_TESTS_TO_RUN != ""
--------------------------------------------------------------------------
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