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/docs.python.org/dev/"
56 RESULT_FILE
="$DIR/build/index.html"
57 INSTALL_DIR
="/tmp/python-test/local"
58 RSYNC_OPTS
="-aC -e ssh"
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 -tt $INSTALL_DIR/lib/python2.7/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 # Skip these tests altogether when looking for leaks. These tests
75 # do not need to be stored above in LEAKY_TESTS too.
76 # test_compiler almost never finishes with the same number of refs
77 # since it depends on other modules, skip it.
78 # test_logging causes hangs, skip it.
79 # KBK 21Apr09: test_httpservers causes hangs, skip for now.
80 LEAKY_SKIPS
="-x test_compiler test_logging test_httpservers"
82 # Change this flag to "yes" for old releases to only update/build the docs.
93 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
96 place_summary_first
() {
98 sed -n '/^[0-9][0-9]* tests OK\./,$p' < $testf \
99 |
egrep -v '\[[0-9]+ refs\]' > $testf.tmp
100 echo "" >> $testf.tmp
101 cat $testf >> $testf.tmp
107 n
=`grep -ic " failed:" $testf`
108 if [ $n -eq 1 ] ; then
109 n
=`grep " failed:" $testf | sed -e 's/ .*//'`
115 if [ "$NUM_FAILURES" != "0" ]; then
117 # FAILURE_CC is optional.
118 if [ "$FAILURE_CC" != "" ]; then
119 dest
="$dest -c $FAILURE_CC"
121 if [ "x$3" != "x" ] ; then
122 (echo "More important issues:"
123 echo "----------------------"
126 echo "Less important issues:"
127 echo "----------------------"
131 fi | mutt
-s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest
137 make clobber
/dev
/null
2>&1
138 cp -p Modules
/Setup.dist Modules
/Setup
139 # But maybe there was no Makefile - we are only building docs. Clear build:
143 ## get the path we are building
144 repo_path
=$
(grep "url=" .svn
/entries |
sed -e s
/\\W
*url
=// -e s
/\"//g
)
146 ## create results file
147 TITLE
="Automated Python Build Results"
148 echo "<html>" >> $RESULT_FILE
149 echo " <head>" >> $RESULT_FILE
150 echo " <title>$TITLE</title>" >> $RESULT_FILE
151 echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
152 echo " </head>" >> $RESULT_FILE
153 echo "<body>" >> $RESULT_FILE
154 echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
155 echo "<table>" >> $RESULT_FILE
156 echo " <tr>" >> $RESULT_FILE
157 echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
158 echo " </tr><tr>" >> $RESULT_FILE
159 echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
160 echo " </tr><tr>" >> $RESULT_FILE
161 echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
162 echo " </tr><tr>" >> $RESULT_FILE
163 echo " <td>URL:</td><td>$repo_path</td>" >> $RESULT_FILE
164 echo " </tr>" >> $RESULT_FILE
165 echo "</table>" >> $RESULT_FILE
166 echo "<ul>" >> $RESULT_FILE
168 ## update, build, and test
169 ORIG_CHECKSUM
=`cksum $FULLPATHNAME`
172 svn update
>& build
/$F
174 update_status
"Updating" "$F" $start
175 if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
176 ## FIXME: we should check if this file has changed.
177 ## If it has changed, we should re-run the script to pick up changes.
178 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
179 exec $FULLPATHNAME $@
185 ## ignore some of the diffs
186 NUM_DIFFS
=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
187 update_status
"svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
191 .
/configure
--prefix=$INSTALL_DIR --with-pydebug >& build
/$F
193 update_status
"Configuring" "$F" $start
194 if [ $err = 0 ]; then
199 warnings
=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
200 update_status
"Building ($warnings warnings)" "$F" $start
201 if [ $err = 0 ]; then
205 make install >& build
/$F
206 update_status
"Installing" "$F" $start
208 if [ ! -x $PYTHON ]; then
209 ln -s ${PYTHON}2.
* $PYTHON
212 ## make and run basic tests
215 $PYTHON $REGRTEST_ARGS -u urlfetch
>& build
/$F
216 NUM_FAILURES
=`count_failures build/$F`
217 place_summary_first build
/$F
218 update_status
"Testing basics ($NUM_FAILURES failures)" "$F" $start
219 mail_on_failure
"basics" build
/$F
223 $PYTHON -O $REGRTEST_ARGS -u urlfetch
>& build
/$F
224 NUM_FAILURES
=`count_failures build/$F`
225 place_summary_first build
/$F
226 update_status
"Testing opt ($NUM_FAILURES failures)" "$F" $start
227 mail_on_failure
"opt" build
/$F
229 ## run the tests looking for leaks
230 F
=make-test-refleak.out
232 ## ensure that the reflog exists so the grep doesn't fail
234 $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network
$LEAKY_SKIPS >& build
/$F
235 LEAK_PAT
="($LEAKY_TESTS|sum=0)"
236 NUM_FAILURES
=`egrep -vc "$LEAK_PAT" $REFLOG`
237 place_summary_first build
/$F
238 update_status
"Testing refleaks ($NUM_FAILURES failures)" "$F" $start
239 mail_on_failure
"refleak" $REFLOG "$LEAK_PAT"
241 ## now try to run all the tests
244 ## skip curses when running from cron since there's no terminal
245 ## skip sound since it's not setup on the PSF box (/dev/dsp)
246 $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev
>& build
/$F
247 NUM_FAILURES
=`count_failures build/$F`
248 place_summary_first build
/$F
249 update_status
"Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
250 mail_on_failure
"all" build
/$F
260 # XXX(nnorwitz): For now, keep the code that checks for a conflicted file until
261 # after the first release of 2.6a1 or 3.0a1. At that point, it will be clear
262 # if there will be a similar problem with the new doc system.
264 # Doc/commontex/boilerplate.tex is expected to always have an outstanding
265 # modification for the date. When a release is cut, a conflict occurs.
266 # This allows us to detect this problem and not try to build the docs
267 # which will definitely fail with a conflict.
268 #CONFLICTED_FILE=commontex/boilerplate.tex
269 #conflict_count=`grep -c "<<<" $CONFLICTED_FILE`
271 if [ $conflict_count != 0 ]; then
272 echo "Conflict detected in $CONFLICTED_FILE. Doc build skipped." > ..
/build
/$F
275 make clean
> ..
/build
/$F 2>&1
276 make checkout update html
>> ..
/build
/$F 2>&1
279 update_status
"Making doc" "$F" $start
280 if [ $err != 0 ]; then
282 mail_on_failure
"doc" ..
/build
/$F
285 echo "</ul>" >> $RESULT_FILE
286 echo "</body>" >> $RESULT_FILE
287 echo "</html>" >> $RESULT_FILE
290 chgrp
-R webmaster build
/html
291 chmod -R g
+w build
/html
292 rsync
$RSYNC_OPTS build
/html
/* $REMOTE_SYSTEM:$REMOTE_DIR
294 rsync
$RSYNC_OPTS index.html
*.out
$REMOTE_SYSTEM:$REMOTE_DIR/results
/