changeset 14186:8513bd2e7259

tests: share dummyssh
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 05 May 2011 01:47:46 +0200
parents eb297845f90b
children 9bbaafddfa90
files tests/dummyssh tests/test-init.t tests/test-ssh-clone-r.t tests/test-ssh.t
diffstat 4 files changed, 49 insertions(+), 95 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dummyssh	Thu May 05 01:47:46 2011 +0200
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import sys
+import os
+
+os.chdir(os.getenv('TESTTMP'))
+
+if sys.argv[1] != "user@dummy":
+    sys.exit(-1)
+
+os.environ["SSH_CLIENT"] = "127.0.0.1 1 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))
--- a/tests/test-init.t	Thu May 05 01:47:46 2011 +0200
+++ b/tests/test-init.t	Thu May 05 01:47:46 2011 +0200
@@ -1,26 +1,5 @@
 This test tries to exercise the ssh functionality with a dummy script
 
-  $ cat <<EOF > dummyssh
-  > import sys
-  > import os
-  > 
-  > 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)
-  > 
-  > 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
-
   $ checknewrepo()
   > {
   >    name=$1
@@ -80,7 +59,7 @@
 
 init+push to remote2
 
-  $ hg init -e "python ./dummyssh" ssh://user@dummy/remote2
+  $ hg init -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote2
   $ hg incoming -R remote2 local
   comparing with local
   changeset:   0:08b9e9f63b32
@@ -90,7 +69,7 @@
   summary:     init
   
 
-  $ hg push -R local -e "python ./dummyssh" ssh://user@dummy/remote2
+  $ hg push -R local -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote2
   pushing to ssh://user@dummy/remote2
   searching for changes
   remote: adding changesets
@@ -100,7 +79,7 @@
 
 clone to remote1
 
-  $ hg clone -e "python ./dummyssh" local ssh://user@dummy/remote1
+  $ hg clone -e "python $TESTDIR/dummyssh" local ssh://user@dummy/remote1
   searching for changes
   remote: adding changesets
   remote: adding manifests
@@ -109,14 +88,14 @@
 
 init to existing repo
 
-  $ hg init -e "python ./dummyssh" ssh://user@dummy/remote1
+  $ hg init -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote1
   abort: repository remote1 already exists!
   abort: could not create remote repo!
   [255]
 
 clone to existing repo
 
-  $ hg clone -e "python ./dummyssh" local ssh://user@dummy/remote1
+  $ hg clone -e "python $TESTDIR/dummyssh" local ssh://user@dummy/remote1
   abort: repository remote1 already exists!
   abort: could not create remote repo!
   [255]
@@ -205,7 +184,7 @@
   $ hg -R local bookmark test
   $ hg -R local bookmarks
    * test                      0:08b9e9f63b32
-  $ hg clone -e "python ./dummyssh" local ssh://user@dummy/remote-bookmarks
+  $ hg clone -e "python $TESTDIR/dummyssh" local ssh://user@dummy/remote-bookmarks
   searching for changes
   remote: adding changesets
   remote: adding manifests
--- a/tests/test-ssh-clone-r.t	Thu May 05 01:47:46 2011 +0200
+++ b/tests/test-ssh-clone-r.t	Thu May 05 01:47:46 2011 +0200
@@ -1,29 +1,6 @@
 This test tries to exercise the ssh functionality with a dummy script
 
-  $ cat <<EOF > dummyssh
-  > import sys
-  > import os
-  > 
-  > 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)
-  > 
-  > os.environ["SSH_CLIENT"] = "127.0.0.1 1 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
-
-creating 'remote
+creating 'remote' repo
 
   $ hg init remote
   $ cd remote
@@ -40,7 +17,7 @@
 clone remote via stream
 
   $ for i in 0 1 2 3 4 5 6 7 8; do
-  >    hg clone -e "python ./dummyssh" --uncompressed -r "$i" ssh://user@dummy/remote test-"$i"
+  >    hg clone -e "python $TESTDIR/dummyssh" --uncompressed -r "$i" ssh://user@dummy/remote test-"$i"
   >    if cd test-"$i"; then
   >       hg verify
   >       cd ..
@@ -162,7 +139,7 @@
   4 files, 9 changesets, 7 total revisions
   $ cd ..
   $ cd test-1
-  $ hg pull -e "python ../dummyssh" -r 4 ssh://user@dummy/remote
+  $ hg pull -e "python $TESTDIR/dummyssh" -r 4 ssh://user@dummy/remote
   pulling from ssh://user@dummy/remote
   searching for changes
   adding changesets
@@ -176,7 +153,7 @@
   crosschecking files in changesets and manifests
   checking files
   1 files, 3 changesets, 2 total revisions
-  $ hg pull -e "python ../dummyssh" ssh://user@dummy/remote
+  $ hg pull -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote
   pulling from ssh://user@dummy/remote
   searching for changes
   adding changesets
@@ -186,7 +163,7 @@
   (run 'hg update' to get a working copy)
   $ cd ..
   $ cd test-2
-  $ hg pull -e "python ../dummyssh" -r 5 ssh://user@dummy/remote
+  $ hg pull -e "python $TESTDIR/dummyssh" -r 5 ssh://user@dummy/remote
   pulling from ssh://user@dummy/remote
   searching for changes
   adding changesets
@@ -200,7 +177,7 @@
   crosschecking files in changesets and manifests
   checking files
   1 files, 5 changesets, 3 total revisions
-  $ hg pull -e "python ../dummyssh" ssh://user@dummy/remote
+  $ hg pull -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote
   pulling from ssh://user@dummy/remote
   searching for changes
   adding changesets
--- a/tests/test-ssh.t	Thu May 05 01:47:46 2011 +0200
+++ b/tests/test-ssh.t	Thu May 05 01:47:46 2011 +0200
@@ -2,33 +2,6 @@
 
 This test tries to exercise the ssh functionality with a dummy script
 
-  $ cat <<EOF > dummyssh
-  > import sys
-  > import os
-  > 
-  > 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)
-  > 
-  > os.environ["SSH_CLIENT"] = "127.0.0.1 1 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
-  $ cat <<EOF > badhook
-  > import sys
-  > sys.stdout.write("KABOOM\n")
-  > EOF
-
 creating 'remote' repo
 
   $ hg init remote
@@ -47,21 +20,21 @@
 
 repo not found error
 
-  $ hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local
+  $ hg clone -e "python $TESTDIR/dummyssh" ssh://user@dummy/nonexistent local
   remote: abort: There is no Mercurial repository here (.hg not found)!
   abort: no suitable response from remote hg!
   [255]
 
 non-existent absolute path
 
-  $ hg clone -e "python ./dummyssh" ssh://user@dummy//`pwd`/nonexistent local
+  $ hg clone -e "python $TESTDIR/dummyssh" ssh://user@dummy//`pwd`/nonexistent local
   remote: abort: There is no Mercurial repository here (.hg not found)!
   abort: no suitable response from remote hg!
   [255]
 
 clone remote via stream
 
-  $ hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream
+  $ hg clone -e "python $TESTDIR/dummyssh" --uncompressed ssh://user@dummy/remote local-stream
   streaming all changes
   4 files to transfer, 392 bytes of data
   transferred 392 bytes in * seconds (*/sec) (glob)
@@ -78,7 +51,7 @@
 
 clone remote via pull
 
-  $ hg clone -e "python ./dummyssh" ssh://user@dummy/remote local
+  $ hg clone -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote local
   requesting all changes
   adding changesets
   adding manifests
@@ -103,7 +76,7 @@
 
   $ hg paths
   default = ssh://user@dummy/remote
-  $ hg pull -e "python ../dummyssh"
+  $ hg pull -e "python $TESTDIR/dummyssh"
   pulling from ssh://user@dummy/remote
   searching for changes
   no changes found
@@ -117,7 +90,7 @@
 
   $ echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
   $ echo "[ui]" >> .hg/hgrc
-  $ echo "ssh = python ../dummyssh" >> .hg/hgrc
+  $ echo "ssh = python $TESTDIR/dummyssh" >> .hg/hgrc
 
 find outgoing
 
@@ -133,7 +106,7 @@
 
 find incoming on the remote side
 
-  $ hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local
+  $ hg incoming -R ../remote -e "python $TESTDIR/dummyssh" ssh://user@dummy/local
   comparing with ssh://user@dummy/local
   searching for changes
   changeset:   1:a28a9d1a809c
@@ -145,7 +118,7 @@
 
 find incoming on the remote side (using absolute path)
 
-  $ hg incoming -R ../remote -e "python ../dummyssh" "ssh://user@dummy/`pwd`"
+  $ hg incoming -R ../remote -e "python $TESTDIR/dummyssh" "ssh://user@dummy/`pwd`"
   comparing with ssh://user@dummy/$TESTTMP/local
   searching for changes
   changeset:   1:a28a9d1a809c
@@ -190,7 +163,7 @@
 test pushkeys and bookmarks
 
   $ cd ../local
-  $ hg debugpushkey --config ui.ssh="python ../dummyssh" ssh://user@dummy/remote namespaces
+  $ hg debugpushkey --config ui.ssh="python $TESTDIR/dummyssh" ssh://user@dummy/remote namespaces
   bookmarks	
   namespaces	
   $ hg book foo -r 0
@@ -203,7 +176,7 @@
   searching for changes
   no changes found
   exporting bookmark foo
-  $ hg debugpushkey --config ui.ssh="python ../dummyssh" ssh://user@dummy/remote bookmarks
+  $ hg debugpushkey --config ui.ssh="python $TESTDIR/dummyssh" ssh://user@dummy/remote bookmarks
   foo	1160648e36cec0054048a7edc4110c6f84fde594
   $ hg book -f foo
   $ hg push --traceback
@@ -231,8 +204,13 @@
 
 a bad, evil hook that prints to stdout
 
+  $ cat <<EOF > $TESTTMP/badhook
+  > import sys
+  > sys.stdout.write("KABOOM\n")
+  > EOF
+
   $ echo '[hooks]' >> ../remote/.hg/hgrc
-  $ echo 'changegroup.stdout = python ../badhook' >> ../remote/.hg/hgrc
+  $ echo "changegroup.stdout = python $TESTTMP/badhook" >> ../remote/.hg/hgrc
   $ echo r > r
   $ hg ci -A -m z r
 
@@ -267,7 +245,7 @@
   $ hg -R ../remote bookmark test
   $ hg -R ../remote bookmarks
    * test                      2:6c0482d977a3
-  $ hg clone -e "python ../dummyssh" ssh://user@dummy/remote local-bookmarks
+  $ hg clone -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote local-bookmarks
   requesting all changes
   adding changesets
   adding manifests