Patchwork [2,of,4] hook: add tests for failing post- python hooks

login
register
mail settings
Submitter Siddharth Agarwal
Date Feb. 12, 2016, 10:53 p.m.
Message ID <81e7825e881bac3132ac.1455317629@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/13164/
State Accepted
Headers show

Comments

Siddharth Agarwal - Feb. 12, 2016, 10:53 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1455306138 28800
#      Fri Feb 12 11:42:18 2016 -0800
# Node ID 81e7825e881bac3132ac3d89ed4d4a6988685c6f
# Parent  b1c91852db57b1647eb4adc8dde0ecae9f258158
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 81e7825e881b
hook: add tests for failing post- python hooks

I couldn't find any tests for this.

Patch

diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -532,6 +532,45 @@  test python hooks
   adding remote bookmark quux
   (run 'hg update' to get a working copy)
 
+post- python hooks that fail to *run* don't cause an abort
+  $ rm ../a/.hg/hgrc
+  $ echo '[hooks]' > .hg/hgrc
+  $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
+  $ hg pull ../a
+  pulling from ../a
+  searching for changes
+  no changes found
+  error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
+
+but post- python hooks that fail to *load* do
+  $ echo '[hooks]' > .hg/hgrc
+  $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
+  $ hg pull ../a
+  pulling from ../a
+  searching for changes
+  no changes found
+  abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
+  [255]
+
+  $ echo '[hooks]' > .hg/hgrc
+  $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
+  $ hg pull ../a
+  pulling from ../a
+  searching for changes
+  no changes found
+  abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
+  (run with --traceback for stack trace)
+  [255]
+
+  $ echo '[hooks]' > .hg/hgrc
+  $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
+  $ hg pull ../a
+  pulling from ../a
+  searching for changes
+  no changes found
+  abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
+  [255]
+
 make sure --traceback works
 
   $ echo '[hooks]' > .hg/hgrc