diff tests/test-init @ 4297:27590c19ad30

test-init: avoid a shell script
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 27 Mar 2007 01:41:21 -0300
parents c0271aba6abe
children 671b3e1eac2e
line wrap: on
line diff
--- a/tests/test-init	Tue Mar 27 01:41:20 2007 -0300
+++ b/tests/test-init	Tue Mar 27 01:41:21 2007 -0300
@@ -2,25 +2,26 @@
 
 # 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)
 
-# check that we're in the right directory
-if [ ! -x dummyssh ] ; then
-	exit -1
-fi
+if not os.path.exists("dummyssh"):
+    sys.exit(-1)
 
-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
 
 checknewrepo()
 {
@@ -51,18 +52,18 @@
 hg init local
 
 echo "# init+push to remote2"
-hg init -e ./dummyssh ssh://user@dummy/remote2
+hg init -e "python ./dummyssh" ssh://user@dummy/remote2
 hg incoming -R remote2 local
-hg push -R local -e ./dummyssh ssh://user@dummy/remote2
+hg push -R local -e "python ./dummyssh" ssh://user@dummy/remote2
 
 echo "# clone to remote1"
-hg clone -e ./dummyssh local ssh://user@dummy/remote1
+hg clone -e "python ./dummyssh" local ssh://user@dummy/remote1
 
 echo "# init to existing repo"
-hg init -e ./dummyssh ssh://user@dummy/remote1
+hg init -e "python ./dummyssh" ssh://user@dummy/remote1
 
 echo "# clone to existing repo"
-hg clone -e ./dummyssh local ssh://user@dummy/remote1
+hg clone -e "python ./dummyssh" local ssh://user@dummy/remote1
 
 echo "# output of dummyssh"
 cat dummylog