##// END OF EJS Templates
run-tests: move _gethgpath() into TestRunner
Gregory Szorc -
r21385:28414e5a default
parent child Browse files
Show More
@@ -969,23 +969,6 b' def run(cmd, wd, options, replacements, '
969 output = re.sub(s, r, output)
969 output = re.sub(s, r, output)
970 return ret, output.splitlines(True)
970 return ret, output.splitlines(True)
971
971
972 _hgpath = None
973
974 def _gethgpath():
975 """Return the path to the mercurial package that is actually found by
976 the current Python interpreter."""
977 global _hgpath
978 if _hgpath is not None:
979 return _hgpath
980
981 cmd = '%s -c "import mercurial; print (mercurial.__path__[0])"'
982 pipe = os.popen(cmd % PYTHON)
983 try:
984 _hgpath = pipe.read().strip()
985 finally:
986 pipe.close()
987 return _hgpath
988
989 iolock = threading.Lock()
972 iolock = threading.Lock()
990
973
991 class TestRunner(object):
974 class TestRunner(object):
@@ -1028,6 +1011,7 b' class TestRunner(object):'
1028 }
1011 }
1029 self.abort = [False]
1012 self.abort = [False]
1030 self._createdfiles = []
1013 self._createdfiles = []
1014 self._hgpath = None
1031
1015
1032 def run(self, args, parser=None):
1016 def run(self, args, parser=None):
1033 """Run the test suite."""
1017 """Run the test suite."""
@@ -1379,11 +1363,25 b' class TestRunner(object):'
1379 """Ensure that the 'mercurial' package imported by python is
1363 """Ensure that the 'mercurial' package imported by python is
1380 the one we expect it to be. If not, print a warning to stderr."""
1364 the one we expect it to be. If not, print a warning to stderr."""
1381 expecthg = os.path.join(self.pythondir, 'mercurial')
1365 expecthg = os.path.join(self.pythondir, 'mercurial')
1382 actualhg = _gethgpath()
1366 actualhg = self._gethgpath()
1383 if os.path.abspath(actualhg) != os.path.abspath(expecthg):
1367 if os.path.abspath(actualhg) != os.path.abspath(expecthg):
1384 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n'
1368 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n'
1385 ' (expected %s)\n'
1369 ' (expected %s)\n'
1386 % (verb, actualhg, expecthg))
1370 % (verb, actualhg, expecthg))
1371 def _gethgpath(self):
1372 """Return the path to the mercurial package that is actually found by
1373 the current Python interpreter."""
1374 if self._hgpath is not None:
1375 return self._hgpath
1376
1377 cmd = '%s -c "import mercurial; print (mercurial.__path__[0])"'
1378 pipe = os.popen(cmd % PYTHON)
1379 try:
1380 self._hgpath = pipe.read().strip()
1381 finally:
1382 pipe.close()
1383
1384 return self._hgpath
1387
1385
1388 def _outputtimes(self):
1386 def _outputtimes(self):
1389 vlog('# Producing time report')
1387 vlog('# Producing time report')
General Comments 0
You need to be logged in to leave comments. Login now