##// END OF EJS Templates
run-tests: move TMPBINDIR out of a global
Gregory Szorc -
r21345:8e7b0f4d default
parent child Browse files
Show More
@@ -398,14 +398,14 b' def cleanup(runner, options):'
398 except OSError:
398 except OSError:
399 pass
399 pass
400
400
401 def usecorrectpython():
401 def usecorrectpython(runner):
402 # some tests run python interpreter. they must use same
402 # some tests run python interpreter. they must use same
403 # interpreter we use or bad things will happen.
403 # interpreter we use or bad things will happen.
404 pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
404 pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
405 if getattr(os, 'symlink', None):
405 if getattr(os, 'symlink', None):
406 vlog("# Making python executable in test path a symlink to '%s'" %
406 vlog("# Making python executable in test path a symlink to '%s'" %
407 sys.executable)
407 sys.executable)
408 mypython = os.path.join(TMPBINDIR, pyexename)
408 mypython = os.path.join(runner.tmpbindir, pyexename)
409 try:
409 try:
410 if os.readlink(mypython) == sys.executable:
410 if os.readlink(mypython) == sys.executable:
411 return
411 return
@@ -475,7 +475,7 b' def installhg(runner, options):'
475 sys.exit(1)
475 sys.exit(1)
476 os.chdir(runner.testdir)
476 os.chdir(runner.testdir)
477
477
478 usecorrectpython()
478 usecorrectpython(runner)
479
479
480 if options.py3k_warnings and not options.anycoverage:
480 if options.py3k_warnings and not options.anycoverage:
481 vlog("# Updating hg command to enable Py3k Warnings switch")
481 vlog("# Updating hg command to enable Py3k Warnings switch")
@@ -1231,7 +1231,7 b' def runtests(runner, options, tests):'
1231 installhg(runner, options)
1231 installhg(runner, options)
1232 _checkhglib("Testing")
1232 _checkhglib("Testing")
1233 else:
1233 else:
1234 usecorrectpython()
1234 usecorrectpython(runner)
1235
1235
1236 if options.restart:
1236 if options.restart:
1237 orig = list(tests)
1237 orig = list(tests)
@@ -1291,6 +1291,7 b' class TestRunner(object):'
1291 self.hgtmp = None
1291 self.hgtmp = None
1292 self.inst = None
1292 self.inst = None
1293 self.bindir = None
1293 self.bindir = None
1294 self.tmpbinddir = None
1294
1295
1295 def main(args, parser=None):
1296 def main(args, parser=None):
1296 runner = TestRunner()
1297 runner = TestRunner()
@@ -1338,7 +1339,7 b' def main(args, parser=None):'
1338 # we do the randomness ourself to know what seed is used
1339 # we do the randomness ourself to know what seed is used
1339 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32))
1340 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32))
1340
1341
1341 global TMPBINDIR, PYTHONDIR, COVERAGE_FILE
1342 global PYTHONDIR, COVERAGE_FILE
1342 runner.testdir = os.environ['TESTDIR'] = os.getcwd()
1343 runner.testdir = os.environ['TESTDIR'] = os.getcwd()
1343 if options.tmpdir:
1344 if options.tmpdir:
1344 options.keep_tmpdir = True
1345 options.keep_tmpdir = True
@@ -1368,8 +1369,8 b' def main(args, parser=None):'
1368 if options.with_hg:
1369 if options.with_hg:
1369 runner.inst = None
1370 runner.inst = None
1370 runner.bindir = os.path.dirname(os.path.realpath(options.with_hg))
1371 runner.bindir = os.path.dirname(os.path.realpath(options.with_hg))
1371 TMPBINDIR = os.path.join(runner.hgtmp, 'install', 'bin')
1372 runner.tmpbindir = os.path.join(runner.hgtmp, 'install', 'bin')
1372 os.makedirs(TMPBINDIR)
1373 os.makedirs(runner.tmpbindir)
1373
1374
1374 # This looks redundant with how Python initializes sys.path from
1375 # This looks redundant with how Python initializes sys.path from
1375 # the location of the script being executed. Needed because the
1376 # the location of the script being executed. Needed because the
@@ -1381,15 +1382,15 b' def main(args, parser=None):'
1381 runner.inst = os.path.join(runner.hgtmp, "install")
1382 runner.inst = os.path.join(runner.hgtmp, "install")
1382 runner.bindir = os.environ["BINDIR"] = os.path.join(runner.inst,
1383 runner.bindir = os.environ["BINDIR"] = os.path.join(runner.inst,
1383 "bin")
1384 "bin")
1384 TMPBINDIR = runner.bindir
1385 runner.tmpbindir = runner.bindir
1385 PYTHONDIR = os.path.join(runner.inst, "lib", "python")
1386 PYTHONDIR = os.path.join(runner.inst, "lib", "python")
1386
1387
1387 os.environ["BINDIR"] = runner.bindir
1388 os.environ["BINDIR"] = runner.bindir
1388 os.environ["PYTHON"] = PYTHON
1389 os.environ["PYTHON"] = PYTHON
1389
1390
1390 path = [runner.bindir] + os.environ["PATH"].split(os.pathsep)
1391 path = [runner.bindir] + os.environ["PATH"].split(os.pathsep)
1391 if TMPBINDIR != runner.bindir:
1392 if runner.tmpbindir != runner.bindir:
1392 path = [TMPBINDIR] + path
1393 path = [runner.tmpbindir] + path
1393 os.environ["PATH"] = os.pathsep.join(path)
1394 os.environ["PATH"] = os.pathsep.join(path)
1394
1395
1395 # Include TESTDIR in PYTHONPATH so that out-of-tree extensions
1396 # Include TESTDIR in PYTHONPATH so that out-of-tree extensions
General Comments 0
You need to be logged in to leave comments. Login now