Patchwork [1,of,2,v2] tests: add test demonstrating how broken third-party extensions can get

login
register
mail settings
Submitter Augie Fackler
Date June 8, 2017, 3:04 p.m.
Message ID <bf999f47f7deff5a53e4.1496934243@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/21249/
State Superseded
Headers show

Comments

Augie Fackler - June 8, 2017, 3:04 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1496757796 14400
#      Tue Jun 06 10:03:16 2017 -0400
# Node ID bf999f47f7deff5a53e4eea18c22465ec738dd31
# Parent  04c19c8082410049465e2cdc510e24801530c94b
tests: add test demonstrating how broken third-party extensions can get

I intend to fix this, but will do the fix as a separate change to make
the behavior change obvious. This was inspired by some users having
the patience diff extension, which broke when we moved bdiff.so so
thoroughly the users can't even run 'hg debuginstall'.

Patch

diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -1606,3 +1606,28 @@  Show deprecation warning for the use of 
   $ hg --config extensions.nonregistrar=`pwd`/nonregistrar.py version > /dev/null
   devel-warn: cmdutil.command is deprecated, use registrar.command to register 'foo'
   (compatibility will be dropped after Mercurial-4.6, update your code.) * (glob)
+
+Make sure a broken uisetup doesn't globally break hg:
+  $ cat > baduisetup.py <<EOF
+  > from mercurial import (
+  >     bdiff,
+  >     extensions,
+  > )
+  > 
+  > def blockswrapper(orig, *args, **kwargs):
+  >     return orig(*args, **kwargs)
+  > 
+  > def uisetup(ui):
+  >     extensions.wrapfunction(bdiff, 'blocks', blockswrapper)
+  > EOF
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > baduisetup = $PWD/baduisetup.py
+  > EOF
+
+Broken: an extension that triggers the import of bdiff during uisetup
+can't be easily debugged:
+  $ hg version
+  abort: No module named bdiff!
+  (did you forget to compile extensions?)
+  [255]