##// END OF EJS Templates
run-tests: move HGTMP out of a global
Gregory Szorc -
r21342:1ad7aabb default
parent child Browse files
Show More
@@ -388,10 +388,10 b' def killdaemons(pidfile):'
388 388 return killmod.killdaemons(pidfile, tryhard=False, remove=True,
389 389 logfn=vlog)
390 390
391 def cleanup(options):
391 def cleanup(runner, options):
392 392 if not options.keep_tmpdir:
393 vlog("# Cleaning up HGTMP", HGTMP)
394 shutil.rmtree(HGTMP, True)
393 vlog("# Cleaning up HGTMP", runner.hgtmp)
394 shutil.rmtree(runner.hgtmp, True)
395 395 for f in createdfiles:
396 396 try:
397 397 os.remove(f)
@@ -459,7 +459,7 b' def installhg(runner, options):'
459 459 ' install --force --prefix="%(prefix)s" --install-lib="%(libdir)s"'
460 460 ' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1'
461 461 % {'exe': sys.executable, 'py3': py3, 'pure': pure,
462 'compiler': compiler, 'base': os.path.join(HGTMP, "build"),
462 'compiler': compiler, 'base': os.path.join(runner.hgtmp, "build"),
463 463 'prefix': INST, 'libdir': PYTHONDIR, 'bindir': BINDIR,
464 464 'nohome': nohome, 'logfile': installerrs})
465 465 vlog("# Running", cmd)
@@ -551,11 +551,11 b' class Test(object):'
551 551 runs cannot be run concurrently.
552 552 """
553 553
554 def __init__(self, testdir, test, options, count, refpath):
555 path = os.path.join(testdir, test)
556 errpath = os.path.join(testdir, '%s.err' % test)
554 def __init__(self, runner, test, options, count, refpath):
555 path = os.path.join(runner.testdir, test)
556 errpath = os.path.join(runner.testdir, '%s.err' % test)
557 557
558 self._testdir = testdir
558 self._testdir = runner.testdir
559 559 self._test = test
560 560 self._path = path
561 561 self._options = options
@@ -575,7 +575,7 b' class Test(object):'
575 575 else:
576 576 self._refout = []
577 577
578 self._threadtmp = os.path.join(HGTMP, 'child%d' % count)
578 self._threadtmp = os.path.join(runner.hgtmp, 'child%d' % count)
579 579 os.mkdir(self._threadtmp)
580 580
581 581 def cleanup(self):
@@ -1103,7 +1103,7 b' def gettest(runner, test, options, count'
1103 1103 refpath = os.path.join(runner.testdir, test + out)
1104 1104 break
1105 1105
1106 return testcls(runner.testdir, test, options, count, refpath)
1106 return testcls(runner, test, options, count, refpath)
1107 1107
1108 1108 wifexited = getattr(os, "WIFEXITED", lambda x: False)
1109 1109 def run(cmd, wd, options, replacements, env):
@@ -1286,6 +1286,7 b' class TestRunner(object):'
1286 1286 """
1287 1287 def __init__(self):
1288 1288 self.testdir = None
1289 self.hgtmp = None
1289 1290
1290 1291 def main(args, parser=None):
1291 1292 runner = TestRunner()
@@ -1333,7 +1334,7 b' def main(args, parser=None):'
1333 1334 # we do the randomness ourself to know what seed is used
1334 1335 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32))
1335 1336
1336 global HGTMP, INST, BINDIR, TMPBINDIR, PYTHONDIR, COVERAGE_FILE
1337 global INST, BINDIR, TMPBINDIR, PYTHONDIR, COVERAGE_FILE
1337 1338 runner.testdir = os.environ['TESTDIR'] = os.getcwd()
1338 1339 if options.tmpdir:
1339 1340 options.keep_tmpdir = True
@@ -1358,12 +1359,12 b' def main(args, parser=None):'
1358 1359 # in all lowercase, which causes troubles with paths (issue3490)
1359 1360 d = os.getenv('TMP')
1360 1361 tmpdir = tempfile.mkdtemp('', 'hgtests.', d)
1361 HGTMP = os.environ['HGTMP'] = os.path.realpath(tmpdir)
1362 runner.hgtmp = os.environ['HGTMP'] = os.path.realpath(tmpdir)
1362 1363
1363 1364 if options.with_hg:
1364 1365 INST = None
1365 1366 BINDIR = os.path.dirname(os.path.realpath(options.with_hg))
1366 TMPBINDIR = os.path.join(HGTMP, 'install', 'bin')
1367 TMPBINDIR = os.path.join(runner.hgtmp, 'install', 'bin')
1367 1368 os.makedirs(TMPBINDIR)
1368 1369
1369 1370 # This looks redundant with how Python initializes sys.path from
@@ -1373,7 +1374,7 b' def main(args, parser=None):'
1373 1374 # ... which means it's not really redundant at all.
1374 1375 PYTHONDIR = BINDIR
1375 1376 else:
1376 INST = os.path.join(HGTMP, "install")
1377 INST = os.path.join(runner.hgtmp, "install")
1377 1378 BINDIR = os.environ["BINDIR"] = os.path.join(INST, "bin")
1378 1379 TMPBINDIR = BINDIR
1379 1380 PYTHONDIR = os.path.join(INST, "lib", "python")
@@ -1404,7 +1405,7 b' def main(args, parser=None):'
1404 1405 COVERAGE_FILE = os.path.join(runner.testdir, ".coverage")
1405 1406
1406 1407 vlog("# Using TESTDIR", runner.testdir)
1407 vlog("# Using HGTMP", HGTMP)
1408 vlog("# Using HGTMP", runner.hgtmp)
1408 1409 vlog("# Using PATH", os.environ["PATH"])
1409 1410 vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH])
1410 1411
@@ -1412,7 +1413,7 b' def main(args, parser=None):'
1412 1413 return runtests(runner, options, tests) or 0
1413 1414 finally:
1414 1415 time.sleep(.1)
1415 cleanup(options)
1416 cleanup(runner, options)
1416 1417
1417 1418 if __name__ == '__main__':
1418 1419 sys.exit(main(sys.argv[1:]))
General Comments 0
You need to be logged in to leave comments. Login now