[PATCH] run-tests: redefine --with-hg so it takes the 'hg' script to run

Brendan Cully brendan at kublai.com
Sat Jun 6 22:40:12 UTC 2009


On Saturday, 06 June 2009 at 13:46, Brendan Cully wrote:
> On Tuesday, 02 June 2009 at 08:25, Greg Ward wrote:
> > On Tue, Jun 2, 2009 at 1:03 AM, Brendan Cully <brendan at kublai.com> wrote:
> > > On Sunday, 31 May 2009 at 19:21, Greg Ward wrote:
> > >> # HG changeset patch
> > >> # User Greg Ward <greg-hg at gerg.ca>
> > >> # Date 1243797631 14400
> > >> # Node ID 122b3986e0a25879af002acb007adffcc42b41b9
> > >> # Parent  4700924cb679c4c3611bd8ee0d841d043cea070c
> > >> run-tests: redefine --with-hg so it takes the 'hg' script to run.
> > >
> > > I've just discovered that this breaks out-of-tree tests. For unbundled
> > > extensions, it was very nice to be able to do
> > >
> > > /path/to/hg/tests/run-tests test-myextension
> > >
> > > I'd love to get this back.
> > 
> > Ahh, irony.  Part of my motivation for this was to make exactly that
> > use case a bit easier.  (I use run-tests.py on hg-fastimport.)  I
> > think I pulled it off if you use --with-hg or --local; at any rate
> > that works for me.  Can you try that and see how it works.  Definitely
> > makes the tests go a bit faster.
> > 
> > But yeah, running without --with-hg (or --local) fails like this:
> > 
> > /usr/bin/python: can't open file 'setup.py': [Errno 2] No such file or directory
> > 
> > Is that what you're seeing?  I just realized this should be
> > straightforward to fix: just need to make it a little smarter about
> > finding setup.py.
> 
> No, I'm seeing this:
> % /dev/hg/crew/tests/run-tests.py test-sharedrepo
> 
> ERROR: test-sharedrepo output changed and returned error code 255
> +++ Test output 
> @@ -1,11 +1,74 @@
> +*** failed to import extension sharedrepo: No module named sharedrepo
> 
> ...
> 
> The top of test-sharedrepo does this:
> 
> echo "[extensions]" >> $HGRCPATH
> echo "sharedrepo=" >> $HGRCPATH

FYI, I've pushed the attached patch to fix this.
-------------- next part --------------
# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1244327883 25200
# Node ID 6e41d3c5619f3d981f7c444a0f01619cb10932fd
# Parent  b4a1b9012d96367e97da8c0e12ae1f7ade712c49
Unbreak run-tests support for out-of-tree extensions

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -759,12 +759,18 @@
         path = [BINDIR] + os.environ["PATH"].split(os.pathsep)
         os.environ["PATH"] = os.pathsep.join(path)
 
+        # Include TESTDIR in PYTHONPATH so that out-of-tree extensions
+        # can run .../tests/run-tests.py test-foo where test-foo
+        # adds an extension to HGRC
+        pypath = [PYTHONDIR, TESTDIR]
         # 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
         # are in /opt/subversion.)
-        os.environ["PYTHONPATH"] = (PYTHONDIR + os.pathsep +
-                                    os.environ.get("PYTHONPATH", ""))
+        oldpypath = os.environ.get('PYTHONPATH')
+        if oldpypath:
+            pypath.append(oldpypath)
+        os.environ['PYTHONPATH'] = os.pathsep.join(pypath)
 
     COVERAGE_FILE = os.path.join(TESTDIR, ".coverage")
 


More information about the Mercurial-devel mailing list