3 ## Script to build and test the latest python from svn. It basically
5 ## svn up ; ./configure ; make ; make test ; make install ; cd Doc ; make
7 ## Logs are kept and rsync'ed to the host. If there are test failure(s),
8 ## information about the failure(s) is mailed.
10 ## This script is run on the PSF's machine as user neal via crontab.
12 ## Yes, this script would probably be easier in python, but then
13 ## there's a bootstrap problem. What if Python doesn't build?
15 ## This script should be fairly clean Bourne shell, ie not too many
16 ## bash-isms. We should try to keep it portable to other Unixes.
17 ## Even though it will probably only run on Linux. I'm sure there are
18 ## several GNU-isms currently (date +%s and readlink).
20 ## Perhaps this script should be broken up into 2 (or more) components.
21 ## Building doc is orthogonal to the rest of the python build/test.
24 ## FIXME: we should detect test hangs (eg, if they take more than 45 minutes)
26 ## FIXME: we should run valgrind
27 ## FIXME: we should run code coverage
29 ## Utilities invoked in this script include:
30 ## basename, date, dirname, expr, grep, readlink, uname
31 ## cksum, make, mutt, rsync, svn
33 ## remember where did we started from
35 if [ "$DIR" = "" ]; then
39 ## make directory absolute
40 DIR
=`readlink -f $DIR`
41 FULLPATHNAME
="$DIR/`basename $0`"
45 ## Configurable options
47 FAILURE_SUBJECT
="Python Regression Test Failures"
48 #FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com"
49 FAILURE_MAILTO
="python-checkins@python.org"
51 REMOTE_SYSTEM
="neal@dinsdale.python.org"
52 REMOTE_DIR
="/data/ftp.python.org/pub/docs.python.org/dev/"
53 RESULT_FILE
="$DIR/build/index.html"
54 INSTALL_DIR
="/tmp/python-test/local"
55 RSYNC_OPTS
="-aC -e ssh"
57 # Always run the installed version of Python.
58 PYTHON
=$INSTALL_DIR/bin
/python
60 # Python options and regression test program that should always be run.
61 REGRTEST_ARGS
="-E -tt $INSTALL_DIR/lib/python2.5/test/regrtest.py"
63 REFLOG
="build/reflog.txt.out"
64 # These tests are not stable and falsely report leaks sometimes.
65 # The entire leak report will be mailed if any test not in this list leaks.
66 # Note: test_XXX (none currently) really leak, but are disabled
67 # so we don't send spam. Any test which really leaks should only
68 # be listed here if there are also test cases under Lib/test/leakers.
69 LEAKY_TESTS
="test_(XXX)" # Currently no tests should report spurious leaks.
71 # Skip these tests altogether when looking for leaks. These tests
72 # do not need to be stored above in LEAKY_TESTS too.
73 # test_compiler almost never finishes with the same number of refs
74 # since it depends on other modules, skip it.
75 # test_logging causes hangs, skip it.
76 LEAKY_SKIPS
="-x test_compiler test_logging"
78 # Change this flag to "yes" for old releases to only update/build the docs.
89 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
93 if [ "$NUM_FAILURES" != "0" ]; then
94 mutt
-s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2
101 rm -f $RESULT_FILE build
/*.out
104 ## create results file
105 TITLE
="Automated Python Build Results"
106 echo "<html>" >> $RESULT_FILE
107 echo " <head>" >> $RESULT_FILE
108 echo " <title>$TITLE</title>" >> $RESULT_FILE
109 echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
110 echo " </head>" >> $RESULT_FILE
111 echo "<body>" >> $RESULT_FILE
112 echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
113 echo "<table>" >> $RESULT_FILE
114 echo " <tr>" >> $RESULT_FILE
115 echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
116 echo " </tr><tr>" >> $RESULT_FILE
117 echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
118 echo " </tr><tr>" >> $RESULT_FILE
119 echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
120 echo " </tr>" >> $RESULT_FILE
121 echo "</table>" >> $RESULT_FILE
122 echo "<ul>" >> $RESULT_FILE
124 ## update, build, and test
125 ORIG_CHECKSUM
=`cksum $FULLPATHNAME`
128 svn update
>& build
/$F
130 update_status
"Updating" "$F" $start
131 if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
132 ## FIXME: we should check if this file has changed.
133 ## If it has changed, we should re-run the script to pick up changes.
134 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
135 exec $FULLPATHNAME $@
141 ## ignore some of the diffs
142 NUM_DIFFS
=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
143 update_status
"svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
147 .
/configure
--prefix=$INSTALL_DIR --with-pydebug >& build
/$F
149 update_status
"Configuring" "$F" $start
150 if [ $err = 0 ]; then
155 warnings
=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
156 update_status
"Building ($warnings warnings)" "$F" $start
157 if [ $err = 0 ]; then
161 make install >& build
/$F
162 update_status
"Installing" "$F" $start
164 if [ ! -x $PYTHON ]; then
165 ln -s ${PYTHON}2.
* $PYTHON
168 ## make and run basic tests
171 $PYTHON $REGRTEST_ARGS >& build
/$F
172 NUM_FAILURES
=`grep -ic " failed:" build/$F`
173 update_status
"Testing basics ($NUM_FAILURES failures)" "$F" $start
174 mail_on_failure
"basics" build
/$F
178 $PYTHON -O $REGRTEST_ARGS >& build
/$F
179 NUM_FAILURES
=`grep -ic " failed:" build/$F`
180 update_status
"Testing opt ($NUM_FAILURES failures)" "$F" $start
181 mail_on_failure
"opt" build
/$F
183 ## run the tests looking for leaks
184 F
=make-test-refleak.out
186 ## ensure that the reflog exists so the grep doesn't fail
188 $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network
$LEAKY_SKIPS >& build
/$F
189 NUM_FAILURES
=`egrep -vc "$LEAKY_TESTS" $REFLOG`
190 update_status
"Testing refleaks ($NUM_FAILURES failures)" "$F" $start
191 mail_on_failure
"refleak" $REFLOG
193 ## now try to run all the tests
196 ## skip curses when running from cron since there's no terminal
197 ## skip sound since it's not setup on the PSF box (/dev/dsp)
198 $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev
>& build
/$F
199 NUM_FAILURES
=`grep -ic " failed:" build/$F`
200 update_status
"Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
201 mail_on_failure
"all" build
/$F
213 update_status
"Making doc" "$F" $start
214 if [ $err != 0 ]; then
216 mail_on_failure
"doc" ..
/build
/$F
219 echo "</ul>" >> $RESULT_FILE
220 echo "</body>" >> $RESULT_FILE
221 echo "</html>" >> $RESULT_FILE
224 rsync
$RSYNC_OPTS html
/* $REMOTE_SYSTEM:$REMOTE_DIR
226 rsync
$RSYNC_OPTS index.html
*.out
$REMOTE_SYSTEM:$REMOTE_DIR/results
/