comparison tests/test-ssh-clone-r @ 4299:6b1e1b9da853

test-ssh-clone-r: avoid a shell script
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 27 Mar 2007 01:41:23 -0300
parents c0b449154a90
children
comparison
equal deleted inserted replaced
4298:58517f6eb1ad 4299:6b1e1b9da853
1 #!/bin/sh 1 #!/bin/sh
2 2
3 # This test tries to exercise the ssh functionality with a dummy script 3 # This test tries to exercise the ssh functionality with a dummy script
4 4
5 cat <<'EOF' > dummyssh 5 cat <<EOF > dummyssh
6 #!/bin/sh 6 import sys
7 # this attempts to deal with relative pathnames 7 import os
8 cd `dirname $0`
9 8
10 # check for proper args 9 os.chdir(os.path.dirname(sys.argv[0]))
11 if [ $1 != "user@dummy" ] ; then 10 if sys.argv[1] != "user@dummy":
12 exit -1 11 sys.exit(-1)
13 fi
14 12
15 # check that we're in the right directory 13 if not os.path.exists("dummyssh"):
16 if [ ! -x dummyssh ] ; then 14 sys.exit(-1)
17 exit -1
18 fi
19 15
20 SSH_CLIENT='127.0.0.1 1 2' 16 os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"
21 export SSH_CLIENT 17
22 echo Got arguments 1:$1 2:$2 3:$3 4:$4 5:$5 >> dummylog 18 log = open("dummylog", "ab")
23 $2 19 log.write("Got arguments")
20 for i, arg in enumerate(sys.argv[1:]):
21 log.write(" %d:%s" % (i+1, arg))
22 log.write("\n")
23 log.close()
24 r = os.system(sys.argv[2])
25 sys.exit(bool(r))
24 EOF 26 EOF
25 chmod +x dummyssh
26 27
27 hg init remote 28 hg init remote
28 cd remote 29 cd remote
29 echo "# creating 'remote'" 30 echo "# creating 'remote'"
30 cat >>afile <<EOF 31 cat >>afile <<EOF
74 hg verify 75 hg verify
75 cd .. 76 cd ..
76 77
77 echo "# clone remote via stream" 78 echo "# clone remote via stream"
78 for i in 0 1 2 3 4 5 6 7 8; do 79 for i in 0 1 2 3 4 5 6 7 8; do
79 hg clone -e ./dummyssh --uncompressed -r "$i" ssh://user@dummy/remote test-"$i" 2>&1 80 hg clone -e "python ./dummyssh" --uncompressed -r "$i" ssh://user@dummy/remote test-"$i" 2>&1
80 if cd test-"$i"; then 81 if cd test-"$i"; then
81 hg verify 82 hg verify
82 cd .. 83 cd ..
83 fi 84 fi
84 done 85 done
85 cd test-8 86 cd test-8
86 hg pull ../test-7 87 hg pull ../test-7
87 hg verify 88 hg verify
88 cd .. 89 cd ..
89 cd test-1 90 cd test-1
90 hg pull -e ../dummyssh -r 4 ssh://user@dummy/remote 2>&1 91 hg pull -e "python ../dummyssh" -r 4 ssh://user@dummy/remote 2>&1
91 hg verify 92 hg verify
92 hg pull -e ../dummyssh ssh://user@dummy/remote 2>&1 93 hg pull -e "python ../dummyssh" ssh://user@dummy/remote 2>&1
93 cd .. 94 cd ..
94 cd test-2 95 cd test-2
95 hg pull -e ../dummyssh -r 5 ssh://user@dummy/remote 2>&1 96 hg pull -e "python ../dummyssh" -r 5 ssh://user@dummy/remote 2>&1
96 hg verify 97 hg verify
97 hg pull -e ../dummyssh ssh://user@dummy/remote 2>&1 98 hg pull -e "python ../dummyssh" ssh://user@dummy/remote 2>&1
98 hg verify 99 hg verify
99 cd .. 100 cd ..