diff --git a/tests/test-ssh b/tests/test-ssh --- 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 < 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 diff --git a/tests/test-ssh.out b/tests/test-ssh.out --- a/tests/test-ssh.out +++ b/tests/test-ssh.out @@ -78,13 +78,13 @@ remote: adding changesets remote: adding manifests remote: adding file changes remote: added 1 changesets with 1 changes to 1 files -Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio 3: 4: 5: -Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5: -Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5: -Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5: -Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5: -Got arguments 1:user@dummy 2:hg -R local serve --stdio 3: 4: 5: -Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5: +Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio +Got arguments 1:user@dummy 2:hg -R remote serve --stdio +Got arguments 1:user@dummy 2:hg -R remote serve --stdio +Got arguments 1:user@dummy 2:hg -R remote serve --stdio +Got arguments 1:user@dummy 2:hg -R remote serve --stdio +Got arguments 1:user@dummy 2:hg -R local serve --stdio +Got arguments 1:user@dummy 2:hg -R remote serve --stdio changegroup-in-remote hook: HG_NODE=572896fe480d7581849806ee402175c49cb20037 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1 -Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5: +Got arguments 1:user@dummy 2:hg -R remote serve --stdio changegroup-in-remote hook: HG_NODE=ac7448082955a0b2ff5cb4512c1e061c779bbc79 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1