Submitter | Durham Goode |
---|---|
Date | April 29, 2016, 12:33 a.m. |
Message ID | <70b39cb6393b3b284f5d.1461889981@dev8486.prn1.facebook.com> |
Download | mbox | patch |
Permalink | /patch/14830/ |
State | Changes Requested |
Headers | show |
Comments
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@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@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
On Thu, 2016-04-28 at 17:33 -0700, Durham Goode wrote: > # HG changeset patch > # User Durham Goode <durham@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.
Patch
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