D5199: test: fix self._testdir to use ues the right mercurial library during testing

sangeet259 (Sangeet Kumar Mishra) phabricator at mercurial-scm.org
Wed Oct 31 16:32:43 UTC 2018


sangeet259 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  currently if you run tests from some other directory other than the ../tests/, you will get a warning stating
  
    warning: Testing with unexpected mercurial lib: mercurial
             (expected /tmp/hgtests.xxxxxx/install/lib/python/mercurial)
  
  This is because the the current directory being added to the 'PATH', if the self._testdir != runtestdir, owing to this line
  
    if self._testdir != runtestdir:
        path = [self._testdir] + path
  
  Also say you ran the tests from the hg base directory,
  because directory is being added in the PATH(see the above snippet, at that stage the `self._testdir` has the value as `cwd`,
  owing to a faulty initialisation). And since the current directory already has the 'hg', that is used in place of the hg that is
  installed for the testing purposes  in `/tmp/hgtests.xxxxxx/...`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5199

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2527,13 +2527,14 @@
             os.umask(oldmask)
 
     def _run(self, testdescs):
+        testdir = getcwdb()
         self._testdir = osenvironb[b'TESTDIR'] = getcwdb()
         # assume all tests in same folder for now
         if testdescs:
             pathname = os.path.dirname(testdescs[0]['path'])
             if pathname:
-                osenvironb[b'TESTDIR'] = os.path.join(osenvironb[b'TESTDIR'],
-                                                      pathname)
+                testdir = os.path.join(testdir,pathname)
+        self._testdir = osenvironb[b'TESTDIR'] = testdir
         if self.options.outputdir:
             self._outputdir = canonpath(_bytespath(self.options.outputdir))
         else:



To: sangeet259, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list