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="python-checkins@python.org"
49 #FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com"
50 FAILURE_MAILTO
="nnorwitz@gmail.com"
52 REMOTE_SYSTEM
="neal@dinsdale.python.org"
53 REMOTE_DIR
="/data/ftp.python.org/pub/docs.python.org/dev/"
54 RESULT_FILE
="$DIR/build/index.html"
55 INSTALL_DIR
="/tmp/python-test/local"
56 RSYNC_OPTS
="-aC -e ssh"
58 REFLOG
="build/reflog.txt.out"
68 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
72 if [ "$NUM_FAILURES" != "0" ]; then
73 mutt
-s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2
80 rm -f $RESULT_FILE build
/*.out
83 ## create results file
84 TITLE
="Automated Python Build Results"
85 echo "<html>" >> $RESULT_FILE
86 echo " <head>" >> $RESULT_FILE
87 echo " <title>$TITLE</title>" >> $RESULT_FILE
88 echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
89 echo " </head>" >> $RESULT_FILE
90 echo "<body>" >> $RESULT_FILE
91 echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
92 echo "<table>" >> $RESULT_FILE
93 echo " <tr>" >> $RESULT_FILE
94 echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
95 echo " </tr><tr>" >> $RESULT_FILE
96 echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
97 echo " </tr><tr>" >> $RESULT_FILE
98 echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
99 echo " </tr>" >> $RESULT_FILE
100 echo "</table>" >> $RESULT_FILE
101 echo "<ul>" >> $RESULT_FILE
103 ## update, build, and test
104 ORIG_CHECKSUM
=`cksum $FULLPATHNAME`
107 svn update
>& build
/$F
109 update_status
"Updating" "$F" $start
110 if [ $err = 0 ]; then
111 ## FIXME: we should check if this file has changed.
112 ## If it has changed, we should re-run the script to pick up changes.
113 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
114 exec $FULLPATHNAME $@
120 ## ignore some of the diffs
121 NUM_DIFFS
=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
122 update_status
"svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
126 .
/configure
--prefix=$INSTALL_DIR --with-pydebug >& build
/$F
128 update_status
"Configuring" "$F" $start
129 if [ $err = 0 ]; then
134 warnings
=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
135 update_status
"Building ($warnings warnings)" "$F" $start
136 if [ $err = 0 ]; then
140 make install >& build
/$F
141 update_status
"Installing" "$F" $start
143 ## make and run basic tests
146 make test >& build
/$F
147 NUM_FAILURES
=`grep -ic fail build/$F`
148 update_status
"Testing basics ($NUM_FAILURES failures)" "$F" $start
149 ## FIXME: should mail since -uall below should find same problems
150 mail_on_failure
"basics" build
/$F
152 ## run the tests looking for leaks
153 F
=make-test-refleak.out
155 .
/python .
/Lib
/test
/regrtest.py
-R 4:3:$REFLOG -u network
>& build
/$F
156 NUM_FAILURES
=`grep -ic leak $REFLOG`
157 update_status
"Testing refleaks ($NUM_FAILURES failures)" "$F" $start
158 mail_on_failure
"refleak" $REFLOG
160 ## now try to run all the tests
163 ## skip curses when running from cron since there's no terminal
164 ## skip sound since it's not setup on the PSF box (/dev/dsp)
165 .
/python
-E -tt .
/Lib
/test
/regrtest.py
-uall -x test_curses test_linuxaudiodev test_ossaudiodev
>& build
/$F
166 NUM_FAILURES
=`grep -ic fail build/$F`
167 update_status
"Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
168 mail_on_failure
"all" build
/$F
180 update_status
"Making doc" "$F" $start
181 if [ $err != 0 ]; then
183 mail_on_failure
"doc" ..
/build
/$F
186 echo "</ul>" >> $RESULT_FILE
187 echo "</body>" >> $RESULT_FILE
188 echo "</html>" >> $RESULT_FILE
191 rsync
$RSYNC_OPTS html
/ $REMOTE_SYSTEM:$REMOTE_DIR
193 rsync
$RSYNC_OPTS index.html
*.out
$REMOTE_SYSTEM:$REMOTE_DIR/results
/