tests: add tests for remote hook output (issue4788) stable
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 24 Oct 2015 00:39:26 +0100
branchstable
changeset 28016 00e75baa810f5e42080d7c2dd826dadc1a22d4c4
parent 28015 a9ed5a8fc5e0554d5cb81b7206d2203cc49a2d23
child 28017 58f1645f72c3cd48191e1b8da412a5ddf31541c1
push id48
push usergszorc@mozilla.com
push dateWed, 04 Nov 2015 20:44:50 +0000
tests: add tests for remote hook output (issue4788) The added tests don't agree in their output. This demonstrates a difference in `hg push` behavior between pre-bundle2 and bundle2. A subsequent patch will attempt to restore some of the pre-bundle2 behavior to bundle2.
tests/test-ssh-bundle1.t
tests/test-ssh.t
--- a/tests/test-ssh-bundle1.t
+++ b/tests/test-ssh-bundle1.t
@@ -505,8 +505,36 @@ debug output
   Got arguments 1:user@dummy 2:hg init 'a repo'
   Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
   Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
   Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
   Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
   Got arguments 1:user@dummy 2:hg -R remote serve --stdio
   changegroup-in-remote hook: HG_NODE=65c38f4125f9602c8db4af56530cc221d93b8ef8 HG_SOURCE=serve HG_TXNID=TXN:* HG_URL=remote:ssh:127.0.0.1 (glob)
   Got arguments 1:user@dummy 2:hg -R remote serve --stdio
+
+remote hook failure is attributed to remote
+
+  $ cat > $TESTTMP/failhook << EOF
+  > def hook(ui, repo, **kwargs):
+  >     ui.write('hook failure!\n')
+  >     ui.flush()
+  >     return 1
+  > EOF
+
+  $ echo "pretxnchangegroup.fail = python:$TESTTMP/failhook:hook" >> remote/.hg/hgrc
+
+  $ hg -q --config ui.ssh="python '$TESTDIR/dummyssh'" clone ssh://user@dummy/remote hookout
+  $ cd hookout
+  $ touch hookfailure
+  $ hg -q commit -A -m 'remote hook failure'
+  $ hg --config ui.ssh="python '$TESTDIR/dummyssh'" push
+  pushing to ssh://user@dummy/remote
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: hook failure!transaction abort!
+  remote: rollback completed
+  remote: abort: pretxnchangegroup.fail hook failed
+  [1]
+
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -496,8 +496,37 @@ debug output
   Got arguments 1:user@dummy 2:hg init 'a repo'
   Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
   Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
   Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
   Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
   Got arguments 1:user@dummy 2:hg -R remote serve --stdio
   changegroup-in-remote hook: HG_BUNDLE2=1 HG_NODE=65c38f4125f9602c8db4af56530cc221d93b8ef8 HG_SOURCE=serve HG_TXNID=TXN:* HG_URL=remote:ssh:127.0.0.1 (glob)
   Got arguments 1:user@dummy 2:hg -R remote serve --stdio
+
+remote hook failure is attributed to remote
+
+  $ cat > $TESTTMP/failhook << EOF
+  > def hook(ui, repo, **kwargs):
+  >     ui.write('hook failure!\n')
+  >     ui.flush()
+  >     return 1
+  > EOF
+
+  $ echo "pretxnchangegroup.fail = python:$TESTTMP/failhook:hook" >> remote/.hg/hgrc
+
+  $ hg -q --config ui.ssh="python '$TESTDIR/dummyssh'" clone ssh://user@dummy/remote hookout
+  $ cd hookout
+  $ touch hookfailure
+  $ hg -q commit -A -m 'remote hook failure'
+  $ hg --config ui.ssh="python '$TESTDIR/dummyssh'" push
+  pushing to ssh://user@dummy/remote
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: hook failure!
+  remote: transaction abort!
+  remote: rollback completed
+  abort: pretxnchangegroup.fail hook failed
+  [255]
+