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

Durham Goode durham at fb.com
Fri Apr 29 11:11:53 EDT 2016


On Apr 29, 2016 3:25 AM, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:
>
> 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.

pythondir is the installdir when an install happens in run-tests, and it comes first in the Python path, so it should always take precedence.

>
> 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.

What do you mean hack around $TESTDIR?  I'm writing a Python unit test (not a .t test), so I can't just do extensions.foo=$TESTDIR/../foo .

>
> 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://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwICaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=nuarHzhP1wi1T9iURRCj1A&m=baPJC3vm2UuqUn3j0CXOeXlfWNp4zmcz1ySnmlBzVIc&s=Pn_--d8FY-rMX-P6qlM6TaeWbi8wSpPmirC5Rd1oA6o&e= 
>


More information about the Mercurial-devel mailing list