blob: 3c669a0d5d396effdc9fcf7528d63f4632393559 [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"
Neal Norwitzf415d5f2006-02-19 18:48:19 +000058# These tests are not stable and sometimes report leaks; however,
59# test_generators really leaks. Since test_generators probably won't
60# be fixed real soon, disable warning about it for now.
61# The entire leak report will be mailed if any test not in this list leaks.
Neal Norwitz4dc4a842006-03-06 23:04:04 +000062LEAKY_TESTS="test_(capi|cfgparser|charmapcodec|cmd_line|compiler|filecmp|generators|quopri|socket|threaded_import|threadedtempfile|threading|threading_local|urllib2)"
Neal Norwitzf415d5f2006-02-19 18:48:19 +000063
Neal Norwitz88b78d82006-02-14 08:14:16 +000064# Change this flag to "yes" for old releases to just update/build the docs.
65BUILD_DISABLED="no"
Neal Norwitz461aa5b2006-01-02 20:07:16 +000066
67## utility functions
68current_time() {
69 date +%s
70}
71
72update_status() {
73 now=`current_time`
74 time=`expr $now - $3`
75 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
76}
77
78mail_on_failure() {
79 if [ "$NUM_FAILURES" != "0" ]; then
80 mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2
81 fi
82}
83
84## setup
85cd $DIR
86mkdir -p build
87rm -f $RESULT_FILE build/*.out
88rm -rf $INSTALL_DIR
89
90## create results file
91TITLE="Automated Python Build Results"
Neal Norwitzb8967592006-01-16 04:37:22 +000092echo "<html>" >> $RESULT_FILE
93echo " <head>" >> $RESULT_FILE
94echo " <title>$TITLE</title>" >> $RESULT_FILE
95echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
96echo " </head>" >> $RESULT_FILE
Neal Norwitz461aa5b2006-01-02 20:07:16 +000097echo "<body>" >> $RESULT_FILE
98echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
99echo "<table>" >> $RESULT_FILE
100echo " <tr>" >> $RESULT_FILE
101echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
102echo " </tr><tr>" >> $RESULT_FILE
103echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
104echo " </tr><tr>" >> $RESULT_FILE
105echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
106echo " </tr>" >> $RESULT_FILE
107echo "</table>" >> $RESULT_FILE
108echo "<ul>" >> $RESULT_FILE
109
110## update, build, and test
111ORIG_CHECKSUM=`cksum $FULLPATHNAME`
112F=svn-update.out
113start=`current_time`
114svn update >& build/$F
115err=$?
116update_status "Updating" "$F" $start
Neal Norwitz88b78d82006-02-14 08:14:16 +0000117if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000118 ## FIXME: we should check if this file has changed.
119 ## If it has changed, we should re-run the script to pick up changes.
120 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
121 exec $FULLPATHNAME $@
122 fi
123
124 F=svn-stat.out
125 start=`current_time`
126 svn stat >& build/$F
127 ## ignore some of the diffs
128 NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
129 update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
130
131 F=configure.out
132 start=`current_time`
133 ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F
134 err=$?
135 update_status "Configuring" "$F" $start
136 if [ $err = 0 ]; then
137 F=make.out
138 start=`current_time`
139 make >& build/$F
140 err=$?
141 warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
142 update_status "Building ($warnings warnings)" "$F" $start
143 if [ $err = 0 ]; then
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000144 ## make install
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000145 F=make-install.out
146 start=`current_time`
147 make install >& build/$F
148 update_status "Installing" "$F" $start
149
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000150 ## make and run basic tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000151 F=make-test.out
152 start=`current_time`
153 make test >& build/$F
Neal Norwitz79415522006-02-15 06:07:32 +0000154 NUM_FAILURES=`grep -ic " failed:" build/$F`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000155 update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
Neal Norwitza39f0572006-01-03 00:33:50 +0000156 ## FIXME: should mail since -uall below should find same problems
Neal Norwitz02c408d2006-01-03 02:18:01 +0000157 mail_on_failure "basics" build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000158
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000159 ## run the tests looking for leaks
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000160 F=make-test-refleak.out
161 start=`current_time`
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000162 ./python ./Lib/test/regrtest.py -R 4:3:$REFLOG -u network >& build/$F
Neal Norwitzf415d5f2006-02-19 18:48:19 +0000163 NUM_FAILURES=`egrep -vc "$LEAKY_TESTS" $REFLOG`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000164 update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start
165 mail_on_failure "refleak" $REFLOG
166
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000167 ## now try to run all the tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000168 F=make-testall.out
169 start=`current_time`
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000170 ## skip curses when running from cron since there's no terminal
171 ## skip sound since it's not setup on the PSF box (/dev/dsp)
172 ./python -E -tt ./Lib/test/regrtest.py -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
Neal Norwitz79415522006-02-15 06:07:32 +0000173 NUM_FAILURES=`grep -ic " failed:" build/$F`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000174 update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
Neal Norwitzd3a58672006-01-02 23:22:41 +0000175 mail_on_failure "all" build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000176 fi
177 fi
178fi
179
180
181## make doc
182cd Doc
183F="make-doc.out"
184start=`current_time`
185make >& ../build/$F
186err=$?
187update_status "Making doc" "$F" $start
188if [ $err != 0 ]; then
189 NUM_FAILURES=1
190 mail_on_failure "doc" ../build/$F
191fi
192
193echo "</ul>" >> $RESULT_FILE
194echo "</body>" >> $RESULT_FILE
195echo "</html>" >> $RESULT_FILE
196
197## copy results
Neal Norwitz88b78d82006-02-14 08:14:16 +0000198rsync $RSYNC_OPTS html/* $REMOTE_SYSTEM:$REMOTE_DIR
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000199cd ../build
200rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/
201