blob: de5153981ffc92802ec547d890370501f2ba3b2d [file] [log] [blame]
Neal Norwitz461aa5b2006-01-02 20:07:16 +00001#!/bin/sh
2
3## Script to build and test the latest python from svn. It basically
4## does this:
5## svn up ; ./configure ; make ; make test ; make install ; cd Doc ; make
6##
7## Logs are kept and rsync'ed to the host. If there are test failure(s),
8## information about the failure(s) is mailed.
9##
10## This script is run on the PSF's machine as user neal via crontab.
11##
12## Yes, this script would probably be easier in python, but then
13## there's a bootstrap problem. What if Python doesn't build?
14##
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).
19##
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.
22##
23
24## FIXME: we should detect test hangs (eg, if they take more than 45 minutes)
25
26## FIXME: we should run valgrind
27## FIXME: we should run code coverage
28
29## Utilities invoked in this script include:
Neal Norwitzd3a58672006-01-02 23:22:41 +000030## basename, date, dirname, expr, grep, readlink, uname
Neal Norwitz461aa5b2006-01-02 20:07:16 +000031## cksum, make, mutt, rsync, svn
32
Neal Norwitz461aa5b2006-01-02 20:07:16 +000033## remember where did we started from
34DIR=`dirname $0`
35if [ "$DIR" = "" ]; then
36 DIR="."
37fi
38
39## make directory absolute
40DIR=`readlink -f $DIR`
Neal Norwitzd3a58672006-01-02 23:22:41 +000041FULLPATHNAME="$DIR/`basename $0`"
Neal Norwitz461aa5b2006-01-02 20:07:16 +000042## we want Misc/..
43DIR=`dirname $DIR`
44
45## Configurable options
46
47FAILURE_SUBJECT="Python Regression Test Failures"
Neal Norwitz461aa5b2006-01-02 20:07:16 +000048#FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com"
Neal Norwitzf415d5f2006-02-19 18:48:19 +000049FAILURE_MAILTO="python-checkins@python.org"
Neal Norwitz461aa5b2006-01-02 20:07:16 +000050
51REMOTE_SYSTEM="neal@dinsdale.python.org"
52REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/"
53RESULT_FILE="$DIR/build/index.html"
54INSTALL_DIR="/tmp/python-test/local"
55RSYNC_OPTS="-aC -e ssh"
56
57REFLOG="build/reflog.txt.out"
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000058# These tests are not stable and falsely report leaks sometimes.
Neal Norwitzf415d5f2006-02-19 18:48:19 +000059# The entire leak report will be mailed if any test not in this list leaks.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000060# Note: test_XXX (none currently) really leak, but are disabled
61# so we don't send spam. Any test which really leaks should only
62# be listed here if there are also test cases under Lib/test/leakers.
63LEAKY_TESTS="test_(ctypes|filecmp|socket|threadedtempfile|threading|urllib2)"
Neal Norwitzf415d5f2006-02-19 18:48:19 +000064
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000065# Skip these tests altogether when looking for leaks. These tests
66# do not need to be stored above in LEAKY_TESTS too.
67# test_compiler almost never finishes with the same number of refs
68# since it depends on other modules, skip it.
69# test_logging causes hangs, skip it.
70LEAKY_SKIPS="-x test_compiler test_logging"
71
72# Change this flag to "yes" for old releases to only update/build the docs.
Neal Norwitz88b78d82006-02-14 08:14:16 +000073BUILD_DISABLED="no"
Neal Norwitz461aa5b2006-01-02 20:07:16 +000074
75## utility functions
76current_time() {
77 date +%s
78}
79
80update_status() {
81 now=`current_time`
82 time=`expr $now - $3`
83 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
84}
85
86mail_on_failure() {
87 if [ "$NUM_FAILURES" != "0" ]; then
88 mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2
89 fi
90}
91
92## setup
93cd $DIR
94mkdir -p build
95rm -f $RESULT_FILE build/*.out
96rm -rf $INSTALL_DIR
97
98## create results file
99TITLE="Automated Python Build Results"
Neal Norwitzb8967592006-01-16 04:37:22 +0000100echo "<html>" >> $RESULT_FILE
101echo " <head>" >> $RESULT_FILE
102echo " <title>$TITLE</title>" >> $RESULT_FILE
103echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
104echo " </head>" >> $RESULT_FILE
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000105echo "<body>" >> $RESULT_FILE
106echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
107echo "<table>" >> $RESULT_FILE
108echo " <tr>" >> $RESULT_FILE
109echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
110echo " </tr><tr>" >> $RESULT_FILE
111echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
112echo " </tr><tr>" >> $RESULT_FILE
113echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
114echo " </tr>" >> $RESULT_FILE
115echo "</table>" >> $RESULT_FILE
116echo "<ul>" >> $RESULT_FILE
117
118## update, build, and test
119ORIG_CHECKSUM=`cksum $FULLPATHNAME`
120F=svn-update.out
121start=`current_time`
122svn update >& build/$F
123err=$?
124update_status "Updating" "$F" $start
Neal Norwitz88b78d82006-02-14 08:14:16 +0000125if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000126 ## FIXME: we should check if this file has changed.
127 ## If it has changed, we should re-run the script to pick up changes.
128 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
129 exec $FULLPATHNAME $@
130 fi
131
132 F=svn-stat.out
133 start=`current_time`
134 svn stat >& build/$F
135 ## ignore some of the diffs
136 NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
137 update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
138
139 F=configure.out
140 start=`current_time`
141 ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F
142 err=$?
143 update_status "Configuring" "$F" $start
144 if [ $err = 0 ]; then
145 F=make.out
146 start=`current_time`
147 make >& build/$F
148 err=$?
149 warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
150 update_status "Building ($warnings warnings)" "$F" $start
151 if [ $err = 0 ]; then
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000152 ## make install
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000153 F=make-install.out
154 start=`current_time`
155 make install >& build/$F
156 update_status "Installing" "$F" $start
157
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000158 ## make and run basic tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000159 F=make-test.out
160 start=`current_time`
161 make test >& build/$F
Neal Norwitz79415522006-02-15 06:07:32 +0000162 NUM_FAILURES=`grep -ic " failed:" build/$F`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000163 update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
Neal Norwitza39f0572006-01-03 00:33:50 +0000164 ## FIXME: should mail since -uall below should find same problems
Neal Norwitz02c408d2006-01-03 02:18:01 +0000165 mail_on_failure "basics" build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000166
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000167 ## run the tests looking for leaks
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000168 F=make-test-refleak.out
169 start=`current_time`
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000170 ## ensure that the reflog exists so the grep doesn't fail
171 touch $REFLOG
172 ./python ./Lib/test/regrtest.py -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F
Neal Norwitzf415d5f2006-02-19 18:48:19 +0000173 NUM_FAILURES=`egrep -vc "$LEAKY_TESTS" $REFLOG`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000174 update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start
175 mail_on_failure "refleak" $REFLOG
176
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000177 ## now try to run all the tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000178 F=make-testall.out
179 start=`current_time`
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000180 ## skip curses when running from cron since there's no terminal
181 ## skip sound since it's not setup on the PSF box (/dev/dsp)
182 ./python -E -tt ./Lib/test/regrtest.py -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
Neal Norwitz79415522006-02-15 06:07:32 +0000183 NUM_FAILURES=`grep -ic " failed:" build/$F`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000184 update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
Neal Norwitzd3a58672006-01-02 23:22:41 +0000185 mail_on_failure "all" build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000186 fi
187 fi
188fi
189
190
191## make doc
192cd Doc
193F="make-doc.out"
194start=`current_time`
195make >& ../build/$F
196err=$?
197update_status "Making doc" "$F" $start
198if [ $err != 0 ]; then
199 NUM_FAILURES=1
200 mail_on_failure "doc" ../build/$F
201fi
202
203echo "</ul>" >> $RESULT_FILE
204echo "</body>" >> $RESULT_FILE
205echo "</html>" >> $RESULT_FILE
206
207## copy results
Neal Norwitz88b78d82006-02-14 08:14:16 +0000208rsync $RSYNC_OPTS html/* $REMOTE_SYSTEM:$REMOTE_DIR
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000209cd ../build
210rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/
211