Patchwork [2,of,9,v2] atexit: test failing handlers

login
register
mail settings
Submitter Bryan O'Sullivan
Date April 14, 2017, 4:29 a.m.
Message ID <b35bc05e7a695ed8cdfd.1492144180@jsdf-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/20186/
State Accepted
Headers show

Comments

Bryan O'Sullivan - April 14, 2017, 4:29 a.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1491947652 25200
#      Tue Apr 11 14:54:12 2017 -0700
# Node ID b35bc05e7a695ed8cdfd809070965ef9ea9266f9
# Parent  f3a5157b39b32245b0bbcb9d7ac3ce7d9cbefde3
atexit: test failing handlers

Patch

diff --git a/tests/test-bad-extension.t b/tests/test-bad-extension.t
--- a/tests/test-bad-extension.t
+++ b/tests/test-bad-extension.t
@@ -1,3 +1,31 @@ 
+ensure that failing ui.atexit handlers report sensibly
+
+  $ cat > $TESTTMP/bailatexit.py <<EOF
+  > from mercurial import util
+  > def bail():
+  >     raise RuntimeError('ui.atexit handler exception')
+  > 
+  > def extsetup(ui):
+  >     ui.atexit(bail)
+  > EOF
+  $ hg -q --config extensions.bailatexit=$TESTTMP/bailatexit.py \
+  >  help help
+  hg help [-ecks] [TOPIC]
+  
+  show help for a given topic or a help overview
+  error in exit handlers:
+  Traceback (most recent call last):
+    File "*/mercurial/dispatch.py", line *, in _runexithandlers (glob)
+      func(*args, **kwargs)
+    File "$TESTTMP/bailatexit.py", line *, in bail (glob)
+      raise RuntimeError('ui.atexit handler exception')
+  RuntimeError: ui.atexit handler exception
+  [255]
+
+  $ rm $TESTTMP/bailatexit.py
+
+another bad extension
+
   $ echo 'raise Exception("bit bucket overflow")' > badext.py
   $ abspathexc=`pwd`/badext.py