HomePhabricator

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

Authored by sangeet259.

Description

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

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

Differential Revision: https://phab.mercurial-scm.org/D5199