tests/test-ssh
changeset 4298 58517f6eb1ad
parent 4291 35b2e02367a5
--- a/tests/test-ssh
+++ b/tests/test-ssh
@@ -4,27 +4,28 @@ cp "$TESTDIR"/printenv.py .
 
 # This test tries to exercise the ssh functionality with a dummy script
 
-cat <<'EOF' > dummyssh
-#!/bin/sh
-# this attempts to deal with relative pathnames
-cd `dirname $0`
+cat <<EOF > dummyssh
+import sys
+import os
 
-# check for proper args
-if [ $1 != "user@dummy" ] ; then
-	exit -1
-fi
+os.chdir(os.path.dirname(sys.argv[0]))
+if sys.argv[1] != "user@dummy":
+    sys.exit(-1)
+
+if not os.path.exists("dummyssh"):
+    sys.exit(-1)
 
-# check that we're in the right directory
-if [ ! -x dummyssh ] ; then
-	exit -1
-fi
+os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"
 
-SSH_CLIENT='127.0.0.1 1 2'
-export SSH_CLIENT
-echo Got arguments 1:$1 2:$2 3:$3 4:$4 5:$5 >> dummylog
-$2
+log = open("dummylog", "ab")
+log.write("Got arguments")
+for i, arg in enumerate(sys.argv[1:]):
+    log.write(" %d:%s" % (i+1, arg))
+log.write("\n")
+log.close()
+r = os.system(sys.argv[2])
+sys.exit(bool(r))
 EOF
-chmod +x dummyssh
 
 echo "# creating 'remote'"
 hg init remote
@@ -40,17 +41,17 @@ echo 'changegroup = python ../printenv.p
 cd ..
 
 echo "# repo not found error"
-hg clone -e ./dummyssh ssh://user@dummy/nonexistent local
+hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local
 
 echo "# clone remote via stream"
-hg clone -e ./dummyssh --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
+hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
   sed -e 's/[0-9][0-9.]*/XXX/g' -e 's/[KM]\(B\/sec\)/X\1/'
 cd local-stream
 hg verify
 cd ..
 
 echo "# clone remote via pull"
-hg clone -e ./dummyssh ssh://user@dummy/remote local
+hg clone -e "python ./dummyssh" ssh://user@dummy/remote local
 
 echo "# verify"
 cd local
@@ -61,7 +62,7 @@ echo 'changegroup = python ../printenv.p
 
 echo "# empty default pull"
 hg paths
-hg pull -e ../dummyssh
+hg pull -e "python ../dummyssh"
 
 echo "# local change"
 echo bleah > foo
@@ -70,13 +71,13 @@ hg ci -m "add" -d "1000000 0"
 echo "# updating rc"
 echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
 echo "[ui]" >> .hg/hgrc
-echo "ssh = ../dummyssh" >> .hg/hgrc
+echo "ssh = python ../dummyssh" >> .hg/hgrc
 
 echo "# find outgoing"
 hg out ssh://user@dummy/remote
 
 echo "# find incoming on the remote side"
-hg incoming -R ../remote -e ../dummyssh ssh://user@dummy/local
+hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local
 
 echo "# push"
 hg push