[m-rev.] submit_patch improvements

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Sep 22 03:10:51 AEST 2002


Estimated hours taken: 1
Branches: main

tools/submit_patch:
	- Document the --title option.
	- Implement the --no-commit option.
	- Add new option --gcc, for testing the GCC back-end
	  (this option is not yet implemented).
	- Add new options --branch and --gcc-branch,
	  for testing and committing on a branch.
	- Add new options --configure and --gcc-configure,
	  for specifying options to configure.
	- Rearrange the code a bit to improve readability.

Workspace: /home/ceres/fjh/mercury
Index: tools/submit_patch
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/submit_patch,v
retrieving revision 1.1
diff -u -d -p -r1.1 submit_patch
--- tools/submit_patch	20 Sep 2002 08:59:57 -0000	1.1
+++ tools/submit_patch	21 Sep 2002 17:04:37 -0000
@@ -9,26 +9,35 @@
 #	This implements a "commit server".
 #	It takes as input a log message and a patch.
 #	It checks out the Mercury sources, applies the patch,
-#	and it (by bootchecking in a couple of grades),
+#	tests it (by bootchecking in a couple of grades),
 #	and if the tests pass, it commits the patch.
 #	It locks the test directory, so you can submit
 #	multiple patches at once and it will only run
 #	one of them at a time.
 #
 # TODO:
-#	- support committing on a branch
 #	- support testing the native-code back-end
-#	- allow additional options to be passed to configure
 
 usage="\
 Usage: $0 [options] <cvs log message file> <patch file>
 Options:
 	-d <dirname>, --directory <dirname>
 		Run the tests in directory <dirname>.
+	--gcc
+		Test the GCC-based native code back-end.
+		(XXX not yet implemented)
 	-r <CVSROOT>, --repository <CVSROOT>
 		Use the specified CVS repository for checking out mercury.
 	-g <CVSROOT>, --gcc-repository <CVSROOT>
 		Use the specified CVS repository for checking out GCC.
+	--branch <branch>
+		Use the specified branch tag for checking out mercury.
+	--gcc-branch <branch>
+		Use the specified branch tag for checking out GCC.
+	--configure <configure-options>
+		Use the specified options when configuring mercury.
+	--gcc-configure <configure-options>
+		Use the specified options when configuring GCC.
 	-S <megabytes>, --space <megabytes>
 		Require this amount of free disk space.
 	-b <bootcheck-options>, --bootcheck <bootcheck-options>
@@ -36,6 +45,10 @@ Options:
 		the standard bootchecks (asm_fast.gc & hlc.gc).
 	-u <email-address>, --user <email-address>
 		Mail the output to the specified user.
+	-t <title>, --title <title>
+		Specify a name for this patch.
+		The patch title is used in the test sub-directory name,
+		and is also included in the email subject line.
 	-c-, --no-commit
 		Do not commit the patch, even if the tests pass.
 	-h, --help
@@ -58,64 +71,33 @@ test_root=/tmp/$user/mercury
 # Disk space needed (in megabytes)
 disk_space_required=300
 
+# "true" if we should build with the GCC back-end,
+# so that `--target asm' works.
+# XXX not yet implemented
+do_gcc=false
+
 # CVS Repositories
 gcc_cvsroot=:pserver:guest at gcc.gnu.org:/cvs/gcc
 mercury_cvsroot=/home/mercury1/repository
-if [ -d $mercury_cvsroot ]; then
+if [ -d "$mercury_cvsroot/." ]; then
 	:
 else
 	mercury_cvsroot=:pserver:guest at cvs.mercury.cs.mu.oz.au:$mercury_cvsroot
 fi
 
-# A "#"-separated list of bootchecks to run.
-bootchecks="--grade asm_fast.gc # --grade hlc.gc".
-
-#-----------------------------------------------------------------------------#
-
-obtain_lock() {
-	until mkdir $test_root/lock; do
-		sleep 60
-	done
-	echo "Process $$ on host `hostname -f`" > $test_root/lock/info
-}
-
-release_lock() {
-	rm -f $test_root/lock/info
-	rmdir $test_root/lock
-}
-
-#-----------------------------------------------------------------------------#
-
-die() {
-	msg="
-*** check_patch failed:
-*** $@
-
-Log file in $test_dir/OUTPUT.
-
-Leaving the build directory $test_dir intact in case
-you need to use it to debug the problem.
-You must to remove this directory when you have finished with it.
-"
-	echo "$msg" 1>&2
-	echo "$msg" | mail -s "auto-test ($title) failed" $user
-	release_lock
-	exit 1
-}
+# CVS branches
+branch=
+gcc_branch=
 
-succeed() {
-	msg="
-*** check_patch succeeded.
+# Configure options
+configure_opts=
+gcc_configure_opts= --enable-checking --languages=c,mercury
 
-Log file in $test_dir/OUTPUT.
+# A "#"-separated list of bootchecks to run.
+bootchecks="--grade asm_fast.gc # --grade hlc.gc".
 
-Leaving the build directory $test_dir intact in case you want to
-browse $test_dir/OUTPUT.
-You must to remove this directory when you have finished with it.
-"
-	echo "$msg" 1>&2
-	echo "$msg" | mail -s "auto-test ($title) succeeded" $user
-}
+# "true" if we should commit the patch if/when the tests pass.
+commit=true
 
 #-----------------------------------------------------------------------------#
 #
@@ -130,6 +112,9 @@ parse_options() {
 	-t*)
 		title="` expr $1 : '-t\(.*\)' `"; ;;
 
+	--gcc)
+		do_gcc=true; shift ;;
+
 	-d|--directory)
 		test_root="$2"; shift ;;
 	-d*)
@@ -145,6 +130,19 @@ parse_options() {
 	-g*)
 		gcc_cvsroot="` expr $1 : '-g\(.*\)' `"; ;;
 
+	--branch)
+		branch="-r$2"; shift ;;
+
+	--gcc-branch)
+		gcc_branch="-r$2"; shift ;;
+
+	--configure)
+		configure_opts="$2"; shift ;;
+
+	--gcc-configure)
+		gcc_configure_opts="$2"; shift ;;
+	
+
 	-s|--space)
 		disk_space_required="$2"; shift ;;
 	-s*)
@@ -194,6 +192,53 @@ parse_options() {
 
 #-----------------------------------------------------------------------------#
 
+obtain_lock() {
+	until mkdir $test_root/lock; do
+		sleep 60
+	done
+	echo "Process $$ on host `hostname -f`" > $test_root/lock/info
+}
+
+release_lock() {
+	rm -f $test_root/lock/info
+	rmdir $test_root/lock
+}
+
+#-----------------------------------------------------------------------------#
+
+die() {
+	msg="
+*** check_patch failed:
+*** $@
+
+Log file in $test_dir/OUTPUT.
+
+Leaving the build directory $test_dir intact in case
+you need to use it to debug the problem.
+You must to remove this directory when you have finished with it.
+"
+	echo "$msg" 1>&2
+	echo "$msg" | mail -s "auto-test ($title) failed" $user
+	release_lock
+	exit 1
+}
+
+succeed() {
+	msg="
+*** check_patch succeeded.
+
+Log file in $test_dir/OUTPUT.
+
+Leaving the build directory $test_dir intact in case you want to
+browse $test_dir/OUTPUT.
+You must to remove this directory when you have finished with it.
+"
+	echo "$msg" 1>&2
+	echo "$msg" | mail -s "auto-test ($title) succeeded" $user
+}
+
+#-----------------------------------------------------------------------------#
+
 # check we've got a reasonable amount of free disk space -- no point
 # starting if we'll only run out of disk space.
 
@@ -248,23 +293,28 @@ main() {
     mkdir $test_dir			|| die "mkdir $test_dir failed"
     echo "Testing in directory $test_dir"
     {
+        set -x
 	cp $patchfile $test_dir/PATCH	|| die "error copying $patchfile"
 	cp $logmessage $test_dir/CVSLOG	|| die "error copying $logmessage"
 	cd $test_dir			|| die "cd $test_dir failed"
         CVSROOT=$mercury_cvsroot
 	export CVSROOT
-	cvs checkout mercury		|| die "cvs checkout mercury failed"
+	cvs checkout $branch mercury	|| die "cvs checkout mercury failed"
 	cd mercury			|| die "cd mercury failed"
-	cvs checkout tests		|| die "cvs checkout tests failed"
+	cvs checkout $branch tests	|| die "cvs checkout tests failed"
 	find . | sort > ../FILES.old
 	patch -p0 < ../PATCH		|| die "applying patch failed"
 	find . | sort > ../FILES.new
 	do_cvs_add_remove		|| die "do_cvs_add_remove failed"
 	autoconf			|| die "autoconf failed"
-	sh configure --prefix=$test_dir/install || die "configure failed"
+	sh configure --prefix=$test_dir/install $configure_opts \
+					|| die "configure failed"
 	make				|| die "make failed"
 	do_bootchecks			|| die "do_bootchecks failed"
-	cvs commit -m"`cat ../CVSLOG`"	|| die "cvs commit failed"
+	case $commit in true)
+		cvs commit -m"`cat ../CVSLOG`" || die "cvs commit failed"
+		;;
+	esac
 	cd ..				|| die "cd .."
 	rm -rf mercury			|| die "rm -rf mercury failed"
     } > $test_dir/OUTPUT 2>&1

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