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 webhost. If there are test failure(s),
8 ## information about the failure(s) is mailed.
10 ## The user must be a member of the webmaster group locally and on webhost.
12 ## This script is run on the PSF's machine as user neal via crontab.
14 ## Yes, this script would probably be easier in python, but then
15 ## there's a bootstrap problem. What if Python doesn't build?
17 ## This script should be fairly clean Bourne shell, ie not too many
18 ## bash-isms. We should try to keep it portable to other Unixes.
19 ## Even though it will probably only run on Linux. I'm sure there are
20 ## several GNU-isms currently (date +%s and readlink).
22 ## Perhaps this script should be broken up into 2 (or more) components.
23 ## Building doc is orthogonal to the rest of the python build/test.
26 ## FIXME: we should detect test hangs (eg, if they take more than 45 minutes)
28 ## FIXME: we should run valgrind
29 ## FIXME: we should run code coverage
31 ## Utilities invoked in this script include:
32 ## basename, date, dirname, expr, grep, readlink, uname
33 ## cksum, make, mutt, rsync, svn
35 ## remember where did we started from
37 if [ "$DIR" = "" ]; then
41 ## make directory absolute
42 DIR
=`readlink -f $DIR`
43 FULLPATHNAME
="$DIR/`basename $0`"
47 ## Configurable options
49 FAILURE_SUBJECT
="Python Regression Test Failures"
50 #FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com"
51 FAILURE_MAILTO
="python-checkins@python.org"
52 #FAILURE_CC="optional--uncomment and set to desired address"
54 REMOTE_SYSTEM
="neal@dinsdale.python.org"
55 REMOTE_DIR
="/data/ftp.python.org/pub/www.python.org/doc/3.1"
56 RESULT_FILE
="$DIR/build/index.html"
57 INSTALL_DIR
="/tmp/python-test-3.1/local"
58 RSYNC_OPTS
="-C -e ssh -rlogD"
60 # Always run the installed version of Python.
61 PYTHON
=$INSTALL_DIR/bin
/python
63 # Python options and regression test program that should always be run.
64 REGRTEST_ARGS
="-E $INSTALL_DIR/lib/python3.0/test/regrtest.py"
66 REFLOG
="build/reflog.txt.out"
67 # These tests are not stable and falsely report leaks sometimes.
68 # The entire leak report will be mailed if any test not in this list leaks.
69 # Note: test_XXX (none currently) really leak, but are disabled
70 # so we don't send spam. Any test which really leaks should only
71 # be listed here if there are also test cases under Lib/test/leakers.
72 LEAKY_TESTS
="test_(asynchat|cmd_line|docxmlrpc|dumbdbm|file|ftplib|httpservers|imaplib|popen2|socket|smtplib|sys|telnetlib|threadedtempfile|threading|threadsignals|xmlrpc)"
74 # These tests always fail, so skip them so we don't get false positives.
76 ALWAYS_SKIP
="-x $_ALWAYS_SKIP"
78 # Skip these tests altogether when looking for leaks. These tests
79 # do not need to be stored above in LEAKY_TESTS too.
80 # test_logging causes hangs, skip it.
81 # KBK 21Apr09: test_httpservers causes hangs, skip for now.
82 LEAKY_SKIPS
="-x test_compiler test_logging test_httpservers"
84 # Change this flag to "yes" for old releases to only update/build the docs.
95 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
98 place_summary_first
() {
100 sed -n '/^[0-9][0-9]* tests OK\./,$p' < $testf \
101 |
egrep -v '\[[0-9]+ refs\]' > $testf.tmp
102 echo "" >> $testf.tmp
103 cat $testf >> $testf.tmp
109 n
=`grep -ic " failed:" $testf`
110 if [ $n -eq 1 ] ; then
111 n
=`grep " failed:" $testf | sed -e 's/ .*//'`
117 if [ "$NUM_FAILURES" != "0" ]; then
119 # FAILURE_CC is optional.
120 if [ "$FAILURE_CC" != "" ]; then
121 dest
="$dest -c $FAILURE_CC"
123 if [ "x$3" != "x" ] ; then
124 (echo "More important issues:"
125 echo "----------------------"
128 echo "Less important issues:"
129 echo "----------------------"
133 fi | mutt
-s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest
139 make clobber
> /dev
/null
2>&1
140 cp -p Modules
/Setup.dist Modules
/Setup
141 # But maybe there was no Makefile - we are only building docs. Clear build:
145 ## get the path we are building
146 repo_path
=$
(grep "url=" .svn
/entries |
sed -e s
/\\W
*url
=// -e s
/\"//g
)
148 ## create results file
149 TITLE
="Automated Python Build Results"
150 echo "<html>" >> $RESULT_FILE
151 echo " <head>" >> $RESULT_FILE
152 echo " <title>$TITLE</title>" >> $RESULT_FILE
153 echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
154 echo " </head>" >> $RESULT_FILE
155 echo "<body>" >> $RESULT_FILE
156 echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
157 echo "<table>" >> $RESULT_FILE
158 echo " <tr>" >> $RESULT_FILE
159 echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
160 echo " </tr><tr>" >> $RESULT_FILE
161 echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
162 echo " </tr><tr>" >> $RESULT_FILE
163 echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
164 echo " </tr><tr>" >> $RESULT_FILE
165 echo " <td>URL:</td><td>$repo_path</td>" >> $RESULT_FILE
166 echo " </tr>" >> $RESULT_FILE
167 echo "</table>" >> $RESULT_FILE
168 echo "<ul>" >> $RESULT_FILE
170 ## update, build, and test
171 ORIG_CHECKSUM
=`cksum $FULLPATHNAME`
174 svn update
>& build
/$F
176 update_status
"Updating" "$F" $start
177 if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
178 ## FIXME: we should check if this file has changed.
179 ## If it has changed, we should re-run the script to pick up changes.
180 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
181 exec $FULLPATHNAME $@
187 ## ignore some of the diffs
188 NUM_DIFFS
=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
189 update_status
"svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
193 .
/configure
--prefix=$INSTALL_DIR --with-pydebug >& build
/$F
195 update_status
"Configuring" "$F" $start
196 if [ $err = 0 ]; then
201 warnings
=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
202 update_status
"Building ($warnings warnings)" "$F" $start
203 if [ $err = 0 ]; then
207 make install >& build
/$F
208 update_status
"Installing" "$F" $start
210 if [ ! -x $PYTHON ]; then
211 ln -s ${PYTHON}3.
* $PYTHON
214 ## make and run basic tests
217 $PYTHON $REGRTEST_ARGS -u urlfetch
>& build
/$F
218 NUM_FAILURES
=`count_failures build/$F`
219 place_summary_first build
/$F
220 update_status
"Testing basics ($NUM_FAILURES failures)" "$F" $start
221 mail_on_failure
"basics" build
/$F
225 $PYTHON -O $REGRTEST_ARGS -u urlfetch
>& build
/$F
226 NUM_FAILURES
=`count_failures build/$F`
227 place_summary_first build
/$F
228 update_status
"Testing opt ($NUM_FAILURES failures)" "$F" $start
229 mail_on_failure
"opt" build
/$F
231 ## run the tests looking for leaks
232 F
=make-test-refleak.out
234 ## ensure that the reflog exists so the grep doesn't fail
236 $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network
$LEAKY_SKIPS >& build
/$F
237 LEAK_PAT
="($LEAKY_TESTS|sum=0)"
238 NUM_FAILURES
=`egrep -vc "$LEAK_PAT" $REFLOG`
239 place_summary_first build
/$F
240 update_status
"Testing refleaks ($NUM_FAILURES failures)" "$F" $start
241 mail_on_failure
"refleak" $REFLOG "$LEAK_PAT"
243 ## now try to run all the tests
246 ## skip curses when running from cron since there's no terminal
247 ## skip sound since it's not setup on the PSF box (/dev/dsp)
248 $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev
$_ALWAYS_SKIP >& build
/$F
249 NUM_FAILURES
=`count_failures build/$F`
250 place_summary_first build
/$F
251 update_status
"Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
252 mail_on_failure
"all" build
/$F
262 make clean
> ..
/build
/$F 2>&1
263 make checkout html
>> ..
/build
/$F 2>&1
265 update_status
"Making doc" "$F" $start
266 if [ $err != 0 ]; then
268 mail_on_failure
"doc" ..
/build
/$F
271 echo "</ul>" >> $RESULT_FILE
272 echo "</body>" >> $RESULT_FILE
273 echo "</html>" >> $RESULT_FILE
276 ## (not used anymore, the daily build is now done directly on the server)
277 #chgrp -R webmaster build/html
278 #chmod -R g+w build/html
279 #rsync $RSYNC_OPTS build/html/* $REMOTE_SYSTEM:$REMOTE_DIR
281 #rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/