changeset 13405:682edefe7dbb

tests: use printenv.py where it is - don't copy it around
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 15 Feb 2011 02:17:43 +0100
parents 31a256ffe9e5
children 5e57c199848d
files tests/printenv.py tests/test-bundle.t tests/test-hook.t tests/test-http.t tests/test-pull-http.t tests/test-push-http.t tests/test-ssh.t tests/test-static-http.t
diffstat 8 files changed, 32 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/tests/printenv.py	Tue Feb 15 01:05:32 2011 +0100
+++ b/tests/printenv.py	Tue Feb 15 02:17:43 2011 +0100
@@ -1,12 +1,9 @@
 # simple script to be used in hooks
-# copy it to the current directory when the test starts:
-#
-#     cp "$TESTDIR"/printenv.py .
 #
 # put something like this in the repo .hg/hgrc:
 #
 #     [hooks]
-#     changegroup = python ../printenv.py <hookname> [exit] [output]
+#     changegroup = python "$TESTDIR"/printenv.py <hookname> [exit] [output]
 #
 #   - <hookname> is a mandatory argument (e.g. "changegroup")
 #   - [exit] is the exit code of the hook (default: 0)
--- a/tests/test-bundle.t	Tue Feb 15 01:05:32 2011 +0100
+++ b/tests/test-bundle.t	Tue Feb 15 02:17:43 2011 +0100
@@ -1,5 +1,3 @@
-  $ cp "$TESTDIR"/printenv.py .
-
 Setting up test
 
   $ hg init test
@@ -199,7 +197,7 @@
 Pull ../full.hg into empty (with hook)
 
   $ echo '[hooks]' >> .hg/hgrc
-  $ echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc
+  $ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup' >> .hg/hgrc
 
 doesn't work (yet ?)
 
--- a/tests/test-hook.t	Tue Feb 15 01:05:32 2011 +0100
+++ b/tests/test-hook.t	Tue Feb 15 02:17:43 2011 +0100
@@ -1,18 +1,16 @@
-  $ cp "$TESTDIR"/printenv.py .
-
 commit hooks can see env vars
 
   $ hg init a
   $ cd a
   $ echo "[hooks]" > .hg/hgrc
-  $ echo 'commit = unset HG_LOCAL HG_TAG; python ../printenv.py commit' >> .hg/hgrc
-  $ echo 'commit.b = unset HG_LOCAL HG_TAG; python ../printenv.py commit.b' >> .hg/hgrc
-  $ echo 'precommit = unset HG_LOCAL HG_NODE HG_TAG; python ../printenv.py precommit' >> .hg/hgrc
-  $ echo 'pretxncommit = unset HG_LOCAL HG_TAG; python ../printenv.py pretxncommit' >> .hg/hgrc
+  $ echo 'commit = unset HG_LOCAL HG_TAG; python "$TESTDIR"/printenv.py commit' >> .hg/hgrc
+  $ echo 'commit.b = unset HG_LOCAL HG_TAG; python "$TESTDIR"/printenv.py commit.b' >> .hg/hgrc
+  $ echo 'precommit = unset HG_LOCAL HG_NODE HG_TAG; python "$TESTDIR"/printenv.py precommit' >> .hg/hgrc
+  $ echo 'pretxncommit = unset HG_LOCAL HG_TAG; python "$TESTDIR"/printenv.py pretxncommit' >> .hg/hgrc
   $ echo 'pretxncommit.tip = hg -q tip' >> .hg/hgrc
-  $ echo 'pre-identify = python ../printenv.py pre-identify 1' >> .hg/hgrc
-  $ echo 'pre-cat = python ../printenv.py pre-cat' >> .hg/hgrc
-  $ echo 'post-cat = python ../printenv.py post-cat' >> .hg/hgrc
+  $ echo 'pre-identify = python "$TESTDIR"/printenv.py pre-identify 1' >> .hg/hgrc
+  $ echo 'pre-cat = python "$TESTDIR"/printenv.py pre-cat' >> .hg/hgrc
+  $ echo 'post-cat = python "$TESTDIR"/printenv.py post-cat' >> .hg/hgrc
   $ echo a > a
   $ hg add a
   $ hg commit -m a
@@ -30,9 +28,9 @@
 changegroup hooks can see env vars
 
   $ echo '[hooks]' > .hg/hgrc
-  $ echo 'prechangegroup = python ../printenv.py prechangegroup' >> .hg/hgrc
-  $ echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc
-  $ echo 'incoming = python ../printenv.py incoming' >> .hg/hgrc
+  $ echo 'prechangegroup = python "$TESTDIR"/printenv.py prechangegroup' >> .hg/hgrc
+  $ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup' >> .hg/hgrc
+  $ echo 'incoming = python "$TESTDIR"/printenv.py incoming' >> .hg/hgrc
 
 pretxncommit and commit hooks can see both parents of merge
 
@@ -94,8 +92,8 @@
 tag hooks can see env vars
 
   $ cd ../a
-  $ echo 'pretag = python ../printenv.py pretag' >> .hg/hgrc
-  $ echo 'tag = unset HG_PARENT1 HG_PARENT2; python ../printenv.py tag' >> .hg/hgrc
+  $ echo 'pretag = python "$TESTDIR"/printenv.py pretag' >> .hg/hgrc
+  $ echo 'tag = unset HG_PARENT1 HG_PARENT2; python "$TESTDIR"/printenv.py tag' >> .hg/hgrc
   $ hg tag -d '3 0' a
   pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a 
   precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 
@@ -110,7 +108,7 @@
 
 pretag hook can forbid tagging
 
-  $ echo 'pretag.forbid = python ../printenv.py pretag.forbid 1' >> .hg/hgrc
+  $ echo 'pretag.forbid = python "$TESTDIR"/printenv.py pretag.forbid 1' >> .hg/hgrc
   $ hg tag -d '4 0' fa
   pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa 
   pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa 
@@ -126,7 +124,7 @@
 more there after
 
   $ echo 'pretxncommit.forbid0 = hg tip -q' >> .hg/hgrc
-  $ echo 'pretxncommit.forbid1 = python ../printenv.py pretxncommit.forbid 1' >> .hg/hgrc
+  $ echo 'pretxncommit.forbid1 = python "$TESTDIR"/printenv.py pretxncommit.forbid 1' >> .hg/hgrc
   $ echo z > z
   $ hg add z
   $ hg -q tip
@@ -146,7 +144,7 @@
 
 precommit hook can prevent commit
 
-  $ echo 'precommit.forbid = python ../printenv.py precommit.forbid 1' >> .hg/hgrc
+  $ echo 'precommit.forbid = python "$TESTDIR"/printenv.py precommit.forbid 1' >> .hg/hgrc
   $ hg commit -m 'fail' -d '4 0'
   precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 
   precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 
@@ -157,14 +155,14 @@
 
 preupdate hook can prevent update
 
-  $ echo 'preupdate = python ../printenv.py preupdate' >> .hg/hgrc
+  $ echo 'preupdate = python "$TESTDIR"/printenv.py preupdate' >> .hg/hgrc
   $ hg update 1
   preupdate hook: HG_PARENT1=ab228980c14d 
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
 
 update hook
 
-  $ echo 'update = python ../printenv.py update' >> .hg/hgrc
+  $ echo 'update = python "$TESTDIR"/printenv.py update' >> .hg/hgrc
   $ hg update
   preupdate hook: HG_PARENT1=539e4b31b6dc 
   update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc 
@@ -176,7 +174,7 @@
   $ hg -q tip
   3:07f3376c1e65
   $ echo '[hooks]' > .hg/hgrc
-  $ echo 'prechangegroup.forbid = python ../printenv.py prechangegroup.forbid 1' >> .hg/hgrc
+  $ echo 'prechangegroup.forbid = python "$TESTDIR"/printenv.py prechangegroup.forbid 1' >> .hg/hgrc
   $ hg pull ../a
   prechangegroup.forbid hook: HG_SOURCE=pull HG_URL=file:$TESTTMP/a 
   pulling from ../a
@@ -189,7 +187,7 @@
 
   $ echo '[hooks]' > .hg/hgrc
   $ echo 'pretxnchangegroup.forbid0 = hg tip -q' >> .hg/hgrc
-  $ echo 'pretxnchangegroup.forbid1 = python ../printenv.py pretxnchangegroup.forbid 1' >> .hg/hgrc
+  $ echo 'pretxnchangegroup.forbid1 = python "$TESTDIR"/printenv.py pretxnchangegroup.forbid 1' >> .hg/hgrc
   $ hg pull ../a
   4:539e4b31b6dc
   pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_URL=file:$TESTTMP/a 
@@ -210,8 +208,8 @@
 
   $ rm .hg/hgrc
   $ echo '[hooks]' > ../a/.hg/hgrc
-  $ echo 'preoutgoing = python ../printenv.py preoutgoing' >> ../a/.hg/hgrc
-  $ echo 'outgoing = python ../printenv.py outgoing' >> ../a/.hg/hgrc
+  $ echo 'preoutgoing = python "$TESTDIR"/printenv.py preoutgoing' >> ../a/.hg/hgrc
+  $ echo 'outgoing = python "$TESTDIR"/printenv.py outgoing' >> ../a/.hg/hgrc
   $ hg pull ../a
   preoutgoing hook: HG_SOURCE=pull 
   outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull 
@@ -227,7 +225,7 @@
 
 preoutgoing hook can prevent outgoing changes
 
-  $ echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc
+  $ echo 'preoutgoing.forbid = python "$TESTDIR"/printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc
   $ hg pull ../a
   preoutgoing hook: HG_SOURCE=pull 
   preoutgoing.forbid hook: HG_SOURCE=pull 
@@ -240,8 +238,8 @@
 
   $ cd ..
   $ echo '[hooks]' > a/.hg/hgrc
-  $ echo 'preoutgoing = python ../printenv.py preoutgoing' >> a/.hg/hgrc
-  $ echo 'outgoing = python ../printenv.py outgoing' >> a/.hg/hgrc
+  $ echo 'preoutgoing = python "$TESTDIR"/printenv.py preoutgoing' >> a/.hg/hgrc
+  $ echo 'outgoing = python "$TESTDIR"/printenv.py outgoing' >> a/.hg/hgrc
   $ hg clone a c
   preoutgoing hook: HG_SOURCE=clone 
   outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone 
@@ -251,7 +249,7 @@
 
 preoutgoing hook can prevent outgoing changes for local clones
 
-  $ echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc
+  $ echo 'preoutgoing.forbid = python "$TESTDIR"/printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc
   $ hg clone a zzz
   preoutgoing hook: HG_SOURCE=clone 
   preoutgoing.forbid hook: HG_SOURCE=clone 
--- a/tests/test-http.t	Tue Feb 15 01:05:32 2011 +0100
+++ b/tests/test-http.t	Tue Feb 15 02:17:43 2011 +0100
@@ -1,5 +1,4 @@
 
-  $ cp "$TESTDIR"/printenv.py .
   $ hg init test
   $ cd test
   $ echo foo>foo
@@ -75,7 +74,7 @@
 
   $ cd copy-pull
   $ echo '[hooks]' >> .hg/hgrc
-  $ echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc
+  $ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup' >> .hg/hgrc
   $ hg pull
   changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=http://localhost:$HGPORT1/ 
   pulling from http://localhost:$HGPORT1/
--- a/tests/test-pull-http.t	Tue Feb 15 01:05:32 2011 +0100
+++ b/tests/test-pull-http.t	Tue Feb 15 02:17:43 2011 +0100
@@ -1,5 +1,4 @@
 
-  $ cp "$TESTDIR"/printenv.py .
   $ hg init test
   $ cd test
   $ echo a > a
--- a/tests/test-push-http.t	Tue Feb 15 01:05:32 2011 +0100
+++ b/tests/test-push-http.t	Tue Feb 15 02:17:43 2011 +0100
@@ -1,5 +1,4 @@
 
-  $ cp "$TESTDIR"/printenv.py .
   $ hg init test
   $ cd test
   $ echo a > a
@@ -53,7 +52,7 @@
 
   $ echo 'allow_push = *' >> .hg/hgrc
   $ echo '[hooks]' >> .hg/hgrc
-  $ echo 'changegroup = python ../printenv.py changegroup 0' >> .hg/hgrc
+  $ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup 0' >> .hg/hgrc
   $ req
   pushing to http://localhost:$HGPORT/
   searching for changes
--- a/tests/test-ssh.t	Tue Feb 15 01:05:32 2011 +0100
+++ b/tests/test-ssh.t	Tue Feb 15 02:17:43 2011 +0100
@@ -1,5 +1,4 @@
 
-  $ cp "$TESTDIR"/printenv.py .
 
 This test tries to exercise the ssh functionality with a dummy script
 
@@ -45,7 +44,7 @@
   > bookmarks =
   > 
   > [hooks]
-  > changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog
+  > changegroup = python "$TESTDIR"/printenv.py changegroup-in-remote 0 ../dummylog
   > EOF
   $ cd ..
 
@@ -101,7 +100,7 @@
   checking files
   2 files, 1 changesets, 2 total revisions
   $ echo '[hooks]' >> .hg/hgrc
-  $ echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc
+  $ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc
 
 empty default pull
 
--- a/tests/test-static-http.t	Tue Feb 15 01:05:32 2011 +0100
+++ b/tests/test-static-http.t	Tue Feb 15 02:17:43 2011 +0100
@@ -1,5 +1,4 @@
 
-  $ cp "$TESTDIR"/printenv.py .
   $ hg clone http://localhost:$HGPORT/ copy
   abort: error: Connection refused
   [255]
@@ -67,7 +66,7 @@
   $ rm .hg/cache/*
   $ cd ../local
   $ echo '[hooks]' >> .hg/hgrc
-  $ echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc
+  $ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup' >> .hg/hgrc
   $ hg pull
   changegroup hook: HG_NODE=4ac2e3648604439c580c69b09ec9d93a88d93432 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/remote 
   pulling from static-http://localhost:$HGPORT/remote