##// END OF EJS Templates
run-tests: move program searching into TestRunner
Gregory Szorc -
r21365:10cf9054 default
parent child Browse files
Show More
@@ -103,8 +103,6 b" if 'java' in sys.platform:"
103 103
104 104 TESTDIR = HGTMP = INST = BINDIR = TMPBINDIR = PYTHONDIR = None
105 105
106 requiredtools = [os.path.basename(sys.executable), "diff", "grep", "unzip",
107 "gunzip", "bunzip2", "sed"]
108 106 defaults = {
109 107 'jobs': ('HGTEST_JOBS', 1),
110 108 'timeout': ('HGTEST_TIMEOUT', 180),
@@ -335,14 +333,6 b' def log(*msg):'
335 333 sys.stdout.flush()
336 334 iolock.release()
337 335
338 def findprogram(program):
339 """Search PATH for a executable program"""
340 for p in os.environ.get('PATH', os.defpath).split(os.pathsep):
341 name = os.path.join(p, program)
342 if os.name == 'nt' or os.access(name, os.X_OK):
343 return name
344 return None
345
346 336 def createhgrc(path, options):
347 337 # create a fresh hgrc
348 338 hgrc = open(path, 'w')
@@ -362,18 +352,6 b' def createhgrc(path, options):'
362 352 hgrc.write('[%s]\n%s\n' % (section, key))
363 353 hgrc.close()
364 354
365 def checktools():
366 # Before we go any further, check for pre-requisite tools
367 # stuff from coreutils (cat, rm, etc) are not tested
368 for p in requiredtools:
369 if os.name == 'nt' and not p.endswith('.exe'):
370 p += '.exe'
371 found = findprogram(p)
372 if found:
373 vlog("# Found prerequisite", p, "at", found)
374 else:
375 print "WARNING: Did not find prerequisite tool: "+p
376
377 355 def terminate(proc):
378 356 """Terminate subprocess (with fallback for Python versions < 2.6)"""
379 357 vlog('# Terminating process %d' % proc.pid)
@@ -1001,6 +979,16 b' class TestRunner(object):'
1001 979 Tests rely on a lot of state. This object holds it for them.
1002 980 """
1003 981
982 REQUIREDTOOLS = [
983 os.path.basename(sys.executable),
984 'diff',
985 'grep',
986 'unzip',
987 'gunzip',
988 'bunzip2',
989 'sed',
990 ]
991
1004 992 TESTTYPES = [
1005 993 ('.py', PythonTest, '.out'),
1006 994 ('.t', TTest, ''),
@@ -1146,7 +1134,7 b' class TestRunner(object):'
1146 1134 except OSError, err:
1147 1135 if err.errno != errno.ENOENT:
1148 1136 raise
1149 if findprogram(pyexename) != sys.executable:
1137 if self._findprogram(pyexename) != sys.executable:
1150 1138 try:
1151 1139 os.symlink(sys.executable, mypython)
1152 1140 self._createdfiles.append(mypython)
@@ -1162,7 +1150,7 b' class TestRunner(object):'
1162 1150 while exedir in path:
1163 1151 path.remove(exedir)
1164 1152 os.environ['PATH'] = os.pathsep.join([exedir] + path)
1165 if not findprogram(pyexename):
1153 if not self._findprogram(pyexename):
1166 1154 print "WARNING: Cannot find %s in search path" % pyexename
1167 1155
1168 1156 def installhg(self):
@@ -1331,6 +1319,26 b' class TestRunner(object):'
1331 1319 except KeyboardInterrupt:
1332 1320 self.abort[0] = True
1333 1321
1322 def _findprogram(self, program):
1323 """Search PATH for a executable program"""
1324 for p in os.environ.get('PATH', os.defpath).split(os.pathsep):
1325 name = os.path.join(p, program)
1326 if os.name == 'nt' or os.access(name, os.X_OK):
1327 return name
1328 return None
1329
1330 def checktools(self):
1331 # Before we go any further, check for pre-requisite tools
1332 # stuff from coreutils (cat, rm, etc) are not tested
1333 for p in self.REQUIREDTOOLS:
1334 if os.name == 'nt' and not p.endswith('.exe'):
1335 p += '.exe'
1336 found = self._findprogram(p)
1337 if found:
1338 vlog("# Found prerequisite", p, "at", found)
1339 else:
1340 print "WARNING: Did not find prerequisite tool: %s " % p
1341
1334 1342 def main(args, runner=None, parser=None):
1335 1343 runner = runner or TestRunner()
1336 1344
@@ -1339,7 +1347,7 b' def main(args, runner=None, parser=None)'
1339 1347 runner.options = options
1340 1348 os.umask(022)
1341 1349
1342 checktools()
1350 runner.checktools()
1343 1351
1344 1352 tests = runner.findtests(args)
1345 1353
General Comments 0
You need to be logged in to leave comments. Login now