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" |
Guido van Rossum | 5205653 | 2007-05-10 14:04:07 +0000 | [diff] [blame] | 49 | FAILURE_MAILTO="python-3000-checkins@python.org" |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +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" |
Guido van Rossum | 5205653 | 2007-05-10 14:04:07 +0000 | [diff] [blame] | 53 | REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/3.0" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 54 | RESULT_FILE="$DIR/build/index.html" |
Guido van Rossum | 5205653 | 2007-05-10 14:04:07 +0000 | [diff] [blame] | 55 | INSTALL_DIR="/tmp/python-test-3.0/local" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 56 | RSYNC_OPTS="-aC -e ssh" |
| 57 | |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +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. |
Guido van Rossum | 5205653 | 2007-05-10 14:04:07 +0000 | [diff] [blame] | 62 | REGRTEST_ARGS="-E -tt $INSTALL_DIR/lib/python3.0/test/regrtest.py" |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 63 | |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 64 | REFLOG="build/reflog.txt.out" |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +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. |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 67 | # Note: test_XXX (none currently) really leak, but are disabled |
| 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. |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 70 | LEAKY_TESTS="test_(asynchat|cmd_line|popen2|socket|smtplib|sys|threadsignals|urllib2_localnet)" |
Guido van Rossum | 5205653 | 2007-05-10 14:04:07 +0000 | [diff] [blame] | 71 | |
| 72 | # These tests always fail, so skip them so we don't get false positives. |
Guido van Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 73 | _ALWAYS_SKIP="" |
Guido van Rossum | 5205653 | 2007-05-10 14:04:07 +0000 | [diff] [blame] | 74 | ALWAYS_SKIP="-x $_ALWAYS_SKIP" |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 75 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 76 | # Skip these tests altogether when looking for leaks. These tests |
| 77 | # do not need to be stored above in LEAKY_TESTS too. |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 78 | # test_logging causes hangs, skip it. |
Neal Norwitz | cb44f26 | 2007-08-16 05:15:20 +0000 | [diff] [blame] | 79 | LEAKY_SKIPS="-x test_logging $_ALWAYS_SKIP" |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 80 | |
| 81 | # 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] | 82 | BUILD_DISABLED="no" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 83 | |
| 84 | ## utility functions |
| 85 | current_time() { |
| 86 | date +%s |
| 87 | } |
| 88 | |
| 89 | update_status() { |
| 90 | now=`current_time` |
| 91 | time=`expr $now - $3` |
| 92 | echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE |
| 93 | } |
| 94 | |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 95 | place_summary_first() { |
| 96 | testf=$1 |
| 97 | sed -n '/^[0-9][0-9]* tests OK\./,$p' < $testf \ |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 98 | | egrep -v '\[[0-9]+ refs\]' > $testf.tmp |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 99 | echo "" >> $testf.tmp |
| 100 | cat $testf >> $testf.tmp |
| 101 | mv $testf.tmp $testf |
| 102 | } |
| 103 | |
| 104 | count_failures () { |
| 105 | testf=$1 |
| 106 | n=`grep -ic " failed:" $testf` |
| 107 | if [ $n -eq 1 ] ; then |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 108 | n=`grep " failed:" $testf | sed -e 's/ .*//'` |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 109 | fi |
| 110 | echo $n |
| 111 | } |
| 112 | |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 113 | mail_on_failure() { |
| 114 | if [ "$NUM_FAILURES" != "0" ]; then |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 115 | dest=$FAILURE_MAILTO |
| 116 | # FAILURE_CC is optional. |
| 117 | if [ "$FAILURE_CC" != "" ]; then |
| 118 | dest="$dest -c $FAILURE_CC" |
| 119 | fi |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 120 | if [ "x$3" != "x" ] ; then |
| 121 | (echo "More important issues:" |
| 122 | echo "----------------------" |
| 123 | egrep -v "$3" < $2 |
| 124 | echo "" |
| 125 | echo "Less important issues:" |
| 126 | echo "----------------------" |
| 127 | egrep "$3" < $2) |
Christian Heimes | 292d351 | 2008-02-03 16:51:08 +0000 | [diff] [blame] | 128 | else |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 129 | cat $2 |
| 130 | fi | mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 131 | fi |
| 132 | } |
| 133 | |
| 134 | ## setup |
| 135 | cd $DIR |
| 136 | mkdir -p build |
| 137 | rm -f $RESULT_FILE build/*.out |
| 138 | rm -rf $INSTALL_DIR |
| 139 | |
| 140 | ## create results file |
| 141 | TITLE="Automated Python Build Results" |
Neal Norwitz | b896759 | 2006-01-16 04:37:22 +0000 | [diff] [blame] | 142 | echo "<html>" >> $RESULT_FILE |
| 143 | echo " <head>" >> $RESULT_FILE |
| 144 | echo " <title>$TITLE</title>" >> $RESULT_FILE |
| 145 | echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE |
| 146 | echo " </head>" >> $RESULT_FILE |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 147 | echo "<body>" >> $RESULT_FILE |
| 148 | echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE |
| 149 | echo "<table>" >> $RESULT_FILE |
| 150 | echo " <tr>" >> $RESULT_FILE |
| 151 | echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE |
| 152 | echo " </tr><tr>" >> $RESULT_FILE |
| 153 | echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE |
| 154 | echo " </tr><tr>" >> $RESULT_FILE |
| 155 | echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE |
| 156 | echo " </tr>" >> $RESULT_FILE |
| 157 | echo "</table>" >> $RESULT_FILE |
| 158 | echo "<ul>" >> $RESULT_FILE |
| 159 | |
| 160 | ## update, build, and test |
| 161 | ORIG_CHECKSUM=`cksum $FULLPATHNAME` |
| 162 | F=svn-update.out |
| 163 | start=`current_time` |
| 164 | svn update >& build/$F |
| 165 | err=$? |
| 166 | update_status "Updating" "$F" $start |
Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 167 | if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 168 | ## FIXME: we should check if this file has changed. |
| 169 | ## If it has changed, we should re-run the script to pick up changes. |
| 170 | if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then |
| 171 | exec $FULLPATHNAME $@ |
| 172 | fi |
| 173 | |
| 174 | F=svn-stat.out |
| 175 | start=`current_time` |
| 176 | svn stat >& build/$F |
| 177 | ## ignore some of the diffs |
| 178 | NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F` |
| 179 | update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start |
| 180 | |
| 181 | F=configure.out |
| 182 | start=`current_time` |
| 183 | ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F |
| 184 | err=$? |
| 185 | update_status "Configuring" "$F" $start |
| 186 | if [ $err = 0 ]; then |
| 187 | F=make.out |
| 188 | start=`current_time` |
| 189 | make >& build/$F |
| 190 | err=$? |
| 191 | warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"` |
| 192 | update_status "Building ($warnings warnings)" "$F" $start |
| 193 | if [ $err = 0 ]; then |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 194 | ## make install |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 195 | F=make-install.out |
| 196 | start=`current_time` |
| 197 | make install >& build/$F |
| 198 | update_status "Installing" "$F" $start |
| 199 | |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 200 | if [ ! -x $PYTHON ]; then |
Guido van Rossum | 5205653 | 2007-05-10 14:04:07 +0000 | [diff] [blame] | 201 | ln -s ${PYTHON}3.* $PYTHON |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 202 | fi |
| 203 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 204 | ## make and run basic tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 205 | F=make-test.out |
| 206 | start=`current_time` |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 207 | $PYTHON $REGRTEST_ARGS -u urlfetch >& build/$F |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 208 | NUM_FAILURES=`count_failures build/$F` |
| 209 | place_summary_first build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 210 | update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start |
Neal Norwitz | 02c408d | 2006-01-03 02:18:01 +0000 | [diff] [blame] | 211 | mail_on_failure "basics" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 212 | |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 213 | F=make-test-opt.out |
| 214 | start=`current_time` |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 215 | $PYTHON -O $REGRTEST_ARGS -u urlfetch >& build/$F |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 216 | NUM_FAILURES=`count_failures build/$F` |
| 217 | place_summary_first build/$F |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 218 | update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start |
| 219 | mail_on_failure "opt" build/$F |
| 220 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 221 | ## run the tests looking for leaks |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 222 | F=make-test-refleak.out |
| 223 | start=`current_time` |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 224 | ## ensure that the reflog exists so the grep doesn't fail |
| 225 | touch $REFLOG |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 226 | $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network,urlfetch $LEAKY_SKIPS >& build/$F |
| 227 | LEAK_PAT="($LEAKY_TESTS|sum=0)" |
Christian Heimes | 292d351 | 2008-02-03 16:51:08 +0000 | [diff] [blame] | 228 | NUM_FAILURES=`egrep -vc "$LEAK_PAT" $REFLOG` |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 229 | place_summary_first build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 230 | update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start |
Christian Heimes | 292d351 | 2008-02-03 16:51:08 +0000 | [diff] [blame] | 231 | mail_on_failure "refleak" $REFLOG "$LEAK_PAT" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 232 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 233 | ## now try to run all the tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 234 | F=make-testall.out |
| 235 | start=`current_time` |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 236 | ## skip curses when running from cron since there's no terminal |
| 237 | ## skip sound since it's not setup on the PSF box (/dev/dsp) |
Guido van Rossum | 5205653 | 2007-05-10 14:04:07 +0000 | [diff] [blame] | 238 | $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev $_ALWAYS_SKIP >& build/$F |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 239 | NUM_FAILURES=`count_failures build/$F` |
| 240 | place_summary_first build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 241 | 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] | 242 | mail_on_failure "all" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 243 | fi |
| 244 | fi |
| 245 | fi |
| 246 | |
| 247 | |
| 248 | ## make doc |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 249 | cd $DIR/Doc |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 250 | F="make-doc.out" |
| 251 | start=`current_time` |
Neal Norwitz | cb44f26 | 2007-08-16 05:15:20 +0000 | [diff] [blame] | 252 | # XXX(nnorwitz): For now, keep the code that checks for a conflicted file until |
| 253 | # after the first release of 2.6a1 or 3.0a1. At that point, it will be clear |
| 254 | # if there will be a similar problem with the new doc system. |
| 255 | |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 256 | # Doc/commontex/boilerplate.tex is expected to always have an outstanding |
| 257 | # modification for the date. When a release is cut, a conflict occurs. |
| 258 | # This allows us to detect this problem and not try to build the docs |
| 259 | # which will definitely fail with a conflict. |
Neal Norwitz | cb44f26 | 2007-08-16 05:15:20 +0000 | [diff] [blame] | 260 | #CONFLICTED_FILE=commontex/boilerplate.tex |
| 261 | #conflict_count=`grep -c "<<<" $CONFLICTED_FILE` |
| 262 | conflict_count=0 |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 263 | if [ $conflict_count != 0 ]; then |
| 264 | echo "Conflict detected in $CONFLICTED_FILE. Doc build skipped." > ../build/$F |
| 265 | err=1 |
| 266 | else |
Neal Norwitz | ed44a1a | 2007-08-17 04:19:37 +0000 | [diff] [blame] | 267 | make update html >& ../build/$F |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 268 | err=$? |
| 269 | fi |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 270 | update_status "Making doc" "$F" $start |
| 271 | if [ $err != 0 ]; then |
| 272 | NUM_FAILURES=1 |
| 273 | mail_on_failure "doc" ../build/$F |
| 274 | fi |
| 275 | |
| 276 | echo "</ul>" >> $RESULT_FILE |
| 277 | echo "</body>" >> $RESULT_FILE |
| 278 | echo "</html>" >> $RESULT_FILE |
| 279 | |
| 280 | ## copy results |
Neal Norwitz | cb44f26 | 2007-08-16 05:15:20 +0000 | [diff] [blame] | 281 | rsync $RSYNC_OPTS build/html/* $REMOTE_SYSTEM:$REMOTE_DIR |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 282 | cd ../build |
| 283 | rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/ |