Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 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: |
Neal Norwitz | d3a5867 | 2006-01-02 23:22:41 +0000 | [diff] [blame] | 30 | ## basename, date, dirname, expr, grep, readlink, uname |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 31 | ## cksum, make, mutt, rsync, svn |
| 32 | |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 33 | ## remember where did we started from |
| 34 | DIR=`dirname $0` |
| 35 | if [ "$DIR" = "" ]; then |
| 36 | DIR="." |
| 37 | fi |
| 38 | |
| 39 | ## make directory absolute |
| 40 | DIR=`readlink -f $DIR` |
Neal Norwitz | d3a5867 | 2006-01-02 23:22:41 +0000 | [diff] [blame] | 41 | FULLPATHNAME="$DIR/`basename $0`" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 42 | ## we want Misc/.. |
| 43 | DIR=`dirname $DIR` |
| 44 | |
| 45 | ## Configurable options |
| 46 | |
| 47 | FAILURE_SUBJECT="Python Regression Test Failures" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 48 | #FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com" |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 49 | FAILURE_MAILTO="python-checkins@python.org" |
Neal Norwitz | 5d08bd7 | 2007-04-20 05:20:38 +0000 | [diff] [blame] | 50 | #FAILURE_CC="optional--uncomment and set to desired address" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 51 | |
| 52 | REMOTE_SYSTEM="neal@dinsdale.python.org" |
| 53 | REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/" |
| 54 | RESULT_FILE="$DIR/build/index.html" |
| 55 | INSTALL_DIR="/tmp/python-test/local" |
| 56 | RSYNC_OPTS="-aC -e ssh" |
| 57 | |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 58 | # Always run the installed version of Python. |
| 59 | PYTHON=$INSTALL_DIR/bin/python |
| 60 | |
| 61 | # Python options and regression test program that should always be run. |
Neal Norwitz | 044e327 | 2008-10-03 04:13:08 +0000 | [diff] [blame^] | 62 | REGRTEST_ARGS="-E -tt $INSTALL_DIR/lib/python2.7/test/regrtest.py" |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 63 | |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 64 | REFLOG="build/reflog.txt.out" |
Neal Norwitz | ee6d23e | 2006-04-12 05:56:00 +0000 | [diff] [blame] | 65 | # These tests are not stable and falsely report leaks sometimes. |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 66 | # The entire leak report will be mailed if any test not in this list leaks. |
Neal Norwitz | a1f9b7f | 2006-04-06 07:58:59 +0000 | [diff] [blame] | 67 | # Note: test_XXX (none currently) really leak, but are disabled |
Neal Norwitz | 770a800 | 2006-03-17 04:52:38 +0000 | [diff] [blame] | 68 | # 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 Norwitz | a403e41 | 2008-08-24 17:29:53 +0000 | [diff] [blame] | 70 | LEAKY_TESTS="test_(asynchat|cmd_line|docxmlrpc|dumbdbm|file|ftplib|httpservers|imaplib|popen2|socket|smtplib|sys|telnetlib|threadedtempfile|threading|threadsignals|urllib2_localnet|xmlrpc)" |
Neal Norwitz | ee6d23e | 2006-04-12 05:56:00 +0000 | [diff] [blame] | 71 | |
| 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. |
| 77 | LEAKY_SKIPS="-x test_compiler test_logging" |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 78 | |
Neal Norwitz | 770a800 | 2006-03-17 04:52:38 +0000 | [diff] [blame] | 79 | # Change this flag to "yes" for old releases to only update/build the docs. |
Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 80 | BUILD_DISABLED="no" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 81 | |
| 82 | ## utility functions |
| 83 | current_time() { |
| 84 | date +%s |
| 85 | } |
| 86 | |
| 87 | update_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 | |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 93 | place_summary_first() { |
| 94 | testf=$1 |
| 95 | sed -n '/^[0-9][0-9]* tests OK\./,$p' < $testf \ |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 96 | | egrep -v '\[[0-9]+ refs\]' > $testf.tmp |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 97 | echo "" >> $testf.tmp |
| 98 | cat $testf >> $testf.tmp |
| 99 | mv $testf.tmp $testf |
| 100 | } |
| 101 | |
| 102 | count_failures () { |
| 103 | testf=$1 |
| 104 | n=`grep -ic " failed:" $testf` |
| 105 | if [ $n -eq 1 ] ; then |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 106 | n=`grep " failed:" $testf | sed -e 's/ .*//'` |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 107 | fi |
| 108 | echo $n |
| 109 | } |
| 110 | |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 111 | mail_on_failure() { |
| 112 | if [ "$NUM_FAILURES" != "0" ]; then |
Neal Norwitz | 5d08bd7 | 2007-04-20 05:20:38 +0000 | [diff] [blame] | 113 | dest=$FAILURE_MAILTO |
| 114 | # FAILURE_CC is optional. |
| 115 | if [ "$FAILURE_CC" != "" ]; then |
| 116 | dest="$dest -c $FAILURE_CC" |
| 117 | fi |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 118 | if [ "x$3" != "x" ] ; then |
| 119 | (echo "More important issues:" |
| 120 | echo "----------------------" |
| 121 | egrep -v "$3" < $2 |
| 122 | echo "" |
| 123 | echo "Less important issues:" |
| 124 | echo "----------------------" |
| 125 | egrep "$3" < $2) |
Skip Montanaro | ee29c3f | 2008-02-02 19:11:57 +0000 | [diff] [blame] | 126 | else |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 127 | cat $2 |
| 128 | fi | mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 129 | fi |
| 130 | } |
| 131 | |
| 132 | ## setup |
| 133 | cd $DIR |
| 134 | mkdir -p build |
| 135 | rm -f $RESULT_FILE build/*.out |
| 136 | rm -rf $INSTALL_DIR |
| 137 | |
| 138 | ## create results file |
| 139 | TITLE="Automated Python Build Results" |
Neal Norwitz | b896759 | 2006-01-16 04:37:22 +0000 | [diff] [blame] | 140 | echo "<html>" >> $RESULT_FILE |
| 141 | echo " <head>" >> $RESULT_FILE |
| 142 | echo " <title>$TITLE</title>" >> $RESULT_FILE |
| 143 | echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE |
| 144 | echo " </head>" >> $RESULT_FILE |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 145 | echo "<body>" >> $RESULT_FILE |
| 146 | echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE |
| 147 | echo "<table>" >> $RESULT_FILE |
| 148 | echo " <tr>" >> $RESULT_FILE |
| 149 | echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE |
| 150 | echo " </tr><tr>" >> $RESULT_FILE |
| 151 | echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE |
| 152 | echo " </tr><tr>" >> $RESULT_FILE |
| 153 | echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE |
| 154 | echo " </tr>" >> $RESULT_FILE |
| 155 | echo "</table>" >> $RESULT_FILE |
| 156 | echo "<ul>" >> $RESULT_FILE |
| 157 | |
| 158 | ## update, build, and test |
| 159 | ORIG_CHECKSUM=`cksum $FULLPATHNAME` |
| 160 | F=svn-update.out |
| 161 | start=`current_time` |
| 162 | svn update >& build/$F |
| 163 | err=$? |
| 164 | update_status "Updating" "$F" $start |
Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 165 | if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 166 | ## FIXME: we should check if this file has changed. |
| 167 | ## If it has changed, we should re-run the script to pick up changes. |
| 168 | if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then |
| 169 | exec $FULLPATHNAME $@ |
| 170 | fi |
| 171 | |
| 172 | F=svn-stat.out |
| 173 | start=`current_time` |
| 174 | svn stat >& build/$F |
| 175 | ## ignore some of the diffs |
| 176 | NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F` |
| 177 | update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start |
| 178 | |
| 179 | F=configure.out |
| 180 | start=`current_time` |
| 181 | ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F |
| 182 | err=$? |
| 183 | update_status "Configuring" "$F" $start |
| 184 | if [ $err = 0 ]; then |
| 185 | F=make.out |
| 186 | start=`current_time` |
| 187 | make >& build/$F |
| 188 | err=$? |
| 189 | warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"` |
| 190 | update_status "Building ($warnings warnings)" "$F" $start |
| 191 | if [ $err = 0 ]; then |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 192 | ## make install |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 193 | F=make-install.out |
| 194 | start=`current_time` |
| 195 | make install >& build/$F |
| 196 | update_status "Installing" "$F" $start |
| 197 | |
Neal Norwitz | 9815f8b | 2006-07-26 04:00:18 +0000 | [diff] [blame] | 198 | if [ ! -x $PYTHON ]; then |
| 199 | ln -s ${PYTHON}2.* $PYTHON |
| 200 | fi |
| 201 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 202 | ## make and run basic tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 203 | F=make-test.out |
| 204 | start=`current_time` |
Neal Norwitz | 38bdfaa | 2008-03-05 05:50:20 +0000 | [diff] [blame] | 205 | $PYTHON $REGRTEST_ARGS -u urlfetch >& build/$F |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 206 | NUM_FAILURES=`count_failures build/$F` |
| 207 | place_summary_first build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 208 | update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start |
Neal Norwitz | 02c408d | 2006-01-03 02:18:01 +0000 | [diff] [blame] | 209 | mail_on_failure "basics" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 210 | |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 211 | F=make-test-opt.out |
| 212 | start=`current_time` |
Neal Norwitz | 38bdfaa | 2008-03-05 05:50:20 +0000 | [diff] [blame] | 213 | $PYTHON -O $REGRTEST_ARGS -u urlfetch >& build/$F |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 214 | NUM_FAILURES=`count_failures build/$F` |
| 215 | place_summary_first build/$F |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 216 | update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start |
| 217 | mail_on_failure "opt" build/$F |
| 218 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 219 | ## run the tests looking for leaks |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 220 | F=make-test-refleak.out |
| 221 | start=`current_time` |
Neal Norwitz | 0f77da3 | 2006-04-17 01:48:41 +0000 | [diff] [blame] | 222 | ## ensure that the reflog exists so the grep doesn't fail |
| 223 | touch $REFLOG |
Neal Norwitz | 38bdfaa | 2008-03-05 05:50:20 +0000 | [diff] [blame] | 224 | $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network,urlfetch $LEAKY_SKIPS >& build/$F |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 225 | LEAK_PAT="($LEAKY_TESTS|sum=0)" |
Skip Montanaro | ee29c3f | 2008-02-02 19:11:57 +0000 | [diff] [blame] | 226 | NUM_FAILURES=`egrep -vc "$LEAK_PAT" $REFLOG` |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 227 | place_summary_first build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 228 | update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start |
Skip Montanaro | ee29c3f | 2008-02-02 19:11:57 +0000 | [diff] [blame] | 229 | mail_on_failure "refleak" $REFLOG "$LEAK_PAT" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 230 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 231 | ## now try to run all the tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 232 | F=make-testall.out |
| 233 | start=`current_time` |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 234 | ## skip curses when running from cron since there's no terminal |
| 235 | ## skip sound since it's not setup on the PSF box (/dev/dsp) |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 236 | $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 237 | NUM_FAILURES=`count_failures build/$F` |
| 238 | place_summary_first build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 239 | update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start |
Neal Norwitz | d3a5867 | 2006-01-02 23:22:41 +0000 | [diff] [blame] | 240 | mail_on_failure "all" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 241 | fi |
| 242 | fi |
| 243 | fi |
| 244 | |
| 245 | |
| 246 | ## make doc |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 247 | cd $DIR/Doc |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 248 | F="make-doc.out" |
| 249 | start=`current_time` |
Neal Norwitz | 5c404ae | 2007-08-16 05:16:09 +0000 | [diff] [blame] | 250 | # XXX(nnorwitz): For now, keep the code that checks for a conflicted file until |
| 251 | # after the first release of 2.6a1 or 3.0a1. At that point, it will be clear |
| 252 | # if there will be a similar problem with the new doc system. |
| 253 | |
Neal Norwitz | 5d08bd7 | 2007-04-20 05:20:38 +0000 | [diff] [blame] | 254 | # Doc/commontex/boilerplate.tex is expected to always have an outstanding |
| 255 | # modification for the date. When a release is cut, a conflict occurs. |
| 256 | # This allows us to detect this problem and not try to build the docs |
| 257 | # which will definitely fail with a conflict. |
Neal Norwitz | 7def3e0 | 2007-08-16 05:07:03 +0000 | [diff] [blame] | 258 | #CONFLICTED_FILE=commontex/boilerplate.tex |
| 259 | #conflict_count=`grep -c "<<<" $CONFLICTED_FILE` |
| 260 | conflict_count=0 |
Neal Norwitz | 5d08bd7 | 2007-04-20 05:20:38 +0000 | [diff] [blame] | 261 | if [ $conflict_count != 0 ]; then |
| 262 | echo "Conflict detected in $CONFLICTED_FILE. Doc build skipped." > ../build/$F |
| 263 | err=1 |
| 264 | else |
Neal Norwitz | 82955f6 | 2007-08-17 04:10:55 +0000 | [diff] [blame] | 265 | make update html >& ../build/$F |
Neal Norwitz | 5d08bd7 | 2007-04-20 05:20:38 +0000 | [diff] [blame] | 266 | err=$? |
| 267 | fi |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 268 | update_status "Making doc" "$F" $start |
| 269 | if [ $err != 0 ]; then |
| 270 | NUM_FAILURES=1 |
| 271 | mail_on_failure "doc" ../build/$F |
| 272 | fi |
| 273 | |
| 274 | echo "</ul>" >> $RESULT_FILE |
| 275 | echo "</body>" >> $RESULT_FILE |
| 276 | echo "</html>" >> $RESULT_FILE |
| 277 | |
| 278 | ## copy results |
Neal Norwitz | 7def3e0 | 2007-08-16 05:07:03 +0000 | [diff] [blame] | 279 | rsync $RSYNC_OPTS build/html/* $REMOTE_SYSTEM:$REMOTE_DIR |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 280 | cd ../build |
| 281 | rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/ |