##// END OF EJS Templates
run-tests: move usecorrectpython() into TestRunner
Gregory Szorc -
r21351:fe564750 default
parent child Browse files
Show More
@@ -388,40 +388,6 b' def killdaemons(pidfile):'
388 return killmod.killdaemons(pidfile, tryhard=False, remove=True,
388 return killmod.killdaemons(pidfile, tryhard=False, remove=True,
389 logfn=vlog)
389 logfn=vlog)
390
390
391 def usecorrectpython(runner):
392 # some tests run python interpreter. they must use same
393 # interpreter we use or bad things will happen.
394 pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
395 if getattr(os, 'symlink', None):
396 vlog("# Making python executable in test path a symlink to '%s'" %
397 sys.executable)
398 mypython = os.path.join(runner.tmpbindir, pyexename)
399 try:
400 if os.readlink(mypython) == sys.executable:
401 return
402 os.unlink(mypython)
403 except OSError, err:
404 if err.errno != errno.ENOENT:
405 raise
406 if findprogram(pyexename) != sys.executable:
407 try:
408 os.symlink(sys.executable, mypython)
409 createdfiles.append(mypython)
410 except OSError, err:
411 # child processes may race, which is harmless
412 if err.errno != errno.EEXIST:
413 raise
414 else:
415 exedir, exename = os.path.split(sys.executable)
416 vlog("# Modifying search path to find %s as %s in '%s'" %
417 (exename, pyexename, exedir))
418 path = os.environ['PATH'].split(os.pathsep)
419 while exedir in path:
420 path.remove(exedir)
421 os.environ['PATH'] = os.pathsep.join([exedir] + path)
422 if not findprogram(pyexename):
423 print "WARNING: Cannot find %s in search path" % pyexename
424
425 def installhg(runner):
391 def installhg(runner):
426 vlog("# Performing temporary installation of HG")
392 vlog("# Performing temporary installation of HG")
427 installerrs = os.path.join("tests", "install.err")
393 installerrs = os.path.join("tests", "install.err")
@@ -465,7 +431,7 b' def installhg(runner):'
465 sys.exit(1)
431 sys.exit(1)
466 os.chdir(runner.testdir)
432 os.chdir(runner.testdir)
467
433
468 usecorrectpython(runner)
434 runner.usecorrectpython()
469
435
470 if runner.options.py3k_warnings and not runner.options.anycoverage:
436 if runner.options.py3k_warnings and not runner.options.anycoverage:
471 vlog("# Updating hg command to enable Py3k Warnings switch")
437 vlog("# Updating hg command to enable Py3k Warnings switch")
@@ -1221,7 +1187,7 b' def runtests(runner, tests):'
1221 installhg(runner)
1187 installhg(runner)
1222 _checkhglib(runner, "Testing")
1188 _checkhglib(runner, "Testing")
1223 else:
1189 else:
1224 usecorrectpython(runner)
1190 runner.usecorrectpython()
1225
1191
1226 if runner.options.restart:
1192 if runner.options.restart:
1227 orig = list(tests)
1193 orig = list(tests)
@@ -1300,6 +1266,40 b' class TestRunner(object):'
1300 except OSError:
1266 except OSError:
1301 pass
1267 pass
1302
1268
1269 def usecorrectpython(self):
1270 # Some tests run the Python interpreter. They must use the
1271 # same interpreter or bad things will happen.
1272 pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
1273 if getattr(os, 'symlink', None):
1274 vlog("# Making python executable in test path a symlink to '%s'" %
1275 sys.executable)
1276 mypython = os.path.join(self.tmpbindir, pyexename)
1277 try:
1278 if os.readlink(mypython) == sys.executable:
1279 return
1280 os.unlink(mypython)
1281 except OSError, err:
1282 if err.errno != errno.ENOENT:
1283 raise
1284 if findprogram(pyexename) != sys.executable:
1285 try:
1286 os.symlink(sys.executable, mypython)
1287 createdfiles.append(mypython)
1288 except OSError, err:
1289 # child processes may race, which is harmless
1290 if err.errno != errno.EEXIST:
1291 raise
1292 else:
1293 exedir, exename = os.path.split(sys.executable)
1294 vlog("# Modifying search path to find %s as %s in '%s'" %
1295 (exename, pyexename, exedir))
1296 path = os.environ['PATH'].split(os.pathsep)
1297 while exedir in path:
1298 path.remove(exedir)
1299 os.environ['PATH'] = os.pathsep.join([exedir] + path)
1300 if not findprogram(pyexename):
1301 print "WARNING: Cannot find %s in search path" % pyexename
1302
1303 def main(args, parser=None):
1303 def main(args, parser=None):
1304 runner = TestRunner()
1304 runner = TestRunner()
1305
1305
General Comments 0
You need to be logged in to leave comments. Login now