tests: simplify printenv calls

Make printenv executable so that we don't need python, TESTDIR, or
quoting.
This commit is contained in:
Matt Mackall 2015-06-08 15:10:15 -05:00
parent 1ea56de489
commit 36e5db11e5
12 changed files with 54 additions and 54 deletions

View File

@ -211,7 +211,7 @@ Make sure bundlerepo doesn't leak tempfiles (issue2491)
Pull ../full.hg into empty (with hook)
$ echo "[hooks]" >> .hg/hgrc
$ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc
$ echo "changegroup = printenv.py changegroup" >> .hg/hgrc
doesn't work (yet ?)

View File

@ -28,7 +28,7 @@ enable obsolescence
> [hooks]
> pretxnclose.tip = hg log -r tip -T "pre-close-tip:{node|short} {phase} {bookmarks}\n"
> txnclose.tip = hg log -r tip -T "postclose-tip:{node|short} {phase} {bookmarks}\n"
> txnclose.env = sh -c "HG_LOCAL= python \"$TESTDIR/printenv.py\" txnclose"
> txnclose.env = sh -c "HG_LOCAL= printenv.py txnclose"
> pushkey= sh "$TESTTMP/bundle2-pushkey-hook.sh"
> EOF

View File

@ -67,9 +67,9 @@ Add two linear commits
$ cd ../clone
$ cat >> .hg/hgrc <<EOF
> [hooks]
> pretxnchangegroup = sh -c "python \"$TESTDIR/printenv.py\" pretxnchangegroup"
> changegroup = sh -c "python \"$TESTDIR/printenv.py\" changegroup"
> incoming = sh -c "python \"$TESTDIR/printenv.py\" incoming"
> pretxnchangegroup = sh -c "printenv.py pretxnchangegroup"
> changegroup = sh -c "printenv.py changegroup"
> incoming = sh -c "printenv.py incoming"
> EOF
Pull the new commits in the clone

View File

@ -17,19 +17,19 @@ commit hooks can see env vars
$ cd a
$ cat > .hg/hgrc <<EOF
> [hooks]
> commit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit"
> commit.b = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit.b"
> precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= python \"$TESTDIR/printenv.py\" precommit"
> pretxncommit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxncommit"
> commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit"
> commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b"
> precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit"
> pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit"
> pretxncommit.tip = hg -q tip
> pre-identify = python "$TESTDIR/printenv.py" pre-identify 1
> pre-cat = python "$TESTDIR/printenv.py" pre-cat
> post-cat = python "$TESTDIR/printenv.py" post-cat
> pretxnopen = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnopen"
> pretxnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnclose"
> txnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnclose"
> pre-identify = printenv.py pre-identify 1
> pre-cat = printenv.py pre-cat
> post-cat = printenv.py post-cat
> pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen"
> pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose"
> txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose"
> txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
> txnabort.1 = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnabort"
> txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort"
> txnclose.checklock = sh -c "hg debuglock > /dev/null"
> EOF
$ echo a > a
@ -53,9 +53,9 @@ changegroup hooks can see env vars
$ cat > .hg/hgrc <<EOF
> [hooks]
> prechangegroup = python "$TESTDIR/printenv.py" prechangegroup
> changegroup = python "$TESTDIR/printenv.py" changegroup
> incoming = python "$TESTDIR/printenv.py" incoming
> prechangegroup = printenv.py prechangegroup
> changegroup = printenv.py changegroup
> incoming = printenv.py incoming
> EOF
pretxncommit and commit hooks can see both parents of merge
@ -128,8 +128,8 @@ tag hooks can see env vars
$ cd ../a
$ cat >> .hg/hgrc <<EOF
> pretag = python "$TESTDIR/printenv.py" pretag
> tag = sh -c "HG_PARENT1= HG_PARENT2= python \"$TESTDIR/printenv.py\" tag"
> pretag = printenv.py pretag
> tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag"
> EOF
$ hg tag -d '3 0' a
pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
@ -148,7 +148,7 @@ tag hooks can see env vars
pretag hook can forbid tagging
$ echo "pretag.forbid = python \"$TESTDIR/printenv.py\" pretag.forbid 1" >> .hg/hgrc
$ echo "pretag.forbid = 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
@ -164,7 +164,7 @@ pretxncommit hook can see changeset, can roll back txn, changeset no
more there after
$ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
$ echo "pretxncommit.forbid1 = python \"$TESTDIR/printenv.py\" pretxncommit.forbid 1" >> .hg/hgrc
$ echo "pretxncommit.forbid1 = printenv.py pretxncommit.forbid 1" >> .hg/hgrc
$ echo z > z
$ hg add z
$ hg -q tip
@ -202,7 +202,7 @@ more there after
precommit hook can prevent commit
$ echo "precommit.forbid = python \"$TESTDIR/printenv.py\" precommit.forbid 1" >> .hg/hgrc
$ echo "precommit.forbid = 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
@ -213,14 +213,14 @@ precommit hook can prevent commit
preupdate hook can prevent update
$ echo "preupdate = python \"$TESTDIR/printenv.py\" preupdate" >> .hg/hgrc
$ echo "preupdate = 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 \"$TESTDIR/printenv.py\" update" >> .hg/hgrc
$ echo "update = printenv.py update" >> .hg/hgrc
$ hg update
preupdate hook: HG_PARENT1=539e4b31b6dc
update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
@ -228,7 +228,7 @@ update hook
pushkey hook
$ echo "pushkey = python \"$TESTDIR/printenv.py\" pushkey" >> .hg/hgrc
$ echo "pushkey = printenv.py pushkey" >> .hg/hgrc
$ cd ../b
$ hg bookmark -r null foo
$ hg push -B foo ../a
@ -245,7 +245,7 @@ pushkey hook
listkeys hook
$ echo "listkeys = python \"$TESTDIR/printenv.py\" listkeys" >> .hg/hgrc
$ echo "listkeys = printenv.py listkeys" >> .hg/hgrc
$ hg bookmark -r null bar
$ cd ../b
$ hg pull -B bar ../a
@ -259,7 +259,7 @@ listkeys hook
test that prepushkey can prevent incoming keys
$ echo "prepushkey = python \"$TESTDIR/printenv.py\" prepushkey.forbid 1" >> .hg/hgrc
$ echo "prepushkey = printenv.py prepushkey.forbid 1" >> .hg/hgrc
$ cd ../b
$ hg bookmark -r null baz
$ hg push -B baz ../a
@ -280,7 +280,7 @@ test that prepushkey can prevent incoming keys
test that prelistkeys can prevent listing keys
$ echo "prelistkeys = python \"$TESTDIR/printenv.py\" prelistkeys.forbid 1" >> .hg/hgrc
$ echo "prelistkeys = printenv.py prelistkeys.forbid 1" >> .hg/hgrc
$ hg bookmark -r null quux
$ cd ../b
$ hg pull -B quux ../a
@ -298,7 +298,7 @@ prechangegroup hook can prevent incoming changes
3:07f3376c1e65
$ cat > .hg/hgrc <<EOF
> [hooks]
> prechangegroup.forbid = python "$TESTDIR/printenv.py" prechangegroup.forbid 1
> prechangegroup.forbid = printenv.py prechangegroup.forbid 1
> EOF
$ hg pull ../a
pulling from ../a
@ -313,7 +313,7 @@ incoming changes no longer there after
$ cat > .hg/hgrc <<EOF
> [hooks]
> pretxnchangegroup.forbid0 = hg tip -q
> pretxnchangegroup.forbid1 = python "$TESTDIR/printenv.py" pretxnchangegroup.forbid 1
> pretxnchangegroup.forbid1 = printenv.py pretxnchangegroup.forbid 1
> EOF
$ hg pull ../a
pulling from ../a
@ -336,8 +336,8 @@ outgoing hooks can see env vars
$ rm .hg/hgrc
$ cat > ../a/.hg/hgrc <<EOF
> [hooks]
> preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
> outgoing = python "$TESTDIR/printenv.py" outgoing
> preoutgoing = printenv.py preoutgoing
> outgoing = printenv.py outgoing
> EOF
$ hg pull ../a
pulling from ../a
@ -355,7 +355,7 @@ outgoing hooks can see env vars
preoutgoing hook can prevent outgoing changes
$ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> ../a/.hg/hgrc
$ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> ../a/.hg/hgrc
$ hg pull ../a
pulling from ../a
searching for changes
@ -369,8 +369,8 @@ outgoing hooks work for local clones
$ cd ..
$ cat > a/.hg/hgrc <<EOF
> [hooks]
> preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
> outgoing = python "$TESTDIR/printenv.py" outgoing
> preoutgoing = printenv.py preoutgoing
> outgoing = printenv.py outgoing
> EOF
$ hg clone a c
preoutgoing hook: HG_SOURCE=clone
@ -381,7 +381,7 @@ outgoing hooks work for local clones
preoutgoing hook can prevent outgoing changes for local clones
$ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> a/.hg/hgrc
$ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> a/.hg/hgrc
$ hg clone a zzz
preoutgoing hook: HG_SOURCE=clone
preoutgoing.forbid hook: HG_SOURCE=clone

View File

@ -128,7 +128,7 @@ pull
$ cd copy-pull
$ echo '[hooks]' >> .hg/hgrc
$ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc
$ echo "changegroup = printenv.py changegroup" >> .hg/hgrc
$ hg pull
pulling from http://localhost:$HGPORT1/
searching for changes

View File

@ -119,7 +119,7 @@ pull
$ cd copy-pull
$ echo '[hooks]' >> .hg/hgrc
$ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc
$ echo "changegroup = printenv.py changegroup" >> .hg/hgrc
$ hg pull
pulling from http://localhost:$HGPORT1/
searching for changes

View File

@ -201,7 +201,7 @@ pull without cacert
$ cd copy-pull
$ echo '[hooks]' >> .hg/hgrc
$ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc
$ echo "changegroup = printenv.py changegroup" >> .hg/hgrc
$ hg pull $DISABLEOSXDUMMYCERT
pulling from https://localhost:$HGPORT/
warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)

View File

@ -68,8 +68,8 @@ expect success
$ echo 'allow_push = *' >> .hg/hgrc
$ echo '[hooks]' >> .hg/hgrc
$ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup 0" >> .hg/hgrc
$ echo "pushkey = python \"$TESTDIR/printenv.py\" pushkey 0" >> .hg/hgrc
$ echo "changegroup = printenv.py changegroup 0" >> .hg/hgrc
$ echo "pushkey = printenv.py pushkey 0" >> .hg/hgrc
$ req
pushing to http://localhost:$HGPORT/
searching for changes
@ -121,7 +121,7 @@ expect push success, phase change failure
> push_ssl = false
> allow_push = *
> [hooks]
> prepushkey = python "$TESTDIR/printenv.py" prepushkey 1
> prepushkey = printenv.py prepushkey 1
> EOF
$ req
pushing to http://localhost:$HGPORT/
@ -134,7 +134,7 @@ expect push success, phase change failure
expect phase change success
$ echo "prepushkey = python \"$TESTDIR/printenv.py\" prepushkey 0" >> .hg/hgrc
$ echo "prepushkey = printenv.py prepushkey 0" >> .hg/hgrc
$ req
pushing to http://localhost:$HGPORT/
searching for changes

View File

@ -58,8 +58,8 @@ expect success
$ echo 'allow_push = *' >> .hg/hgrc
$ echo '[hooks]' >> .hg/hgrc
$ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup 0" >> .hg/hgrc
$ echo "pushkey = python \"$TESTDIR/printenv.py\" pushkey 0" >> .hg/hgrc
$ echo "changegroup = printenv.py changegroup 0" >> .hg/hgrc
$ echo "pushkey = printenv.py pushkey 0" >> .hg/hgrc
$ req
pushing to http://localhost:$HGPORT/
searching for changes
@ -114,7 +114,7 @@ expect push success, phase change failure
> push_ssl = false
> allow_push = *
> [hooks]
> prepushkey = python "$TESTDIR/printenv.py" prepushkey 1
> prepushkey = printenv.py prepushkey 1
> EOF
$ req
pushing to http://localhost:$HGPORT/
@ -130,7 +130,7 @@ expect push success, phase change failure
expect phase change success
$ echo "prepushkey = python \"$TESTDIR/printenv.py\" prepushkey 0" >> .hg/hgrc
$ echo "prepushkey = printenv.py prepushkey 0" >> .hg/hgrc
$ req
pushing to http://localhost:$HGPORT/
searching for changes

View File

@ -36,7 +36,7 @@ configure for serving
> uncompressed = True
>
> [hooks]
> changegroup = python "$TESTDIR/printenv.py" changegroup-in-remote 0 ../dummylog
> changegroup = printenv.py changegroup-in-remote 0 ../dummylog
> EOF
$ cd ..
@ -113,7 +113,7 @@ verify
checking files
2 files, 3 changesets, 2 total revisions
$ echo '[hooks]' >> .hg/hgrc
$ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup-in-local 0 ../dummylog" >> .hg/hgrc
$ echo "changegroup = printenv.py changegroup-in-local 0 ../dummylog" >> .hg/hgrc
empty default pull

View File

@ -27,7 +27,7 @@ configure for serving
> uncompressed = True
>
> [hooks]
> changegroup = python "$TESTDIR/printenv.py" changegroup-in-remote 0 ../dummylog
> changegroup = printenv.py changegroup-in-remote 0 ../dummylog
> EOF
$ cd ..
@ -104,7 +104,7 @@ verify
checking files
2 files, 3 changesets, 2 total revisions
$ echo '[hooks]' >> .hg/hgrc
$ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup-in-local 0 ../dummylog" >> .hg/hgrc
$ echo "changegroup = printenv.py changegroup-in-local 0 ../dummylog" >> .hg/hgrc
empty default pull

View File

@ -60,7 +60,7 @@ check for HTTP opener failures when cachefile does not exist
$ rm .hg/cache/*
$ cd ../local
$ echo '[hooks]' >> .hg/hgrc
$ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc
$ echo "changegroup = printenv.py changegroup" >> .hg/hgrc
$ hg pull
pulling from static-http://localhost:$HGPORT/remote
searching for changes