[m-rev.] commit server
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Sep 19 18:43:06 AEST 2002
Estimated hours taken: 4
Branches: main
tools/check_patch:
New file. This implements a "commit server".
It takes as input a log message and a patch.
It checks out the Mercury sources, applies the patch,
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.
Not yet very well tested.
Workspace: /home/ceres/fjh/mercury
Index: tools/check_patch
===================================================================
RCS file: tools/check_patch
diff -N tools/check_patch
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tools/check_patch 19 Sep 2002 08:26:29 -0000
@@ -0,0 +1,260 @@
+#!/bin/sh
+#---------------------------------------------------------------------------#
+# Copyright (C) 2002 The University of Melbourne.
+# This file may only be copied under the terms of the GNU General
+# Public License - see the file COPYING in the Mercury distribution.
+#---------------------------------------------------------------------------#
+#
+# check_patch:
+# 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),
+# 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]
+Options:
+ -d <dirname>, --directory <dirname>
+ Run the tests in directory <dirname>.
+ -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.
+ -S <megabytes>, --space <megabytes>
+ Require this amount of free disk space.
+ -b <bootcheck-options>, --bootcheck <bootcheck-options>
+ Bootcheck with the specified options, in addition
+ the standard bootchecks (asm_fast.gc & hlc.gc).
+ -u <email-address>, --user <email-address>
+ Mail the output to the specified user.
+ -c-, --no-commit
+ Do not commit the patch, even if the tests pass.
+ -h, --help
+ Display this usage message.
+"
+
+#---------------------------------------------------------------------------#
+
+# Default option settings
+
+# Name of this patch
+title=$$
+
+# User to mail results to
+user=`whoami`
+
+# Place to run the tests
+test_root=/tmp/$user/mercury
+
+# Disk space needed (in megabytes)
+disk_space_required=300
+
+# CVS Repositories
+gcc_cvsroot=:pserver:guest at gcc.gnu.org:/cvs/gcc
+mercury_cvsroot=/home/mercury1/repository
+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
+}
+
+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
+}
+
+#-----------------------------------------------------------------------------#
+#
+# Parse the options
+#
+
+parse_options() {
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ -t|--title)
+ title="$2"; shift ;;
+ -t*)
+ title="` expr $1 : '-t\(.*\)' `"; ;;
+
+ -d|--directory)
+ test_root="$2"; shift ;;
+ -d*)
+ test_root="` expr $1 : '-d\(.*\)' `"; ;;
+
+ -r|--repository)
+ mercury_cvsroot="$2"; shift ;;
+ -r*)
+ mercury_cvsroot="` expr $1 : '-r\(.*\)' `"; ;;
+
+ -g|--gcc-repository)
+ gcc_cvsroot="$2"; shift ;;
+ -g*)
+ gcc_cvsroot="` expr $1 : '-g\(.*\)' `"; ;;
+
+ -s|--space)
+ disk_space_required="$2"; shift ;;
+ -s*)
+ disk_space_required="` expr $1 : '-s\(.*\)' `"; ;;
+
+ -b|--bootcheck)
+ bootchecks="$bootchecks#$2"; shift ;;
+ -b*)
+ bootchecks="$bootchecks#` expr $1 : '-b\(.*\)' `"; ;;
+
+ -u|--user)
+ user="$2"; shift ;;
+ -u*)
+ user="` expr $1 : '-u\(.*\)' `"; ;;
+
+ -c-|--no-commit)
+ commit=false ;;
+ -c|--commit)
+ commit=true ;;
+
+ -h|--help)
+ echo "$usage";
+ exit 0 ;;
+
+ --)
+ shift; break ;;
+ -*)
+ echo "$0: unknown option \`$1'" 1>&2
+ echo "$usage" 1>&2
+ exit 1 ;;
+ *)
+ break ;;
+ esac
+ shift
+ done
+
+ if [ $# -ne 2 ]; then
+ echo "$0: wrong number of arguments" 1>&2
+ echo "usage: $0 <log message file> <patch file>" 1>&2
+ echo "Use \`--help' for help." 1>&2
+ exit 1
+ fi
+ logmessage=$1
+ patchfile=$2
+ test_dir=$test_root/test_$title
+}
+
+#-----------------------------------------------------------------------------#
+
+# check we've got a reasonable amount of free disk space -- no point
+# starting if we'll only run out of disk space.
+
+check_disk_space() {
+
+ free=`df -m $test_root/. | awk '
+ NR == 2 && NF > 4 { print $4; exit; }
+ NR == 3 { print $3; }
+ '`
+ echo "Free disk space: $free megabytes"
+ [ "$free" -gt $disk_space_required ] ||
+ die "Insufficient disk space on $test_root"
+}
+
+#-----------------------------------------------------------------------------#
+
+do_bootchecks() {
+ old_IFS=$IFS
+ IFS=#
+ for bootcheck in $bootchecks; do
+ IFS=$old_IFS
+ eval tools/bootcheck $bootcheck ||
+ die "tools/bootcheck $bootcheck failed"
+ IFS=#
+ done
+ IFS=$old_IFS
+}
+
+#-----------------------------------------------------------------------------#
+
+main() {
+ parse_options "$@" || die "parse_options failed"
+ [ -d $test_root ] || mkdir -p $test_root ||
+ die "creating dir $test_root failed"
+ obtain_lock || die "can't obtain lock"
+ trap 'die "interrupted"' 1 2 3 13 15
+ check_disk_space || die "insufficient disk space"
+ mkdir $test_dir || die "mkdir $test_dir failed"
+ echo "Testing in directory $test_dir"
+ {
+ 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"
+ cd mercury || die "cd mercury failed"
+ cvs checkout tests || die "cvs checkout tests failed"
+ patch -p0 < ../PATCH || die "applying patch failed"
+ autoconf || die "autoconf failed"
+ sh configure --prefix=$test_dir/install || die "configure failed"
+ make || die "make failed"
+ do_bootchecks || die "do_bootchecks failed"
+ cvs commit -m"`cat ../CVSLOG`" || die "cvs commit failed"
+ cd .. || die "cd .."
+ rm -rf mercury || die "rm -rf mercury failed"
+ } > $test_dir/OUTPUT 2>&1
+ release_lock
+ succeed
+ exit 0
+}
+#-----------------------------------------------------------------------------#
+main "$@"
+#-----------------------------------------------------------------------------#
--
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