# HG changeset patch # User Sangeet Kumar Mishra # Date 1541267655 -19800 # Node ID 78e5b9d815facdba962950aad03e8e1b3ae60288 # Parent ff37b1712fa531ead5fdd34aa3bb7e6fa60af716 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 diff -r ff37b1712fa5 -r 78e5b9d815fa tests/run-tests.py --- a/tests/run-tests.py Sat Nov 03 20:50:04 2018 -0400 +++ b/tests/run-tests.py Sat Nov 03 23:24:15 2018 +0530 @@ -2543,17 +2543,18 @@ 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: - self._outputdir = self._testdir + self._outputdir = getcwdb() if testdescs and pathname: self._outputdir = os.path.join(self._outputdir, pathname) previoustimes = {} @@ -2901,7 +2902,7 @@ testcls = cls break - refpath = os.path.join(self._testdir, path) + refpath = os.path.join(getcwdb(), path) tmpdir = os.path.join(self._hgtmp, b'child%d' % count) # extra keyword parameters. 'case' is used by .t tests