Mercurial > hg
comparison tests/run-tests.py @ 21343:93511a595766
run-tests: move INST out of a global
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Apr 2014 23:20:42 -0700 |
parents | 1ad7aabba14e |
children | 2e1aa8c1ee37 |
comparison
equal
deleted
inserted
replaced
21342:1ad7aabba14e | 21343:93511a595766 |
---|---|
458 ' build %(compiler)s --build-base="%(base)s"' | 458 ' build %(compiler)s --build-base="%(base)s"' |
459 ' install --force --prefix="%(prefix)s" --install-lib="%(libdir)s"' | 459 ' install --force --prefix="%(prefix)s" --install-lib="%(libdir)s"' |
460 ' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1' | 460 ' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1' |
461 % {'exe': sys.executable, 'py3': py3, 'pure': pure, | 461 % {'exe': sys.executable, 'py3': py3, 'pure': pure, |
462 'compiler': compiler, 'base': os.path.join(runner.hgtmp, "build"), | 462 'compiler': compiler, 'base': os.path.join(runner.hgtmp, "build"), |
463 'prefix': INST, 'libdir': PYTHONDIR, 'bindir': BINDIR, | 463 'prefix': runner.inst, 'libdir': PYTHONDIR, 'bindir': BINDIR, |
464 'nohome': nohome, 'logfile': installerrs}) | 464 'nohome': nohome, 'logfile': installerrs}) |
465 vlog("# Running", cmd) | 465 vlog("# Running", cmd) |
466 if os.system(cmd) == 0: | 466 if os.system(cmd) == 0: |
467 if not options.verbose: | 467 if not options.verbose: |
468 os.remove(installerrs) | 468 os.remove(installerrs) |
509 vlog('# Installing coverage trigger to %s' % target) | 509 vlog('# Installing coverage trigger to %s' % target) |
510 shutil.copyfile(custom, target) | 510 shutil.copyfile(custom, target) |
511 rc = os.path.join(runner.testdir, '.coveragerc') | 511 rc = os.path.join(runner.testdir, '.coveragerc') |
512 vlog('# Installing coverage rc to %s' % rc) | 512 vlog('# Installing coverage rc to %s' % rc) |
513 os.environ['COVERAGE_PROCESS_START'] = rc | 513 os.environ['COVERAGE_PROCESS_START'] = rc |
514 fn = os.path.join(INST, '..', '.coverage') | 514 fn = os.path.join(runner.inst, '..', '.coverage') |
515 os.environ['COVERAGE_FILE'] = fn | 515 os.environ['COVERAGE_FILE'] = fn |
516 | 516 |
517 def outputtimes(options): | 517 def outputtimes(options): |
518 vlog('# Producing time report') | 518 vlog('# Producing time report') |
519 times.sort(key=lambda t: (t[1], t[0]), reverse=True) | 519 times.sort(key=lambda t: (t[1], t[0]), reverse=True) |
1223 except KeyboardInterrupt: | 1223 except KeyboardInterrupt: |
1224 abort = True | 1224 abort = True |
1225 | 1225 |
1226 def runtests(runner, options, tests): | 1226 def runtests(runner, options, tests): |
1227 try: | 1227 try: |
1228 if INST: | 1228 if runner.inst: |
1229 installhg(runner, options) | 1229 installhg(runner, options) |
1230 _checkhglib("Testing") | 1230 _checkhglib("Testing") |
1231 else: | 1231 else: |
1232 usecorrectpython() | 1232 usecorrectpython() |
1233 | 1233 |
1285 Tests rely on a lot of state. This object holds it for them. | 1285 Tests rely on a lot of state. This object holds it for them. |
1286 """ | 1286 """ |
1287 def __init__(self): | 1287 def __init__(self): |
1288 self.testdir = None | 1288 self.testdir = None |
1289 self.hgtmp = None | 1289 self.hgtmp = None |
1290 self.inst = None | |
1290 | 1291 |
1291 def main(args, parser=None): | 1292 def main(args, parser=None): |
1292 runner = TestRunner() | 1293 runner = TestRunner() |
1293 | 1294 |
1294 parser = parser or getparser() | 1295 parser = parser or getparser() |
1332 if 'PYTHONHASHSEED' not in os.environ: | 1333 if 'PYTHONHASHSEED' not in os.environ: |
1333 # use a random python hash seed all the time | 1334 # use a random python hash seed all the time |
1334 # we do the randomness ourself to know what seed is used | 1335 # we do the randomness ourself to know what seed is used |
1335 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) | 1336 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) |
1336 | 1337 |
1337 global INST, BINDIR, TMPBINDIR, PYTHONDIR, COVERAGE_FILE | 1338 global BINDIR, TMPBINDIR, PYTHONDIR, COVERAGE_FILE |
1338 runner.testdir = os.environ['TESTDIR'] = os.getcwd() | 1339 runner.testdir = os.environ['TESTDIR'] = os.getcwd() |
1339 if options.tmpdir: | 1340 if options.tmpdir: |
1340 options.keep_tmpdir = True | 1341 options.keep_tmpdir = True |
1341 tmpdir = options.tmpdir | 1342 tmpdir = options.tmpdir |
1342 if os.path.exists(tmpdir): | 1343 if os.path.exists(tmpdir): |
1360 d = os.getenv('TMP') | 1361 d = os.getenv('TMP') |
1361 tmpdir = tempfile.mkdtemp('', 'hgtests.', d) | 1362 tmpdir = tempfile.mkdtemp('', 'hgtests.', d) |
1362 runner.hgtmp = os.environ['HGTMP'] = os.path.realpath(tmpdir) | 1363 runner.hgtmp = os.environ['HGTMP'] = os.path.realpath(tmpdir) |
1363 | 1364 |
1364 if options.with_hg: | 1365 if options.with_hg: |
1365 INST = None | 1366 runner.inst = None |
1366 BINDIR = os.path.dirname(os.path.realpath(options.with_hg)) | 1367 BINDIR = os.path.dirname(os.path.realpath(options.with_hg)) |
1367 TMPBINDIR = os.path.join(runner.hgtmp, 'install', 'bin') | 1368 TMPBINDIR = os.path.join(runner.hgtmp, 'install', 'bin') |
1368 os.makedirs(TMPBINDIR) | 1369 os.makedirs(TMPBINDIR) |
1369 | 1370 |
1370 # This looks redundant with how Python initializes sys.path from | 1371 # This looks redundant with how Python initializes sys.path from |
1372 # "hg" specified by --with-hg is not the only Python script | 1373 # "hg" specified by --with-hg is not the only Python script |
1373 # executed in the test suite that needs to import 'mercurial' | 1374 # executed in the test suite that needs to import 'mercurial' |
1374 # ... which means it's not really redundant at all. | 1375 # ... which means it's not really redundant at all. |
1375 PYTHONDIR = BINDIR | 1376 PYTHONDIR = BINDIR |
1376 else: | 1377 else: |
1377 INST = os.path.join(runner.hgtmp, "install") | 1378 runner.inst = os.path.join(runner.hgtmp, "install") |
1378 BINDIR = os.environ["BINDIR"] = os.path.join(INST, "bin") | 1379 BINDIR = os.environ["BINDIR"] = os.path.join(runner.inst, "bin") |
1379 TMPBINDIR = BINDIR | 1380 TMPBINDIR = BINDIR |
1380 PYTHONDIR = os.path.join(INST, "lib", "python") | 1381 PYTHONDIR = os.path.join(runner.inst, "lib", "python") |
1381 | 1382 |
1382 os.environ["BINDIR"] = BINDIR | 1383 os.environ["BINDIR"] = BINDIR |
1383 os.environ["PYTHON"] = PYTHON | 1384 os.environ["PYTHON"] = PYTHON |
1384 | 1385 |
1385 path = [BINDIR] + os.environ["PATH"].split(os.pathsep) | 1386 path = [BINDIR] + os.environ["PATH"].split(os.pathsep) |