[PATCH STABLE] runtests: add the repo root to the python path
Matt Mackall
mpm at selenic.com
Fri Apr 29 13:08:24 EDT 2016
On Thu, 2016-04-28 at 17:33 -0700, 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]
Seems like it should be conditional on options.with_hg?
But that's not really sufficient, because if we point that at the system install
of hg which is sitting in /usr/bin, that has no particular relation to the
libraries in the repo containing the test suite.
We can perhaps query an hg executable for what library path it uses with
debuginstall.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list