blob: 6e09186123ba7d3d04c87fda3f998d4839c48ecd [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:
30## date, dirname, expr, grep, readlink, uname
31## cksum, make, mutt, rsync, svn
32
33## need to get svn from ~/local/bin
34PATH=$PATH:$HOME/local/bin
35
36## remember where did we started from
37DIR=`dirname $0`
38if [ "$DIR" = "" ]; then
39 DIR="."
40fi
41
42## make directory absolute
43DIR=`readlink -f $DIR`
44FULLPATHNAME="$DIR/$0"
45## we want Misc/..
46DIR=`dirname $DIR`
47
48## Configurable options
49
50FAILURE_SUBJECT="Python Regression Test Failures"
51#FAILURE_MAILTO="python-checkins@python.org"
52#FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com"
53FAILURE_MAILTO="nnorwitz@gmail.com"
54
55REMOTE_SYSTEM="neal@dinsdale.python.org"
56REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/"
57RESULT_FILE="$DIR/build/index.html"
58INSTALL_DIR="/tmp/python-test/local"
59RSYNC_OPTS="-aC -e ssh"
60
61REFLOG="build/reflog.txt.out"
62
63## utility functions
64current_time() {
65 date +%s
66}
67
68update_status() {
69 now=`current_time`
70 time=`expr $now - $3`
71 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
72}
73
74mail_on_failure() {
75 if [ "$NUM_FAILURES" != "0" ]; then
76 mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2
77 fi
78}
79
80## setup
81cd $DIR
82mkdir -p build
83rm -f $RESULT_FILE build/*.out
84rm -rf $INSTALL_DIR
85
86## create results file
87TITLE="Automated Python Build Results"
88echo "<html><head><title>$TITLE</title></head>" >> $RESULT_FILE
89echo "<body>" >> $RESULT_FILE
90echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
91echo "<table>" >> $RESULT_FILE
92echo " <tr>" >> $RESULT_FILE
93echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
94echo " </tr><tr>" >> $RESULT_FILE
95echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
96echo " </tr><tr>" >> $RESULT_FILE
97echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
98echo " </tr>" >> $RESULT_FILE
99echo "</table>" >> $RESULT_FILE
100echo "<ul>" >> $RESULT_FILE
101
102## update, build, and test
103ORIG_CHECKSUM=`cksum $FULLPATHNAME`
104F=svn-update.out
105start=`current_time`
106svn update >& build/$F
107err=$?
108update_status "Updating" "$F" $start
109if [ $err = 0 ]; then
110 ## FIXME: we should check if this file has changed.
111 ## If it has changed, we should re-run the script to pick up changes.
112 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
113 exec $FULLPATHNAME $@
114 fi
115
116 F=svn-stat.out
117 start=`current_time`
118 svn stat >& build/$F
119 ## ignore some of the diffs
120 NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
121 update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
122
123 F=configure.out
124 start=`current_time`
125 ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F
126 err=$?
127 update_status "Configuring" "$F" $start
128 if [ $err = 0 ]; then
129 F=make.out
130 start=`current_time`
131 make >& build/$F
132 err=$?
133 warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
134 update_status "Building ($warnings warnings)" "$F" $start
135 if [ $err = 0 ]; then
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000136 ## make install
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000137 F=make-install.out
138 start=`current_time`
139 make install >& build/$F
140 update_status "Installing" "$F" $start
141
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000142 ## make and run basic tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000143 F=make-test.out
144 start=`current_time`
145 make test >& build/$F
146 NUM_FAILURES=`grep -ic fail build/$F`
147 update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
148 mail_on_failure "basics" buiild/$F
149
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000150 ## run the tests looking for leaks
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000151 F=make-test-refleak.out
152 start=`current_time`
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000153 ./python ./Lib/test/regrtest.py -R 4:3:$REFLOG -u network >& build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000154 NUM_FAILURES=`grep -ic leak $REFLOG`
155 update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start
156 mail_on_failure "refleak" $REFLOG
157
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000158 ## now try to run all the tests
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000159 F=make-testall.out
160 start=`current_time`
Neal Norwitzd19a4d42006-01-02 22:10:10 +0000161 ## skip curses when running from cron since there's no terminal
162 ## skip sound since it's not setup on the PSF box (/dev/dsp)
163 ./python -E -tt ./Lib/test/regrtest.py -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
Neal Norwitz461aa5b2006-01-02 20:07:16 +0000164 NUM_FAILURES=`grep -ic fail build/$F`
165 update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
166 mail_on_failure "all" buiild/$F
167 fi
168 fi
169fi
170
171
172## make doc
173cd Doc
174F="make-doc.out"
175start=`current_time`
176make >& ../build/$F
177err=$?
178update_status "Making doc" "$F" $start
179if [ $err != 0 ]; then
180 NUM_FAILURES=1
181 mail_on_failure "doc" ../build/$F
182fi
183
184echo "</ul>" >> $RESULT_FILE
185echo "</body>" >> $RESULT_FILE
186echo "</html>" >> $RESULT_FILE
187
188## copy results
189rsync $RSYNC_OPTS html/ $REMOTE_SYSTEM:$REMOTE_DIR
190cd ../build
191rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/
192