##// 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 TESTDIR = HGTMP = INST = BINDIR = TMPBINDIR = PYTHONDIR = None
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 defaults = {
106 defaults = {
109 'jobs': ('HGTEST_JOBS', 1),
107 'jobs': ('HGTEST_JOBS', 1),
110 'timeout': ('HGTEST_TIMEOUT', 180),
108 'timeout': ('HGTEST_TIMEOUT', 180),
@@ -335,14 +333,6 b' def log(*msg):'
335 sys.stdout.flush()
333 sys.stdout.flush()
336 iolock.release()
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 def createhgrc(path, options):
336 def createhgrc(path, options):
347 # create a fresh hgrc
337 # create a fresh hgrc
348 hgrc = open(path, 'w')
338 hgrc = open(path, 'w')
@@ -362,18 +352,6 b' def createhgrc(path, options):'
362 hgrc.write('[%s]\n%s\n' % (section, key))
352 hgrc.write('[%s]\n%s\n' % (section, key))
363 hgrc.close()
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 def terminate(proc):
355 def terminate(proc):
378 """Terminate subprocess (with fallback for Python versions < 2.6)"""
356 """Terminate subprocess (with fallback for Python versions < 2.6)"""
379 vlog('# Terminating process %d' % proc.pid)
357 vlog('# Terminating process %d' % proc.pid)
@@ -1001,6 +979,16 b' class TestRunner(object):'
1001 Tests rely on a lot of state. This object holds it for them.
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 TESTTYPES = [
992 TESTTYPES = [
1005 ('.py', PythonTest, '.out'),
993 ('.py', PythonTest, '.out'),
1006 ('.t', TTest, ''),
994 ('.t', TTest, ''),
@@ -1146,7 +1134,7 b' class TestRunner(object):'
1146 except OSError, err:
1134 except OSError, err:
1147 if err.errno != errno.ENOENT:
1135 if err.errno != errno.ENOENT:
1148 raise
1136 raise
1149 if findprogram(pyexename) != sys.executable:
1137 if self._findprogram(pyexename) != sys.executable:
1150 try:
1138 try:
1151 os.symlink(sys.executable, mypython)
1139 os.symlink(sys.executable, mypython)
1152 self._createdfiles.append(mypython)
1140 self._createdfiles.append(mypython)
@@ -1162,7 +1150,7 b' class TestRunner(object):'
1162 while exedir in path:
1150 while exedir in path:
1163 path.remove(exedir)
1151 path.remove(exedir)
1164 os.environ['PATH'] = os.pathsep.join([exedir] + path)
1152 os.environ['PATH'] = os.pathsep.join([exedir] + path)
1165 if not findprogram(pyexename):
1153 if not self._findprogram(pyexename):
1166 print "WARNING: Cannot find %s in search path" % pyexename
1154 print "WARNING: Cannot find %s in search path" % pyexename
1167
1155
1168 def installhg(self):
1156 def installhg(self):
@@ -1331,6 +1319,26 b' class TestRunner(object):'
1331 except KeyboardInterrupt:
1319 except KeyboardInterrupt:
1332 self.abort[0] = True
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 def main(args, runner=None, parser=None):
1342 def main(args, runner=None, parser=None):
1335 runner = runner or TestRunner()
1343 runner = runner or TestRunner()
1336
1344
@@ -1339,7 +1347,7 b' def main(args, runner=None, parser=None)'
1339 runner.options = options
1347 runner.options = options
1340 os.umask(022)
1348 os.umask(022)
1341
1349
1342 checktools()
1350 runner.checktools()
1343
1351
1344 tests = runner.findtests(args)
1352 tests = runner.findtests(args)
1345
1353
General Comments 0
You need to be logged in to leave comments. Login now