blob: 4c17251237605e58db3583219e90214862a1ffae [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"
48#FAILURE_MAILTO="python-checkins@python.org"
49#FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com"
50FAILURE_MAILTO="nnorwitz@gmail.com"
51
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
58REFLOG="build/reflog.txt.out"
Neal Norwitz88b78d82006-02-14 08:14:16 +000059# Change this flag to "yes" for old releases to just update/build the docs.
60BUILD_DISABLED="no"
Neal Norwitz461aa5b2006-01-02 20:07:16 +000061
62## utility functions
63current_time() {
64 date +%s
65}
66
67update_status() {
68 now=`current_time`
69 time=`expr $now - $3`
70 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
71}
72
73mail_on_failure() {
74 if [ "$NUM_FAILURES" != "0" ]; then
75 mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2
76 fi
77}
78
79## setup
80cd $DIR
81mkdir -p build
82rm -f $RESULT_FILE build/*.out
83rm -rf $INSTALL_DIR
84
85## create results file
86TITLE="Automated Python Build Results"
Neal Norwitzb8967592006-01-16 04:37:22 +000087echo "<html>" >> $RESULT_FILE
88echo " <head>" >> $RESULT_FILE
89echo " <title>$TITLE</title>" >> $RESULT_FILE
90echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
91echo " </head>" >> $RESULT_FILE
Neal Norwitz461aa5b2006-01-02 20:07:16 +000092echo "<body>" >> $RESULT_FILE
93echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
94echo "<table>" >> $RESULT_FILE
95echo " <tr>" >> $RESULT_FILE
96echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
97echo " </tr><tr>" >> $RESULT_FILE
98echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
99echo " </tr><tr>" >> $RESULT_FILE
100echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
101echo " </tr>" >> $RESULT_FILE
102echo "</table>" >> $RESULT_FILE
103echo "<ul>" >> $RESULT_FILE
104
105## update, build, and test
106ORIG_CHECKSUM=`cksum $FULLPATHNAME`
107F=svn-update.out
108start=`current_time`
109svn update >& build/$F
110err=$?
111update_status "Updating" "$F" $start
Neal Norwitz88b78d82006-02-14 08:14:16 +0000112if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000113 ## FIXME: we should check if this file has changed.
114 ## If it has changed, we should re-run the script to pick up changes.
115 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
116 exec $FULLPATHNAME $@
117 fi
118
119 F=svn-stat.out
120 start=`current_time`
121 svn stat >& build/$F
122 ## ignore some of the diffs
123 NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
124 update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
125
126 F=configure.out
127 start=`current_time`
128 ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F
129 err=$?
130 update_status "Configuring" "$F" $start
131 if [ $err = 0 ]; then
132 F=make.out
133 start=`current_time`
134 make >& build/$F
135 err=$?
136 warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
137 update_status "Building ($warnings warnings)" "$F" $start
138 if [ $err = 0 ]; then
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000139 ## make install
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000140 F=make-install.out
141 start=`current_time`
142 make install >& build/$F
143 update_status "Installing" "$F" $start
144
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000145 ## make and run basic tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000146 F=make-test.out
147 start=`current_time`
148 make test >& build/$F
Neal Norwitzbd3490a2006-02-09 05:08:56 +0000149 NUM_FAILURES=`grep -ic " test failed:" build/$F`
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000150 update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
Neal Norwitza39f0572006-01-03 00:33:50 +0000151 ## FIXME: should mail since -uall below should find same problems
Neal Norwitz02c408d2006-01-03 02:18:01 +0000152 mail_on_failure "basics" build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000153
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000154 ## run the tests looking for leaks
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000155 F=make-test-refleak.out
156 start=`current_time`
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000157 ./python ./Lib/test/regrtest.py -R 4:3:$REFLOG -u network >& build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000158 NUM_FAILURES=`grep -ic leak $REFLOG`
159 update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start
160 mail_on_failure "refleak" $REFLOG
161
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000162 ## now try to run all the tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000163 F=make-testall.out
164 start=`current_time`
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000165 ## skip curses when running from cron since there's no terminal
166 ## skip sound since it's not setup on the PSF box (/dev/dsp)
167 ./python -E -tt ./Lib/test/regrtest.py -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000168 NUM_FAILURES=`grep -ic fail build/$F`
169 update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
Neal Norwitzd3a58672006-01-02 23:22:41 +0000170 mail_on_failure "all" build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000171 fi
172 fi
173fi
174
175
176## make doc
177cd Doc
178F="make-doc.out"
179start=`current_time`
180make >& ../build/$F
181err=$?
182update_status "Making doc" "$F" $start
183if [ $err != 0 ]; then
184 NUM_FAILURES=1
185 mail_on_failure "doc" ../build/$F
186fi
187
188echo "</ul>" >> $RESULT_FILE
189echo "</body>" >> $RESULT_FILE
190echo "</html>" >> $RESULT_FILE
191
192## copy results
Neal Norwitz88b78d82006-02-14 08:14:16 +0000193rsync $RSYNC_OPTS html/* $REMOTE_SYSTEM:$REMOTE_DIR
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000194cd ../build
195rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/
196