tests/test-extension.t
changeset 40206 37295cee1a15
parent 40205 89ba51c3e4f1
child 40263 8cf459d8b111
equal deleted inserted replaced
40205:89ba51c3e4f1 40206:37295cee1a15
   185   $ echo 'foo = !' >> $HGRCPATH
   185   $ echo 'foo = !' >> $HGRCPATH
   186   $ echo 'bar = !' >> $HGRCPATH
   186   $ echo 'bar = !' >> $HGRCPATH
   187 
   187 
   188 Check "from __future__ import absolute_import" support for external libraries
   188 Check "from __future__ import absolute_import" support for external libraries
   189 
   189 
       
   190 (import-checker.py reports issues for some of heredoc python code
       
   191 fragments below, because import-checker.py does not know test specific
       
   192 package hierarchy. NO_CHECK_* should be used as a limit mark of
       
   193 heredoc, in order to make import-checker.py ignore them. For
       
   194 simplicity, all python code fragments below are generated with such
       
   195 limit mark, regardless of importing module or not.)
       
   196 
   190 #if windows
   197 #if windows
   191   $ PATHSEP=";"
   198   $ PATHSEP=";"
   192 #else
   199 #else
   193   $ PATHSEP=":"
   200   $ PATHSEP=":"
   194 #endif
   201 #endif
   198   $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
   205   $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
   199   $ mkdir $TESTTMP/libroot/mod
   206   $ mkdir $TESTTMP/libroot/mod
   200   $ touch $TESTTMP/libroot/mod/__init__.py
   207   $ touch $TESTTMP/libroot/mod/__init__.py
   201   $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
   208   $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
   202 
   209 
   203   $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
   210   $ cat > $TESTTMP/libroot/mod/ambigabs.py <<NO_CHECK_EOF
   204   > from __future__ import absolute_import, print_function
   211   > from __future__ import absolute_import, print_function
   205   > import ambig # should load "libroot/ambig.py"
   212   > import ambig # should load "libroot/ambig.py"
   206   > s = ambig.s
   213   > s = ambig.s
   207   > EOF
   214   > NO_CHECK_EOF
   208   $ cat > loadabs.py <<EOF
   215   $ cat > loadabs.py <<NO_CHECK_EOF
   209   > import mod.ambigabs as ambigabs
   216   > import mod.ambigabs as ambigabs
   210   > def extsetup():
   217   > def extsetup():
   211   >     print('ambigabs.s=%s' % ambigabs.s, flush=True)
   218   >     print('ambigabs.s=%s' % ambigabs.s, flush=True)
   212   > EOF
   219   > NO_CHECK_EOF
   213   $ $PYTHON $TESTTMP/unflush.py loadabs.py
   220   $ $PYTHON $TESTTMP/unflush.py loadabs.py
   214   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
   221   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
   215   ambigabs.s=libroot/ambig.py
   222   ambigabs.s=libroot/ambig.py
   216   $TESTTMP/a
   223   $TESTTMP/a
   217 
   224 
   218 #if no-py3k
   225 #if no-py3k
   219   $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
   226   $ cat > $TESTTMP/libroot/mod/ambigrel.py <<NO_CHECK_EOF
   220   > from __future__ import print_function
   227   > from __future__ import print_function
   221   > import ambig # should load "libroot/mod/ambig.py"
   228   > import ambig # should load "libroot/mod/ambig.py"
   222   > s = ambig.s
   229   > s = ambig.s
   223   > EOF
   230   > NO_CHECK_EOF
   224   $ cat > loadrel.py <<EOF
   231   $ cat > loadrel.py <<NO_CHECK_EOF
   225   > import mod.ambigrel as ambigrel
   232   > import mod.ambigrel as ambigrel
   226   > def extsetup():
   233   > def extsetup():
   227   >     print('ambigrel.s=%s' % ambigrel.s, flush=True)
   234   >     print('ambigrel.s=%s' % ambigrel.s, flush=True)
   228   > EOF
   235   > NO_CHECK_EOF
   229   $ $PYTHON $TESTTMP/unflush.py loadrel.py
   236   $ $PYTHON $TESTTMP/unflush.py loadrel.py
   230   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
   237   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
   231   ambigrel.s=libroot/mod/ambig.py
   238   ambigrel.s=libroot/mod/ambig.py
   232   $TESTTMP/a
   239   $TESTTMP/a
   233 #endif
   240 #endif
   234 
   241 
   235 Check absolute/relative import of extension specific modules
   242 Check absolute/relative import of extension specific modules
   236 
   243 
   237   $ mkdir $TESTTMP/extroot
   244   $ mkdir $TESTTMP/extroot
   238   $ cat > $TESTTMP/extroot/bar.py <<EOF
   245   $ cat > $TESTTMP/extroot/bar.py <<NO_CHECK_EOF
   239   > s = b'this is extroot.bar'
   246   > s = b'this is extroot.bar'
   240   > EOF
   247   > NO_CHECK_EOF
   241   $ mkdir $TESTTMP/extroot/sub1
   248   $ mkdir $TESTTMP/extroot/sub1
   242   $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
   249   $ cat > $TESTTMP/extroot/sub1/__init__.py <<NO_CHECK_EOF
   243   > s = b'this is extroot.sub1.__init__'
   250   > s = b'this is extroot.sub1.__init__'
   244   > EOF
   251   > NO_CHECK_EOF
   245   $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
   252   $ cat > $TESTTMP/extroot/sub1/baz.py <<NO_CHECK_EOF
   246   > s = b'this is extroot.sub1.baz'
   253   > s = b'this is extroot.sub1.baz'
   247   > EOF
   254   > NO_CHECK_EOF
   248   $ cat > $TESTTMP/extroot/__init__.py <<EOF
   255   $ cat > $TESTTMP/extroot/__init__.py <<NO_CHECK_EOF
   249   > from __future__ import absolute_import
   256   > from __future__ import absolute_import
   250   > s = b'this is extroot.__init__'
   257   > s = b'this is extroot.__init__'
   251   > from . import foo
   258   > from . import foo
   252   > def extsetup(ui):
   259   > def extsetup(ui):
   253   >     ui.write(b'(extroot) ', foo.func(), b'\n')
   260   >     ui.write(b'(extroot) ', foo.func(), b'\n')
   254   >     ui.flush()
   261   >     ui.flush()
   255   > EOF
   262   > NO_CHECK_EOF
   256 
   263 
   257   $ cat > $TESTTMP/extroot/foo.py <<EOF
   264   $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
   258   > # test absolute import
   265   > # test absolute import
   259   > buf = []
   266   > buf = []
   260   > def func():
   267   > def func():
   261   >     # "not locals" case
   268   >     # "not locals" case
   262   >     import extroot.bar
   269   >     import extroot.bar
   272   > import extroot
   279   > import extroot
   273   > buf.append(b'import extroot: %s' % extroot.s)
   280   > buf.append(b'import extroot: %s' % extroot.s)
   274   > # NOT "not fromlist" and NOT "level != -1" case
   281   > # NOT "not fromlist" and NOT "level != -1" case
   275   > from extroot.bar import s
   282   > from extroot.bar import s
   276   > buf.append(b'from extroot.bar import s: %s' % s)
   283   > buf.append(b'from extroot.bar import s: %s' % s)
   277   > EOF
   284   > NO_CHECK_EOF
   278   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
   285   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
   279   (extroot) from extroot.bar import *: this is extroot.bar
   286   (extroot) from extroot.bar import *: this is extroot.bar
   280   (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
   287   (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
   281   (extroot) import extroot: this is extroot.__init__
   288   (extroot) import extroot: this is extroot.__init__
   282   (extroot) from extroot.bar import s: this is extroot.bar
   289   (extroot) from extroot.bar import s: this is extroot.bar
   284   $TESTTMP/a
   291   $TESTTMP/a
   285 
   292 
   286 #if no-py3k
   293 #if no-py3k
   287   $ rm "$TESTTMP"/extroot/foo.*
   294   $ rm "$TESTTMP"/extroot/foo.*
   288   $ rm -Rf "$TESTTMP/extroot/__pycache__"
   295   $ rm -Rf "$TESTTMP/extroot/__pycache__"
   289   $ cat > $TESTTMP/extroot/foo.py <<EOF
   296   $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
   290   > # test relative import
   297   > # test relative import
   291   > buf = []
   298   > buf = []
   292   > def func():
   299   > def func():
   293   >     # "not locals" case
   300   >     # "not locals" case
   294   >     import bar
   301   >     import bar
   304   > import sub1
   311   > import sub1
   305   > buf.append('import sub1: %s' % sub1.s)
   312   > buf.append('import sub1: %s' % sub1.s)
   306   > # NOT "not fromlist" and NOT "level != -1" case
   313   > # NOT "not fromlist" and NOT "level != -1" case
   307   > from bar import s
   314   > from bar import s
   308   > buf.append('from bar import s: %s' % s)
   315   > buf.append('from bar import s: %s' % s)
   309   > EOF
   316   > NO_CHECK_EOF
   310   $ hg --config extensions.extroot=$TESTTMP/extroot root
   317   $ hg --config extensions.extroot=$TESTTMP/extroot root
   311   (extroot) from bar import *: this is extroot.bar
   318   (extroot) from bar import *: this is extroot.bar
   312   (extroot) import sub1.baz: this is extroot.sub1.baz
   319   (extroot) import sub1.baz: this is extroot.sub1.baz
   313   (extroot) import sub1: this is extroot.sub1.__init__
   320   (extroot) import sub1: this is extroot.sub1.__init__
   314   (extroot) from bar import s: this is extroot.bar
   321   (extroot) from bar import s: this is extroot.bar
   336   $ mkdir -p $TESTTMP/extlibroot/lsub1/lsub2
   343   $ mkdir -p $TESTTMP/extlibroot/lsub1/lsub2
   337   $ touch $TESTTMP/extlibroot/__init__.py
   344   $ touch $TESTTMP/extlibroot/__init__.py
   338   $ touch $TESTTMP/extlibroot/lsub1/__init__.py
   345   $ touch $TESTTMP/extlibroot/lsub1/__init__.py
   339   $ touch $TESTTMP/extlibroot/lsub1/lsub2/__init__.py
   346   $ touch $TESTTMP/extlibroot/lsub1/lsub2/__init__.py
   340 
   347 
   341   $ cat > $TESTTMP/extlibroot/lsub1/lsub2/called.py <<EOF
   348   $ cat > $TESTTMP/extlibroot/lsub1/lsub2/called.py <<NO_CHECK_EOF
   342   > def func():
   349   > def func():
   343   >     return b"this is extlibroot.lsub1.lsub2.called.func()"
   350   >     return b"this is extlibroot.lsub1.lsub2.called.func()"
   344   > EOF
   351   > NO_CHECK_EOF
   345   $ cat > $TESTTMP/extlibroot/lsub1/lsub2/unused.py <<EOF
   352   $ cat > $TESTTMP/extlibroot/lsub1/lsub2/unused.py <<NO_CHECK_EOF
   346   > raise Exception("extlibroot.lsub1.lsub2.unused is loaded unintentionally")
   353   > raise Exception("extlibroot.lsub1.lsub2.unused is loaded unintentionally")
   347   > EOF
   354   > NO_CHECK_EOF
   348   $ cat > $TESTTMP/extlibroot/lsub1/lsub2/used.py <<EOF
   355   $ cat > $TESTTMP/extlibroot/lsub1/lsub2/used.py <<NO_CHECK_EOF
   349   > detail = b"this is extlibroot.lsub1.lsub2.used"
   356   > detail = b"this is extlibroot.lsub1.lsub2.used"
   350   > EOF
   357   > NO_CHECK_EOF
   351 
   358 
   352 Setup sub-package of "external library", which causes instantiation of
   359 Setup sub-package of "external library", which causes instantiation of
   353 demandmod in "recurse down the module chain" code path. Relative
   360 demandmod in "recurse down the module chain" code path. Relative
   354 importing with "absolute_import" feature isn't tested, because "level
   361 importing with "absolute_import" feature isn't tested, because "level
   355 >=1 " doesn't cause instantiation of demandmod.
   362 >=1 " doesn't cause instantiation of demandmod.
   356 
   363 
   357   $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
   364   $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
   358   $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<EOF
   365   $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<NO_CHECK_EOF
   359   > detail = b"this is extlibroot.recursedown.abs.used"
   366   > detail = b"this is extlibroot.recursedown.abs.used"
   360   > EOF
   367   > NO_CHECK_EOF
   361   $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<EOF
   368   $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<NO_CHECK_EOF
   362   > from __future__ import absolute_import
   369   > from __future__ import absolute_import
   363   > from extlibroot.recursedown.abs.used import detail
   370   > from extlibroot.recursedown.abs.used import detail
   364   > EOF
   371   > NO_CHECK_EOF
   365 
   372 
   366   $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
   373   $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
   367   $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<EOF
   374   $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<NO_CHECK_EOF
   368   > detail = b"this is extlibroot.recursedown.legacy.used"
   375   > detail = b"this is extlibroot.recursedown.legacy.used"
   369   > EOF
   376   > NO_CHECK_EOF
   370   $ cat > $TESTTMP/extlibroot/recursedown/legacy/__init__.py <<EOF
   377   $ cat > $TESTTMP/extlibroot/recursedown/legacy/__init__.py <<NO_CHECK_EOF
   371   > # legacy style (level == -1) import
   378   > # legacy style (level == -1) import
   372   > from extlibroot.recursedown.legacy.used import detail
   379   > from extlibroot.recursedown.legacy.used import detail
   373   > EOF
   380   > NO_CHECK_EOF
   374 
   381 
   375   $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<EOF
   382   $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<NO_CHECK_EOF
   376   > from __future__ import absolute_import
   383   > from __future__ import absolute_import
   377   > from extlibroot.recursedown.abs import detail as absdetail
   384   > from extlibroot.recursedown.abs import detail as absdetail
   378   > from .legacy import detail as legacydetail
   385   > from .legacy import detail as legacydetail
   379   > EOF
   386   > NO_CHECK_EOF
   380 
   387 
   381 Setup package that re-exports an attribute of its submodule as the same
   388 Setup package that re-exports an attribute of its submodule as the same
   382 name. This leaves 'shadowing.used' pointing to 'used.detail', but still
   389 name. This leaves 'shadowing.used' pointing to 'used.detail', but still
   383 the submodule 'used' should be somehow accessible. (issue5617)
   390 the submodule 'used' should be somehow accessible. (issue5617)
   384 
   391 
   385   $ mkdir -p $TESTTMP/extlibroot/shadowing
   392   $ mkdir -p $TESTTMP/extlibroot/shadowing
   386   $ cat > $TESTTMP/extlibroot/shadowing/used.py <<EOF
   393   $ cat > $TESTTMP/extlibroot/shadowing/used.py <<NO_CHECK_EOF
   387   > detail = b"this is extlibroot.shadowing.used"
   394   > detail = b"this is extlibroot.shadowing.used"
   388   > EOF
   395   > NO_CHECK_EOF
   389   $ cat > $TESTTMP/extlibroot/shadowing/proxied.py <<EOF
   396   $ cat > $TESTTMP/extlibroot/shadowing/proxied.py <<NO_CHECK_EOF
   390   > from __future__ import absolute_import
   397   > from __future__ import absolute_import
   391   > from extlibroot.shadowing.used import detail
   398   > from extlibroot.shadowing.used import detail
   392   > EOF
   399   > NO_CHECK_EOF
   393   $ cat > $TESTTMP/extlibroot/shadowing/__init__.py <<EOF
   400   $ cat > $TESTTMP/extlibroot/shadowing/__init__.py <<NO_CHECK_EOF
   394   > from __future__ import absolute_import
   401   > from __future__ import absolute_import
   395   > from .used import detail as used
   402   > from .used import detail as used
   396   > EOF
   403   > NO_CHECK_EOF
   397 
   404 
   398 Setup extension local modules to be imported with "absolute_import"
   405 Setup extension local modules to be imported with "absolute_import"
   399 feature.
   406 feature.
   400 
   407 
   401   $ mkdir -p $TESTTMP/absextroot/xsub1/xsub2
   408   $ mkdir -p $TESTTMP/absextroot/xsub1/xsub2
   402   $ touch $TESTTMP/absextroot/xsub1/__init__.py
   409   $ touch $TESTTMP/absextroot/xsub1/__init__.py
   403   $ touch $TESTTMP/absextroot/xsub1/xsub2/__init__.py
   410   $ touch $TESTTMP/absextroot/xsub1/xsub2/__init__.py
   404 
   411 
   405   $ cat > $TESTTMP/absextroot/xsub1/xsub2/called.py <<EOF
   412   $ cat > $TESTTMP/absextroot/xsub1/xsub2/called.py <<NO_CHECK_EOF
   406   > def func():
   413   > def func():
   407   >     return b"this is absextroot.xsub1.xsub2.called.func()"
   414   >     return b"this is absextroot.xsub1.xsub2.called.func()"
   408   > EOF
   415   > NO_CHECK_EOF
   409   $ cat > $TESTTMP/absextroot/xsub1/xsub2/unused.py <<EOF
   416   $ cat > $TESTTMP/absextroot/xsub1/xsub2/unused.py <<NO_CHECK_EOF
   410   > raise Exception("absextroot.xsub1.xsub2.unused is loaded unintentionally")
   417   > raise Exception("absextroot.xsub1.xsub2.unused is loaded unintentionally")
   411   > EOF
   418   > NO_CHECK_EOF
   412   $ cat > $TESTTMP/absextroot/xsub1/xsub2/used.py <<EOF
   419   $ cat > $TESTTMP/absextroot/xsub1/xsub2/used.py <<NO_CHECK_EOF
   413   > detail = b"this is absextroot.xsub1.xsub2.used"
   420   > detail = b"this is absextroot.xsub1.xsub2.used"
   414   > EOF
   421   > NO_CHECK_EOF
   415 
   422 
   416 Setup extension local modules to examine whether demand importing
   423 Setup extension local modules to examine whether demand importing
   417 works as expected in "level > 1" case.
   424 works as expected in "level > 1" case.
   418 
   425 
   419   $ cat > $TESTTMP/absextroot/relimportee.py <<EOF
   426   $ cat > $TESTTMP/absextroot/relimportee.py <<NO_CHECK_EOF
   420   > detail = b"this is absextroot.relimportee"
   427   > detail = b"this is absextroot.relimportee"
   421   > EOF
   428   > NO_CHECK_EOF
   422   $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<EOF
   429   $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<NO_CHECK_EOF
   423   > from __future__ import absolute_import
   430   > from __future__ import absolute_import
   424   > from mercurial import pycompat
   431   > from mercurial import pycompat
   425   > from ... import relimportee
   432   > from ... import relimportee
   426   > detail = b"this relimporter imports %r" % (
   433   > detail = b"this relimporter imports %r" % (
   427   >     pycompat.bytestr(relimportee.detail))
   434   >     pycompat.bytestr(relimportee.detail))
   428   > EOF
   435   > NO_CHECK_EOF
   429 
   436 
   430 Setup modules, which actually import extension local modules at
   437 Setup modules, which actually import extension local modules at
   431 runtime.
   438 runtime.
   432 
   439 
   433   $ cat > $TESTTMP/absextroot/absolute.py << EOF
   440   $ cat > $TESTTMP/absextroot/absolute.py << NO_CHECK_EOF
   434   > from __future__ import absolute_import
   441   > from __future__ import absolute_import
   435   > 
   442   > 
   436   > # import extension local modules absolutely (level = 0)
   443   > # import extension local modules absolutely (level = 0)
   437   > from absextroot.xsub1.xsub2 import used, unused
   444   > from absextroot.xsub1.xsub2 import used, unused
   438   > from absextroot.xsub1.xsub2.called import func
   445   > from absextroot.xsub1.xsub2.called import func
   440   > def getresult():
   447   > def getresult():
   441   >     result = []
   448   >     result = []
   442   >     result.append(used.detail)
   449   >     result.append(used.detail)
   443   >     result.append(func())
   450   >     result.append(func())
   444   >     return result
   451   >     return result
   445   > EOF
   452   > NO_CHECK_EOF
   446 
   453 
   447   $ cat > $TESTTMP/absextroot/relative.py << EOF
   454   $ cat > $TESTTMP/absextroot/relative.py << NO_CHECK_EOF
   448   > from __future__ import absolute_import
   455   > from __future__ import absolute_import
   449   > 
   456   > 
   450   > # import extension local modules relatively (level == 1)
   457   > # import extension local modules relatively (level == 1)
   451   > from .xsub1.xsub2 import used, unused
   458   > from .xsub1.xsub2 import used, unused
   452   > from .xsub1.xsub2.called import func
   459   > from .xsub1.xsub2.called import func
   458   >     result = []
   465   >     result = []
   459   >     result.append(used.detail)
   466   >     result.append(used.detail)
   460   >     result.append(func())
   467   >     result.append(func())
   461   >     result.append(relimporter.detail)
   468   >     result.append(relimporter.detail)
   462   >     return result
   469   >     return result
   463   > EOF
   470   > NO_CHECK_EOF
   464 
   471 
   465 Setup main procedure of extension.
   472 Setup main procedure of extension.
   466 
   473 
   467   $ cat > $TESTTMP/absextroot/__init__.py <<EOF
   474   $ cat > $TESTTMP/absextroot/__init__.py <<NO_CHECK_EOF
   468   > from __future__ import absolute_import
   475   > from __future__ import absolute_import
   469   > from mercurial import registrar
   476   > from mercurial import registrar
   470   > cmdtable = {}
   477   > cmdtable = {}
   471   > command = registrar.command(cmdtable)
   478   > command = registrar.command(cmdtable)
   472   > 
   479   > 
   497   >     result.append(lfunc())
   504   >     result.append(lfunc())
   498   >     result.append(absdetail)
   505   >     result.append(absdetail)
   499   >     result.append(legacydetail)
   506   >     result.append(legacydetail)
   500   >     result.append(proxied.detail)
   507   >     result.append(proxied.detail)
   501   >     ui.write(b'LIB: %s\n' % b'\nLIB: '.join(result))
   508   >     ui.write(b'LIB: %s\n' % b'\nLIB: '.join(result))
   502   > EOF
   509   > NO_CHECK_EOF
   503 
   510 
   504 Examine module importing.
   511 Examine module importing.
   505 
   512 
   506   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
   513   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
   507   LIB: this is extlibroot.lsub1.lsub2.used
   514   LIB: this is extlibroot.lsub1.lsub2.used
   527 See also issue5208 for detail about example case on Python 3.x.
   534 See also issue5208 for detail about example case on Python 3.x.
   528 
   535 
   529   $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py
   536   $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py
   530   $TESTTMP/extlibroot/lsub1/lsub2/notexist.py: file not found
   537   $TESTTMP/extlibroot/lsub1/lsub2/notexist.py: file not found
   531 
   538 
   532   $ cat > $TESTTMP/notexist.py <<EOF
   539   $ cat > $TESTTMP/notexist.py <<NO_CHECK_EOF
   533   > text = 'notexist.py at root is loaded unintentionally\n'
   540   > text = 'notexist.py at root is loaded unintentionally\n'
   534   > EOF
   541   > NO_CHECK_EOF
   535 
   542 
   536   $ cat > $TESTTMP/checkrelativity.py <<EOF
   543   $ cat > $TESTTMP/checkrelativity.py <<NO_CHECK_EOF
   537   > from mercurial import registrar
   544   > from mercurial import registrar
   538   > cmdtable = {}
   545   > cmdtable = {}
   539   > command = registrar.command(cmdtable)
   546   > command = registrar.command(cmdtable)
   540   > 
   547   > 
   541   > # demand import avoids failure of importing notexist here
   548   > # demand import avoids failure of importing notexist here
   546   >     try:
   553   >     try:
   547   >         ui.write(extlibroot.lsub1.lsub2.notexist.text)
   554   >         ui.write(extlibroot.lsub1.lsub2.notexist.text)
   548   >         return 1 # unintentional success
   555   >         return 1 # unintentional success
   549   >     except ImportError:
   556   >     except ImportError:
   550   >         pass # intentional failure
   557   >         pass # intentional failure
   551   > EOF
   558   > NO_CHECK_EOF
   552 
   559 
   553   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity)
   560   $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity)
   554 
   561 
   555 #endif
   562 #endif
       
   563 
       
   564 (Here, module importing tests are finished. Therefore, use other than
       
   565 NO_CHECK_* limit mark for heredoc python files, in order to apply
       
   566 import-checker.py or so on their contents)
   556 
   567 
   557 Make sure a broken uisetup doesn't globally break hg:
   568 Make sure a broken uisetup doesn't globally break hg:
   558   $ cat > $TESTTMP/baduisetup.py <<EOF
   569   $ cat > $TESTTMP/baduisetup.py <<EOF
   559   > def uisetup(ui):
   570   > def uisetup(ui):
   560   >     1/0
   571   >     1/0