Author: danielsh
Date: Sun Jun 26 15:00:21 2011
New Revision: 1139806

URL: http://svn.apache.org/viewvc?rev=1139806&view=rev
Log:
Make svnserveautocheck more portable.

* Makefile.in
  (svnserveautocheck): Pass $PYTHON and don't call bash.

* subversion/tests/cmdline/svnserveautocheck.sh
  (#!): s#/bin/bash#/bin/sh#
  ($PYTHON): Use this environment variable, if available.
  (): Replace bash-specific constructs with more portable equivalents.

Modified:
    subversion/trunk/Makefile.in
    subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh

Modified: subversion/trunk/Makefile.in
URL: 
http://svn.apache.org/viewvc/subversion/trunk/Makefile.in?rev=1139806&r1=1139805&r2=1139806&view=diff
==============================================================================
--- subversion/trunk/Makefile.in (original)
+++ subversion/trunk/Makefile.in Sun Jun 26 15:00:21 2011
@@ -511,8 +511,8 @@ svncheck: bin $(TEST_DEPS) @BDB_TEST_DEP
 
 # 'make svnserveautocheck' runs svnserve for you and kills it.
 svnserveautocheck: svnserve bin $(TEST_DEPS) @BDB_TEST_DEPS@
-       @env THREADED=$(THREADED) \
-         bash $(top_srcdir)/subversion/tests/cmdline/svnserveautocheck.sh
+       @env PYTHON=$(PYTHON) THREADED=$(THREADED) \
+         $(top_srcdir)/subversion/tests/cmdline/svnserveautocheck.sh
 
 # First, run:
 #   subversion/svnserve/svnserve --listen-host "::1" -d -r 
`pwd`/subversion/tests/cmdline

Modified: subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh?rev=1139806&r1=1139805&r2=1139806&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh (original)
+++ subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh Sun Jun 26 
15:00:21 2011
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 #
 # Licensed to the Apache Software Foundation (ASF) under one
@@ -32,6 +32,9 @@
 # svnserveautocheck".  Like "make check", you can specify further options
 # like "make svnserveautocheck FS_TYPE=bdb 
TESTS=subversion/tests/cmdline/basic.py".
 
+echo "PYTHON=$PYTHON" >&2
+PYTHON=${PYTHON:-python}
+
 SCRIPTDIR=$(dirname $0)
 SCRIPT=$(basename $0)
 
@@ -43,23 +46,23 @@ trap trap_cleanup SIGHUP SIGTERM SIGINT
 LC_ALL=C
 export LC_ALL
 
-function really_cleanup() {
+really_cleanup() {
     if [ -e  "$SVNSERVE_PID" ]; then
         kill $(cat "$SVNSERVE_PID")
         rm -f $SVNSERVE_PID
     fi
 }
 
-function trap_cleanup() {
+trap_cleanup() {
     really_cleanup
     exit 1
 }
 
-function say() {
+say() {
   echo "$SCRIPT: $*"
 }
 
-function fail() {
+fail() {
   say $*
   exit 1
 }
@@ -67,9 +70,9 @@ function fail() {
 if [ -x subversion/svn/svn ]; then
   ABS_BUILDDIR=$(pwd)
 elif [ -x $SCRIPTDIR/../../svn/svn ]; then
-  pushd $SCRIPTDIR/../../../ >/dev/null
+  cd $SCRIPTDIR/../../../
   ABS_BUILDDIR=$(pwd)
-  popd >/dev/null
+  cd - >/dev/null
 else
   fail "Run this script from the root of Subversion's build tree!"
 fi
@@ -84,9 +87,17 @@ SERVER_CMD="$ABS_BUILDDIR/subversion/svn
 
 rm -f $SVNSERVE_PID
 
-SVNSERVE_PORT=$(($RANDOM+1024))
+random_port() {
+  if [ -n "$BASH_VERSION" ]; then
+    echo $(($RANDOM+1024))
+  else
+    $PYTHON -c 'import random; print random.randint(1024, 2**16-1)'
+  fi
+}
+
+SVNSERVE_PORT=$(random_port)
 while netstat -an | grep $SVNSERVE_PORT | grep 'LISTEN'; do
-  SVNSERVE_PORT=$(($RANDOM+1024))
+  SVNSERVE_PORT=$(random_port)
 done
 
 if [ "$THREADED" != "" ]; then
@@ -100,16 +111,16 @@ fi
             $SVNSERVE_ARGS &
 
 BASE_URL=svn://127.0.0.1:$SVNSERVE_PORT
-if [ $# == 0 ]; then
+if [ $# = 0 ]; then
   time make check "BASE_URL=$BASE_URL"
   r=$?
 else
-  pushd "$ABS_BUILDDIR/subversion/tests/cmdline/" >/dev/null
+  cd "$ABS_BUILDDIR/subversion/tests/cmdline/"
   TEST="$1"
   shift
   time "./${TEST}_tests.py" "--url=$BASE_URL" $*
   r=$?
-  popd >/dev/null
+  cd - > /dev/null
 fi
 
 really_cleanup


Reply via email to