source: trunk/essentials/dev-lang/python/Misc/build.sh

Last change on this file was 3225, checked in by bird, 18 years ago

Python 2.5

File size: 7.5 KB
Line 
1#!/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## basename, date, dirname, expr, grep, readlink, uname
31## cksum, make, mutt, rsync, svn
32
33## remember where did we started from
34DIR=`dirname $0`
35if [ "$DIR" = "" ]; then
36 DIR="."
37fi
38
39## make directory absolute
40DIR=`readlink -f $DIR`
41FULLPATHNAME="$DIR/`basename $0`"
42## we want Misc/..
43DIR=`dirname $DIR`
44
45## Configurable options
46
47FAILURE_SUBJECT="Python Regression Test Failures"
48#FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com"
49FAILURE_MAILTO="python-checkins@python.org"
50
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
57# Always run the installed version of Python.
58PYTHON=$INSTALL_DIR/bin/python
59
60# Python options and regression test program that should always be run.
61REGRTEST_ARGS="-E -tt $INSTALL_DIR/lib/python2.5/test/regrtest.py"
62
63REFLOG="build/reflog.txt.out"
64# These tests are not stable and falsely report leaks sometimes.
65# The entire leak report will be mailed if any test not in this list leaks.
66# Note: test_XXX (none currently) really leak, but are disabled
67# so we don't send spam. Any test which really leaks should only
68# be listed here if there are also test cases under Lib/test/leakers.
69LEAKY_TESTS="test_(XXX)" # Currently no tests should report spurious leaks.
70
71# Skip these tests altogether when looking for leaks. These tests
72# do not need to be stored above in LEAKY_TESTS too.
73# test_compiler almost never finishes with the same number of refs
74# since it depends on other modules, skip it.
75# test_logging causes hangs, skip it.
76LEAKY_SKIPS="-x test_compiler test_logging"
77
78# Change this flag to "yes" for old releases to only update/build the docs.
79BUILD_DISABLED="no"
80
81## utility functions
82current_time() {
83 date +%s
84}
85
86update_status() {
87 now=`current_time`
88 time=`expr $now - $3`
89 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
90}
91
92mail_on_failure() {
93 if [ "$NUM_FAILURES" != "0" ]; then
94 mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2
95 fi
96}
97
98## setup
99cd $DIR
100mkdir -p build
101rm -f $RESULT_FILE build/*.out
102rm -rf $INSTALL_DIR
103
104## create results file
105TITLE="Automated Python Build Results"
106echo "<html>" >> $RESULT_FILE
107echo " <head>" >> $RESULT_FILE
108echo " <title>$TITLE</title>" >> $RESULT_FILE
109echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
110echo " </head>" >> $RESULT_FILE
111echo "<body>" >> $RESULT_FILE
112echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
113echo "<table>" >> $RESULT_FILE
114echo " <tr>" >> $RESULT_FILE
115echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
116echo " </tr><tr>" >> $RESULT_FILE
117echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
118echo " </tr><tr>" >> $RESULT_FILE
119echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
120echo " </tr>" >> $RESULT_FILE
121echo "</table>" >> $RESULT_FILE
122echo "<ul>" >> $RESULT_FILE
123
124## update, build, and test
125ORIG_CHECKSUM=`cksum $FULLPATHNAME`
126F=svn-update.out
127start=`current_time`
128svn update >& build/$F
129err=$?
130update_status "Updating" "$F" $start
131if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
132 ## FIXME: we should check if this file has changed.
133 ## If it has changed, we should re-run the script to pick up changes.
134 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
135 exec $FULLPATHNAME $@
136 fi
137
138 F=svn-stat.out
139 start=`current_time`
140 svn stat >& build/$F
141 ## ignore some of the diffs
142 NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
143 update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
144
145 F=configure.out
146 start=`current_time`
147 ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F
148 err=$?
149 update_status "Configuring" "$F" $start
150 if [ $err = 0 ]; then
151 F=make.out
152 start=`current_time`
153 make >& build/$F
154 err=$?
155 warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
156 update_status "Building ($warnings warnings)" "$F" $start
157 if [ $err = 0 ]; then
158 ## make install
159 F=make-install.out
160 start=`current_time`
161 make install >& build/$F
162 update_status "Installing" "$F" $start
163
164 if [ ! -x $PYTHON ]; then
165 ln -s ${PYTHON}2.* $PYTHON
166 fi
167
168 ## make and run basic tests
169 F=make-test.out
170 start=`current_time`
171 $PYTHON $REGRTEST_ARGS >& build/$F
172 NUM_FAILURES=`grep -ic " failed:" build/$F`
173 update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
174 mail_on_failure "basics" build/$F
175
176 F=make-test-opt.out
177 start=`current_time`
178 $PYTHON -O $REGRTEST_ARGS >& build/$F
179 NUM_FAILURES=`grep -ic " failed:" build/$F`
180 update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start
181 mail_on_failure "opt" build/$F
182
183 ## run the tests looking for leaks
184 F=make-test-refleak.out
185 start=`current_time`
186 ## ensure that the reflog exists so the grep doesn't fail
187 touch $REFLOG
188 $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F
189 NUM_FAILURES=`egrep -vc "$LEAKY_TESTS" $REFLOG`
190 update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start
191 mail_on_failure "refleak" $REFLOG
192
193 ## now try to run all the tests
194 F=make-testall.out
195 start=`current_time`
196 ## skip curses when running from cron since there's no terminal
197 ## skip sound since it's not setup on the PSF box (/dev/dsp)
198 $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
199 NUM_FAILURES=`grep -ic " failed:" build/$F`
200 update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
201 mail_on_failure "all" build/$F
202 fi
203 fi
204fi
205
206
207## make doc
208cd $DIR/Doc
209F="make-doc.out"
210start=`current_time`
211make >& ../build/$F
212err=$?
213update_status "Making doc" "$F" $start
214if [ $err != 0 ]; then
215 NUM_FAILURES=1
216 mail_on_failure "doc" ../build/$F
217fi
218
219echo "</ul>" >> $RESULT_FILE
220echo "</body>" >> $RESULT_FILE
221echo "</html>" >> $RESULT_FILE
222
223## copy results
224rsync $RSYNC_OPTS html/* $REMOTE_SYSTEM:$REMOTE_DIR
225cd ../build
226rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/
227
Note: See TracBrowser for help on using the repository browser.