Mercurial > hg-stable
changeset 4298:58517f6eb1ad
test-ssh: avoid a shell script
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Tue, 27 Mar 2007 01:41:22 -0300 |
parents | 27590c19ad30 |
children | 6b1e1b9da853 |
files | tests/test-ssh tests/test-ssh.out |
diffstat | 2 files changed, 32 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-ssh Tue Mar 27 01:41:21 2007 -0300 +++ b/tests/test-ssh Tue Mar 27 01:41:22 2007 -0300 @@ -4,27 +4,28 @@ # 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 @@ 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 "# empty default pull" hg paths -hg pull -e ../dummyssh +hg pull -e "python ../dummyssh" echo "# local change" echo bleah > foo @@ -70,13 +71,13 @@ 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
--- a/tests/test-ssh.out Tue Mar 27 01:41:21 2007 -0300 +++ b/tests/test-ssh.out Tue Mar 27 01:41:22 2007 -0300 @@ -78,13 +78,13 @@ 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