blob: de997f5bd880739937b1bf649c516673e1cd82d0 [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 Norwitz5d08bd72007-04-20 05:20:38 +000050#FAILURE_CC="optional--uncomment and set to desired address"
Neal Norwitz461aa5b2006-01-02 20:07:16 +000051
52REMOTE_SYSTEM="neal@dinsdale.python.org"
53REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/"
54RESULT_FILE="$DIR/build/index.html"
55INSTALL_DIR="/tmp/python-test/local"
56RSYNC_OPTS="-aC -e ssh"
57
Neal Norwitz524b59b2006-06-27 04:09:13 +000058# Always run the installed version of Python.
59PYTHON=$INSTALL_DIR/bin/python
60
61# Python options and regression test program that should always be run.
Neal Norwitzf2fcfa32006-08-18 06:14:52 +000062REGRTEST_ARGS="-E -tt $INSTALL_DIR/lib/python2.6/test/regrtest.py"
Neal Norwitz524b59b2006-06-27 04:09:13 +000063
Neal Norwitz461aa5b2006-01-02 20:07:16 +000064REFLOG="build/reflog.txt.out"
Neal Norwitzee6d23e2006-04-12 05:56:00 +000065# These tests are not stable and falsely report leaks sometimes.
Neal Norwitzf415d5f2006-02-19 18:48:19 +000066# The entire leak report will be mailed if any test not in this list leaks.
Neal Norwitza1f9b7f2006-04-06 07:58:59 +000067# Note: test_XXX (none currently) really leak, but are disabled
Neal Norwitz770a8002006-03-17 04:52:38 +000068# so we don't send spam. Any test which really leaks should only
69# be listed here if there are also test cases under Lib/test/leakers.
Neal Norwitzdf462262007-06-15 03:11:41 +000070LEAKY_TESTS="test_(cmd_line|popen2|socket|urllib2_localnet)"
Neal Norwitzee6d23e2006-04-12 05:56:00 +000071
72# Skip these tests altogether when looking for leaks. These tests
73# do not need to be stored above in LEAKY_TESTS too.
74# test_compiler almost never finishes with the same number of refs
75# since it depends on other modules, skip it.
76# test_logging causes hangs, skip it.
77LEAKY_SKIPS="-x test_compiler test_logging"
Neal Norwitzf415d5f2006-02-19 18:48:19 +000078
Neal Norwitz770a8002006-03-17 04:52:38 +000079# Change this flag to "yes" for old releases to only update/build the docs.
Neal Norwitz88b78d82006-02-14 08:14:16 +000080BUILD_DISABLED="no"
Neal Norwitz461aa5b2006-01-02 20:07:16 +000081
82## utility functions
83current_time() {
84 date +%s
85}
86
87update_status() {
88 now=`current_time`
89 time=`expr $now - $3`
90 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
91}
92
93mail_on_failure() {
94 if [ "$NUM_FAILURES" != "0" ]; then
Neal Norwitz5d08bd72007-04-20 05:20:38 +000095 dest=$FAILURE_MAILTO
96 # FAILURE_CC is optional.
97 if [ "$FAILURE_CC" != "" ]; then
98 dest="$dest -c $FAILURE_CC"
99 fi
100 mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest < $2
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000101 fi
102}
103
104## setup
105cd $DIR
106mkdir -p build
107rm -f $RESULT_FILE build/*.out
108rm -rf $INSTALL_DIR
109
110## create results file
111TITLE="Automated Python Build Results"
Neal Norwitzb8967592006-01-16 04:37:22 +0000112echo "<html>" >> $RESULT_FILE
113echo " <head>" >> $RESULT_FILE
114echo " <title>$TITLE</title>" >> $RESULT_FILE
115echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
116echo " </head>" >> $RESULT_FILE
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000117echo "<body>" >> $RESULT_FILE
118echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
119echo "<table>" >> $RESULT_FILE
120echo " <tr>" >> $RESULT_FILE
121echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
122echo " </tr><tr>" >> $RESULT_FILE
123echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
124echo " </tr><tr>" >> $RESULT_FILE
125echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
126echo " </tr>" >> $RESULT_FILE
127echo "</table>" >> $RESULT_FILE
128echo "<ul>" >> $RESULT_FILE
129
130## update, build, and test
131ORIG_CHECKSUM=`cksum $FULLPATHNAME`
132F=svn-update.out
133start=`current_time`
134svn update >& build/$F
135err=$?
136update_status "Updating" "$F" $start
Neal Norwitz88b78d82006-02-14 08:14:16 +0000137if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000138 ## FIXME: we should check if this file has changed.
139 ## If it has changed, we should re-run the script to pick up changes.
140 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
141 exec $FULLPATHNAME $@
142 fi
143
144 F=svn-stat.out
145 start=`current_time`
146 svn stat >& build/$F
147 ## ignore some of the diffs
148 NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
149 update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
150
151 F=configure.out
152 start=`current_time`
153 ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F
154 err=$?
155 update_status "Configuring" "$F" $start
156 if [ $err = 0 ]; then
157 F=make.out
158 start=`current_time`
159 make >& build/$F
160 err=$?
161 warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
162 update_status "Building ($warnings warnings)" "$F" $start
163 if [ $err = 0 ]; then
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000164 ## make install
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000165 F=make-install.out
166 start=`current_time`
167 make install >& build/$F
168 update_status "Installing" "$F" $start
169
Neal Norwitz9815f8b2006-07-26 04:00:18 +0000170 if [ ! -x $PYTHON ]; then
171 ln -s ${PYTHON}2.* $PYTHON
172 fi
173
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000174 ## make and run basic tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000175 F=make-test.out
176 start=`current_time`
Neal Norwitz524b59b2006-06-27 04:09:13 +0000177 $PYTHON $REGRTEST_ARGS >& build/$F
Neal Norwitz79415522006-02-15 06:07:32 +0000178 NUM_FAILURES=`grep -ic " failed:" build/$F`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000179 update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
Neal Norwitz02c408d2006-01-03 02:18:01 +0000180 mail_on_failure "basics" build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000181
Neal Norwitz524b59b2006-06-27 04:09:13 +0000182 F=make-test-opt.out
183 start=`current_time`
184 $PYTHON -O $REGRTEST_ARGS >& build/$F
185 NUM_FAILURES=`grep -ic " failed:" build/$F`
186 update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start
187 mail_on_failure "opt" build/$F
188
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000189 ## run the tests looking for leaks
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000190 F=make-test-refleak.out
191 start=`current_time`
Neal Norwitz0f77da32006-04-17 01:48:41 +0000192 ## ensure that the reflog exists so the grep doesn't fail
193 touch $REFLOG
Neal Norwitz524b59b2006-06-27 04:09:13 +0000194 $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F
Neal Norwitzd9841032007-05-11 05:55:15 +0000195 NUM_FAILURES=`egrep -vc "($LEAKY_TESTS|sum=0)" $REFLOG`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000196 update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start
197 mail_on_failure "refleak" $REFLOG
198
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000199 ## now try to run all the tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000200 F=make-testall.out
201 start=`current_time`
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000202 ## skip curses when running from cron since there's no terminal
203 ## skip sound since it's not setup on the PSF box (/dev/dsp)
Neal Norwitz524b59b2006-06-27 04:09:13 +0000204 $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
Neal Norwitz79415522006-02-15 06:07:32 +0000205 NUM_FAILURES=`grep -ic " failed:" build/$F`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000206 update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
Neal Norwitzd3a58672006-01-02 23:22:41 +0000207 mail_on_failure "all" build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000208 fi
209 fi
210fi
211
212
213## make doc
Neal Norwitz524b59b2006-06-27 04:09:13 +0000214cd $DIR/Doc
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000215F="make-doc.out"
216start=`current_time`
Neal Norwitz5c404ae2007-08-16 05:16:09 +0000217# XXX(nnorwitz): For now, keep the code that checks for a conflicted file until
218# after the first release of 2.6a1 or 3.0a1. At that point, it will be clear
219# if there will be a similar problem with the new doc system.
220
Neal Norwitz5d08bd72007-04-20 05:20:38 +0000221# Doc/commontex/boilerplate.tex is expected to always have an outstanding
222# modification for the date. When a release is cut, a conflict occurs.
223# This allows us to detect this problem and not try to build the docs
224# which will definitely fail with a conflict.
Neal Norwitz7def3e02007-08-16 05:07:03 +0000225#CONFLICTED_FILE=commontex/boilerplate.tex
226#conflict_count=`grep -c "<<<" $CONFLICTED_FILE`
227conflict_count=0
Neal Norwitz5d08bd72007-04-20 05:20:38 +0000228if [ $conflict_count != 0 ]; then
229 echo "Conflict detected in $CONFLICTED_FILE. Doc build skipped." > ../build/$F
230 err=1
231else
Neal Norwitz82955f62007-08-17 04:10:55 +0000232 make update html >& ../build/$F
Neal Norwitz5d08bd72007-04-20 05:20:38 +0000233 err=$?
234fi
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000235update_status "Making doc" "$F" $start
236if [ $err != 0 ]; then
237 NUM_FAILURES=1
238 mail_on_failure "doc" ../build/$F
239fi
240
241echo "</ul>" >> $RESULT_FILE
242echo "</body>" >> $RESULT_FILE
243echo "</html>" >> $RESULT_FILE
244
245## copy results
Neal Norwitz7def3e02007-08-16 05:07:03 +0000246rsync $RSYNC_OPTS build/html/* $REMOTE_SYSTEM:$REMOTE_DIR
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000247cd ../build
248rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/