[PATCH STABLE] runtests: add the repo root to the python path

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Apr 29 06:24:55 EDT 2016


It seems like this would make the content of the repo override the 
result of the install in all case. This feel wrong as testing the actual 
install is usually very important.

We should probably have a clean distinction and mechanism for 
install/local in run-tests.py. In the mean time, one can hack around 
$TESTDIR to work around.

On 04/29/2016 02:33 AM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1461889809 25200
> #      Thu Apr 28 17:30:09 2016 -0700
> # Branch stable
> # Node ID 70b39cb6393b3b284f5dcae7f90910ef2cea9686
> # Parent  94451300f3ec4a81135d3cf86ca3dce13e53837b
> runtests: add the repo root to the python path
>
> In a normal run-tests.py job (without --with-hg), setup.py is called in such a
> way as to install a copy of the repo's libraries to a temp directory, and that
> directory is added to the python path.
>
> When --with-hg is specified, no install happens. When using run-tests.py from
> other repositories, this means that the actual contents of the other repository
> are not actually in the python path, so imports from python unit tests fail to
> find the modules that should be tested (even worse, it finds the system ones and
> tests them).
>
> The fix is to add the repo root of the repo being tested to the python path.  We
> add it at the end so that any prior pythonpath logic takes precedence.
>
> Tested this by running ./run-tests.py --with-hg=~/hg/hg from my remotefilelog
> repo and verified that python unit tests which perform imports now pass. Also
> ran the hg tests and they still pass.
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -2103,7 +2103,8 @@ class TestRunner(object):
>           # can run .../tests/run-tests.py test-foo where test-foo
>           # adds an extension to HGRC. Also include run-test.py directory to
>           # import modules like heredoctest.
> -        pypath = [self._pythondir, self._testdir, runtestdir]
> +        reporoot = os.path.dirname(self._testdir)
> +        pypath = [self._pythondir, self._testdir, runtestdir, reporoot]
>           # We have to augment PYTHONPATH, rather than simply replacing
>           # it, in case external libraries are only available via current
>           # PYTHONPATH.  (In particular, the Subversion bindings on OS X
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list