R. David Murray | f4d63ab | 2010-01-07 04:04:28 +0000 | [diff] [blame] | 1 | #!/bin/sh |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 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 | ## |
Kurt B. Kaiser | 794b2a7 | 2009-07-27 16:09:28 +0000 | [diff] [blame] | 7 | ## Logs are kept and rsync'ed to the webhost. If there are test failure(s), |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 8 | ## information about the failure(s) is mailed. |
| 9 | ## |
Kurt B. Kaiser | 794b2a7 | 2009-07-27 16:09:28 +0000 | [diff] [blame] | 10 | ## The user must be a member of the webmaster group locally and on webhost. |
| 11 | ## |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 12 | ## This script is run on the PSF's machine as user neal via crontab. |
| 13 | ## |
| 14 | ## Yes, this script would probably be easier in python, but then |
| 15 | ## there's a bootstrap problem. What if Python doesn't build? |
| 16 | ## |
| 17 | ## This script should be fairly clean Bourne shell, ie not too many |
| 18 | ## bash-isms. We should try to keep it portable to other Unixes. |
| 19 | ## Even though it will probably only run on Linux. I'm sure there are |
| 20 | ## several GNU-isms currently (date +%s and readlink). |
| 21 | ## |
| 22 | ## Perhaps this script should be broken up into 2 (or more) components. |
| 23 | ## Building doc is orthogonal to the rest of the python build/test. |
| 24 | ## |
| 25 | |
| 26 | ## FIXME: we should detect test hangs (eg, if they take more than 45 minutes) |
| 27 | |
| 28 | ## FIXME: we should run valgrind |
| 29 | ## FIXME: we should run code coverage |
| 30 | |
| 31 | ## Utilities invoked in this script include: |
Neal Norwitz | d3a5867 | 2006-01-02 23:22:41 +0000 | [diff] [blame] | 32 | ## basename, date, dirname, expr, grep, readlink, uname |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 33 | ## cksum, make, mutt, rsync, svn |
| 34 | |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 35 | ## remember where did we started from |
| 36 | DIR=`dirname $0` |
| 37 | if [ "$DIR" = "" ]; then |
| 38 | DIR="." |
| 39 | fi |
| 40 | |
| 41 | ## make directory absolute |
| 42 | DIR=`readlink -f $DIR` |
Neal Norwitz | d3a5867 | 2006-01-02 23:22:41 +0000 | [diff] [blame] | 43 | FULLPATHNAME="$DIR/`basename $0`" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 44 | ## we want Misc/.. |
| 45 | DIR=`dirname $DIR` |
| 46 | |
| 47 | ## Configurable options |
| 48 | |
| 49 | FAILURE_SUBJECT="Python Regression Test Failures" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 50 | #FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com" |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 51 | FAILURE_MAILTO="python-checkins@python.org" |
Neal Norwitz | 5d08bd7 | 2007-04-20 05:20:38 +0000 | [diff] [blame] | 52 | #FAILURE_CC="optional--uncomment and set to desired address" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 53 | |
| 54 | REMOTE_SYSTEM="neal@dinsdale.python.org" |
| 55 | REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/" |
| 56 | RESULT_FILE="$DIR/build/index.html" |
| 57 | INSTALL_DIR="/tmp/python-test/local" |
Kurt B. Kaiser | ae628c9 | 2010-01-03 08:36:45 +0000 | [diff] [blame] | 58 | RSYNC_OPTS="-C -e ssh -rlogD" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 59 | |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 60 | # Always run the installed version of Python. |
| 61 | PYTHON=$INSTALL_DIR/bin/python |
| 62 | |
| 63 | # Python options and regression test program that should always be run. |
Neal Norwitz | 044e327 | 2008-10-03 04:13:08 +0000 | [diff] [blame] | 64 | REGRTEST_ARGS="-E -tt $INSTALL_DIR/lib/python2.7/test/regrtest.py" |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 65 | |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 66 | REFLOG="build/reflog.txt.out" |
Neal Norwitz | ee6d23e | 2006-04-12 05:56:00 +0000 | [diff] [blame] | 67 | # These tests are not stable and falsely report leaks sometimes. |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 68 | # 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] | 69 | # Note: test_XXX (none currently) really leak, but are disabled |
Neal Norwitz | 770a800 | 2006-03-17 04:52:38 +0000 | [diff] [blame] | 70 | # so we don't send spam. Any test which really leaks should only |
| 71 | # be listed here if there are also test cases under Lib/test/leakers. |
Collin Winter | f03c42f | 2009-05-18 21:35:40 +0000 | [diff] [blame] | 72 | LEAKY_TESTS="test_(asynchat|cmd_line|docxmlrpc|dumbdbm|file|ftplib|httpservers|imaplib|popen2|socket|smtplib|sys|telnetlib|threadedtempfile|threading|threadsignals|xmlrpc)" |
Neal Norwitz | ee6d23e | 2006-04-12 05:56:00 +0000 | [diff] [blame] | 73 | |
| 74 | # Skip these tests altogether when looking for leaks. These tests |
| 75 | # do not need to be stored above in LEAKY_TESTS too. |
| 76 | # test_compiler almost never finishes with the same number of refs |
| 77 | # since it depends on other modules, skip it. |
| 78 | # test_logging causes hangs, skip it. |
Kurt B. Kaiser | 794b2a7 | 2009-07-27 16:09:28 +0000 | [diff] [blame] | 79 | # KBK 21Apr09: test_httpservers causes hangs, skip for now. |
| 80 | LEAKY_SKIPS="-x test_compiler test_logging test_httpservers" |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 81 | |
Neal Norwitz | 770a800 | 2006-03-17 04:52:38 +0000 | [diff] [blame] | 82 | # 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] | 83 | BUILD_DISABLED="no" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 84 | |
| 85 | ## utility functions |
| 86 | current_time() { |
| 87 | date +%s |
| 88 | } |
| 89 | |
| 90 | update_status() { |
| 91 | now=`current_time` |
| 92 | time=`expr $now - $3` |
| 93 | echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE |
| 94 | } |
| 95 | |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 96 | place_summary_first() { |
| 97 | testf=$1 |
| 98 | sed -n '/^[0-9][0-9]* tests OK\./,$p' < $testf \ |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 99 | | egrep -v '\[[0-9]+ refs\]' > $testf.tmp |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 100 | echo "" >> $testf.tmp |
| 101 | cat $testf >> $testf.tmp |
| 102 | mv $testf.tmp $testf |
| 103 | } |
| 104 | |
| 105 | count_failures () { |
| 106 | testf=$1 |
| 107 | n=`grep -ic " failed:" $testf` |
| 108 | if [ $n -eq 1 ] ; then |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 109 | n=`grep " failed:" $testf | sed -e 's/ .*//'` |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 110 | fi |
| 111 | echo $n |
| 112 | } |
| 113 | |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 114 | mail_on_failure() { |
| 115 | if [ "$NUM_FAILURES" != "0" ]; then |
Neal Norwitz | 5d08bd7 | 2007-04-20 05:20:38 +0000 | [diff] [blame] | 116 | dest=$FAILURE_MAILTO |
| 117 | # FAILURE_CC is optional. |
| 118 | if [ "$FAILURE_CC" != "" ]; then |
| 119 | dest="$dest -c $FAILURE_CC" |
| 120 | fi |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 121 | if [ "x$3" != "x" ] ; then |
| 122 | (echo "More important issues:" |
| 123 | echo "----------------------" |
| 124 | egrep -v "$3" < $2 |
| 125 | echo "" |
| 126 | echo "Less important issues:" |
| 127 | echo "----------------------" |
| 128 | egrep "$3" < $2) |
Skip Montanaro | ee29c3f | 2008-02-02 19:11:57 +0000 | [diff] [blame] | 129 | else |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 130 | cat $2 |
| 131 | fi | mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 132 | fi |
| 133 | } |
| 134 | |
| 135 | ## setup |
| 136 | cd $DIR |
Kurt B. Kaiser | ae628c9 | 2010-01-03 08:36:45 +0000 | [diff] [blame] | 137 | make clobber > /dev/null 2>&1 |
Kurt B. Kaiser | 794b2a7 | 2009-07-27 16:09:28 +0000 | [diff] [blame] | 138 | cp -p Modules/Setup.dist Modules/Setup |
| 139 | # But maybe there was no Makefile - we are only building docs. Clear build: |
| 140 | rm -rf build/ |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 141 | mkdir -p build |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 142 | rm -rf $INSTALL_DIR |
Kurt B. Kaiser | 794b2a7 | 2009-07-27 16:09:28 +0000 | [diff] [blame] | 143 | ## get the path we are building |
| 144 | repo_path=$(grep "url=" .svn/entries | sed -e s/\\W*url=// -e s/\"//g) |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 145 | |
| 146 | ## create results file |
| 147 | TITLE="Automated Python Build Results" |
Neal Norwitz | b896759 | 2006-01-16 04:37:22 +0000 | [diff] [blame] | 148 | echo "<html>" >> $RESULT_FILE |
| 149 | echo " <head>" >> $RESULT_FILE |
| 150 | echo " <title>$TITLE</title>" >> $RESULT_FILE |
| 151 | echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE |
| 152 | echo " </head>" >> $RESULT_FILE |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 153 | echo "<body>" >> $RESULT_FILE |
| 154 | echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE |
| 155 | echo "<table>" >> $RESULT_FILE |
| 156 | echo " <tr>" >> $RESULT_FILE |
| 157 | echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE |
| 158 | echo " </tr><tr>" >> $RESULT_FILE |
| 159 | echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE |
| 160 | echo " </tr><tr>" >> $RESULT_FILE |
| 161 | echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE |
Kurt B. Kaiser | 794b2a7 | 2009-07-27 16:09:28 +0000 | [diff] [blame] | 162 | echo " </tr><tr>" >> $RESULT_FILE |
| 163 | echo " <td>URL:</td><td>$repo_path</td>" >> $RESULT_FILE |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 164 | echo " </tr>" >> $RESULT_FILE |
| 165 | echo "</table>" >> $RESULT_FILE |
| 166 | echo "<ul>" >> $RESULT_FILE |
| 167 | |
| 168 | ## update, build, and test |
| 169 | ORIG_CHECKSUM=`cksum $FULLPATHNAME` |
| 170 | F=svn-update.out |
| 171 | start=`current_time` |
| 172 | svn update >& build/$F |
| 173 | err=$? |
| 174 | update_status "Updating" "$F" $start |
Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 175 | if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 176 | ## FIXME: we should check if this file has changed. |
| 177 | ## If it has changed, we should re-run the script to pick up changes. |
| 178 | if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then |
| 179 | exec $FULLPATHNAME $@ |
| 180 | fi |
| 181 | |
| 182 | F=svn-stat.out |
| 183 | start=`current_time` |
| 184 | svn stat >& build/$F |
| 185 | ## ignore some of the diffs |
| 186 | NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F` |
| 187 | update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start |
| 188 | |
| 189 | F=configure.out |
| 190 | start=`current_time` |
| 191 | ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F |
| 192 | err=$? |
| 193 | update_status "Configuring" "$F" $start |
| 194 | if [ $err = 0 ]; then |
| 195 | F=make.out |
| 196 | start=`current_time` |
| 197 | make >& build/$F |
| 198 | err=$? |
| 199 | warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"` |
| 200 | update_status "Building ($warnings warnings)" "$F" $start |
| 201 | if [ $err = 0 ]; then |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 202 | ## make install |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 203 | F=make-install.out |
| 204 | start=`current_time` |
| 205 | make install >& build/$F |
| 206 | update_status "Installing" "$F" $start |
| 207 | |
Neal Norwitz | 9815f8b | 2006-07-26 04:00:18 +0000 | [diff] [blame] | 208 | if [ ! -x $PYTHON ]; then |
| 209 | ln -s ${PYTHON}2.* $PYTHON |
| 210 | fi |
| 211 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 212 | ## make and run basic tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 213 | F=make-test.out |
| 214 | start=`current_time` |
R. David Murray | ff2d7a7 | 2010-01-07 03:09:08 +0000 | [diff] [blame] | 215 | $PYTHON $REGRTEST_ARGS -W -u urlfetch >& build/$F |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 216 | NUM_FAILURES=`count_failures build/$F` |
| 217 | place_summary_first build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 218 | update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start |
Neal Norwitz | 02c408d | 2006-01-03 02:18:01 +0000 | [diff] [blame] | 219 | mail_on_failure "basics" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 220 | |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 221 | F=make-test-opt.out |
| 222 | start=`current_time` |
R. David Murray | ff2d7a7 | 2010-01-07 03:09:08 +0000 | [diff] [blame] | 223 | $PYTHON -O $REGRTEST_ARGS -W -u urlfetch >& build/$F |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 224 | NUM_FAILURES=`count_failures build/$F` |
| 225 | place_summary_first build/$F |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 226 | update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start |
| 227 | mail_on_failure "opt" build/$F |
| 228 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 229 | ## run the tests looking for leaks |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 230 | F=make-test-refleak.out |
| 231 | start=`current_time` |
Neal Norwitz | 0f77da3 | 2006-04-17 01:48:41 +0000 | [diff] [blame] | 232 | ## ensure that the reflog exists so the grep doesn't fail |
| 233 | touch $REFLOG |
Kurt B. Kaiser | 794b2a7 | 2009-07-27 16:09:28 +0000 | [diff] [blame] | 234 | $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F |
Neal Norwitz | 64984a8 | 2008-03-05 05:49:03 +0000 | [diff] [blame] | 235 | LEAK_PAT="($LEAKY_TESTS|sum=0)" |
Skip Montanaro | ee29c3f | 2008-02-02 19:11:57 +0000 | [diff] [blame] | 236 | NUM_FAILURES=`egrep -vc "$LEAK_PAT" $REFLOG` |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 237 | place_summary_first build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 238 | update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start |
Skip Montanaro | ee29c3f | 2008-02-02 19:11:57 +0000 | [diff] [blame] | 239 | mail_on_failure "refleak" $REFLOG "$LEAK_PAT" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 240 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 241 | ## now try to run all the tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 242 | F=make-testall.out |
| 243 | start=`current_time` |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 244 | ## skip curses when running from cron since there's no terminal |
| 245 | ## skip sound since it's not setup on the PSF box (/dev/dsp) |
R. David Murray | ff2d7a7 | 2010-01-07 03:09:08 +0000 | [diff] [blame] | 246 | $PYTHON $REGRTEST_ARGS -W -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F |
Skip Montanaro | 0473517 | 2008-02-15 19:03:59 +0000 | [diff] [blame] | 247 | NUM_FAILURES=`count_failures build/$F` |
| 248 | place_summary_first build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 249 | 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] | 250 | mail_on_failure "all" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 251 | fi |
| 252 | fi |
| 253 | fi |
| 254 | |
| 255 | |
| 256 | ## make doc |
Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 257 | cd $DIR/Doc |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 258 | F="make-doc.out" |
| 259 | start=`current_time` |
Georg Brandl | 7c910eb | 2010-01-03 13:05:39 +0000 | [diff] [blame] | 260 | make clean > ../build/$F 2>&1 |
| 261 | make checkout html >> ../build/$F 2>&1 |
| 262 | err=$? |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 263 | update_status "Making doc" "$F" $start |
| 264 | if [ $err != 0 ]; then |
| 265 | NUM_FAILURES=1 |
| 266 | mail_on_failure "doc" ../build/$F |
| 267 | fi |
| 268 | |
| 269 | echo "</ul>" >> $RESULT_FILE |
| 270 | echo "</body>" >> $RESULT_FILE |
| 271 | echo "</html>" >> $RESULT_FILE |
| 272 | |
| 273 | ## copy results |
Georg Brandl | f1539bd | 2010-03-12 21:27:23 +0000 | [diff] [blame] | 274 | ## (not used anymore, the daily build is now done directly on the server) |
| 275 | #chgrp -R webmaster build/html |
| 276 | #chmod -R g+w build/html |
| 277 | #rsync $RSYNC_OPTS build/html/* $REMOTE_SYSTEM:$REMOTE_DIR |
| 278 | #cd ../build |
| 279 | #rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/ |