This is an archive of the discontinued Mercurial Phabricator instance.

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

Authored by sangeet259 on Oct 31 2018, 12:32 PM.



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

Diff Detail

rHG Mercurial
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

sangeet259 created this revision.Oct 31 2018, 12:32 PM
yuja added a subscriber: yuja.Nov 2 2018, 9:44 PM
  • a/tests/

+++ b/tests/
@@ -2527,13 +2527,14 @@

def _run(self, testdescs):

+ testdir = getcwdb()

self._testdir = osenvironb[b'TESTDIR'] = getcwdb()

Nit: maybe this line has to be removed.

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

The idea sounds good, but test-run-tests.t failed. Can you investigate?

sangeet259 edited the summary of this revision. (Show Details)Nov 3 2018, 3:23 PM
sangeet259 updated this revision to Diff 12389.
sangeet259 updated this revision to Diff 12390.Nov 3 2018, 3:27 PM

This passes the tests now. I had missed the subsequent code that was dependent on the earlier initialisation of self._testdir.
Fixed it.

yuja added a comment.Nov 3 2018, 9:58 PM

Queued, thanks.

This revision was automatically updated to reflect the committed changes.