Mercurial > hg-stable
changeset 33957:9d5d040160e6
tests: move baduisetup test inside "#if demandimport"
The test case depends on the failure happening not at import time, but
at uisetup() time, so it doesn't make sense when demandimport is
disabled.
There was already a section for testing demandimport stuff, so I moved
it inside that existing section. As part of the move, I enabled the
extension using '--config' so subsequent tests don't get the bad
extension enabled.
Differential Revision: https://phab.mercurial-scm.org/D526
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sat, 26 Aug 2017 16:00:07 -0700 |
parents | 9180f8f593f3 |
children | 2a37459aedf2 |
files | tests/test-extension.t |
diffstat | 1 files changed, 47 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-extension.t Fri Aug 25 15:50:07 2017 -0700 +++ b/tests/test-extension.t Sat Aug 26 16:00:07 2017 -0700 @@ -510,6 +510,53 @@ $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity) +Make sure a broken uisetup doesn't globally break hg: + $ cat > $TESTTMP/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 + +Even though the extension fails during uisetup, hg is still basically usable: + $ hg --config extensions.baduisetup=$TESTTMP/baduisetup.py version + \*\*\* failed to set up extension baduisetup: No module named (mercurial\.)?bdiff (re) + Mercurial Distributed SCM (version *) (glob) + (see https://mercurial-scm.org for more information) + + Copyright (C) 2005-2017 Matt Mackall and others + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + $ hg --config extensions.baduisetup=$TESTTMP/baduisetup.py version --traceback + Traceback (most recent call last): + File "*/mercurial/extensions.py", line *, in _runuisetup (glob) + uisetup(ui) + File "$TESTTMP/baduisetup.py", line 10, in uisetup + extensions.wrapfunction(bdiff, 'blocks', blockswrapper) + File "*/mercurial/extensions.py", line *, in wrapfunction (glob) + origfn = getattr(container, funcname) + File "*/hgdemandimport/demandimportpy2.py", line *, in __getattr__ (glob) + self._load() + File "*/hgdemandimport/demandimportpy2.py", line *, in _load (glob) + mod = _hgextimport(_origimport, head, globals, locals, None, level) + File "*/hgdemandimport/demandimportpy2.py", line *, in _hgextimport (glob) + return importfunc(name, globals, *args, **kwargs) + ImportError: No module named (mercurial\.)?bdiff (re) + \*\*\* failed to set up extension baduisetup: No module named (mercurial\.)?bdiff (re) + Mercurial Distributed SCM (version *) (glob) + (see https://mercurial-scm.org for more information) + + Copyright (C) 2005-2017 Matt Mackall and others + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + #endif $ cd .. @@ -1662,54 +1709,3 @@ $ 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 > $TESTTMP/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 = $TESTTMP/baduisetup.py - > EOF - -Even though the extension fails during uisetup, hg is still basically usable: - $ hg version - \*\*\* failed to set up extension baduisetup: No module named (mercurial\.)?bdiff (re) - Mercurial Distributed SCM (version *) (glob) - (see https://mercurial-scm.org for more information) - - Copyright (C) 2005-2017 Matt Mackall and others - This is free software; see the source for copying conditions. There is NO - warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - $ hg version --traceback - Traceback (most recent call last): - File "*/mercurial/extensions.py", line *, in _runuisetup (glob) - uisetup(ui) - File "$TESTTMP/baduisetup.py", line 10, in uisetup - extensions.wrapfunction(bdiff, 'blocks', blockswrapper) - File "*/mercurial/extensions.py", line *, in wrapfunction (glob) - origfn = getattr(container, funcname) - File "*/hgdemandimport/demandimportpy2.py", line *, in __getattr__ (glob) - self._load() - File "*/hgdemandimport/demandimportpy2.py", line *, in _load (glob) - mod = _hgextimport(_origimport, head, globals, locals, None, level) - File "*/hgdemandimport/demandimportpy2.py", line *, in _hgextimport (glob) - return importfunc(name, globals, *args, **kwargs) - ImportError: No module named (mercurial\.)?bdiff (re) - \*\*\* failed to set up extension baduisetup: No module named (mercurial\.)?bdiff (re) - Mercurial Distributed SCM (version *) (glob) - (see https://mercurial-scm.org for more information) - - Copyright (C) 2005-2017 Matt Mackall and others - This is free software; see the source for copying conditions. There is NO - warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.