##// END OF EJS Templates
run-tests: move PYTHONDIR out of a global
Gregory Szorc -
r21346:02087bc4 default
parent child Browse files
Show More
@@ -460,7 +460,7 b' def installhg(runner, options):'
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': runner.inst, 'libdir': PYTHONDIR,
463 'prefix': runner.inst, 'libdir': runner.pythondir,
464 'bindir': runner.bindir,
464 'bindir': runner.bindir,
465 'nohome': nohome, 'logfile': installerrs})
465 'nohome': nohome, 'logfile': installerrs})
466 vlog("# Running", cmd)
466 vlog("# Running", cmd)
@@ -506,7 +506,7 b' def installhg(runner, options):'
506
506
507 if options.anycoverage:
507 if options.anycoverage:
508 custom = os.path.join(runner.testdir, 'sitecustomize.py')
508 custom = os.path.join(runner.testdir, 'sitecustomize.py')
509 target = os.path.join(PYTHONDIR, 'sitecustomize.py')
509 target = os.path.join(runner.pythondir, 'sitecustomize.py')
510 vlog('# Installing coverage trigger to %s' % target)
510 vlog('# Installing coverage trigger to %s' % target)
511 shutil.copyfile(custom, target)
511 shutil.copyfile(custom, target)
512 rc = os.path.join(runner.testdir, '.coveragerc')
512 rc = os.path.join(runner.testdir, '.coveragerc')
@@ -526,7 +526,7 b' def outputtimes(options):'
526 def outputcoverage(runner, options):
526 def outputcoverage(runner, options):
527
527
528 vlog('# Producing coverage report')
528 vlog('# Producing coverage report')
529 os.chdir(PYTHONDIR)
529 os.chdir(runner.pythondir)
530
530
531 def covrun(*args):
531 def covrun(*args):
532 cmd = 'coverage %s' % ' '.join(args)
532 cmd = 'coverage %s' % ' '.join(args)
@@ -1170,10 +1170,10 b' def _gethgpath():'
1170 pipe.close()
1170 pipe.close()
1171 return _hgpath
1171 return _hgpath
1172
1172
1173 def _checkhglib(verb):
1173 def _checkhglib(runner, verb):
1174 """Ensure that the 'mercurial' package imported by python is
1174 """Ensure that the 'mercurial' package imported by python is
1175 the one we expect it to be. If not, print a warning to stderr."""
1175 the one we expect it to be. If not, print a warning to stderr."""
1176 expecthg = os.path.join(PYTHONDIR, 'mercurial')
1176 expecthg = os.path.join(runner.pythondir, 'mercurial')
1177 actualhg = _gethgpath()
1177 actualhg = _gethgpath()
1178 if os.path.abspath(actualhg) != os.path.abspath(expecthg):
1178 if os.path.abspath(actualhg) != os.path.abspath(expecthg):
1179 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n'
1179 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n'
@@ -1229,7 +1229,7 b' def runtests(runner, options, tests):'
1229 try:
1229 try:
1230 if runner.inst:
1230 if runner.inst:
1231 installhg(runner, options)
1231 installhg(runner, options)
1232 _checkhglib("Testing")
1232 _checkhglib(runner, "Testing")
1233 else:
1233 else:
1234 usecorrectpython(runner)
1234 usecorrectpython(runner)
1235
1235
@@ -1259,7 +1259,7 b' def runtests(runner, options, tests):'
1259 print "Warned %s: %s" % s
1259 print "Warned %s: %s" % s
1260 for s in results['!']:
1260 for s in results['!']:
1261 print "Failed %s: %s" % s
1261 print "Failed %s: %s" % s
1262 _checkhglib("Tested")
1262 _checkhglib(runner, "Tested")
1263 print "# Ran %d tests, %d skipped, %d warned, %d failed." % (
1263 print "# Ran %d tests, %d skipped, %d warned, %d failed." % (
1264 tested, skipped + ignored, warned, failed)
1264 tested, skipped + ignored, warned, failed)
1265 if results['!']:
1265 if results['!']:
@@ -1292,6 +1292,7 b' class TestRunner(object):'
1292 self.inst = None
1292 self.inst = None
1293 self.bindir = None
1293 self.bindir = None
1294 self.tmpbinddir = None
1294 self.tmpbinddir = None
1295 self.pythondir = None
1295
1296
1296 def main(args, parser=None):
1297 def main(args, parser=None):
1297 runner = TestRunner()
1298 runner = TestRunner()
@@ -1339,7 +1340,7 b' def main(args, parser=None):'
1339 # we do the randomness ourself to know what seed is used
1340 # we do the randomness ourself to know what seed is used
1340 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32))
1341 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32))
1341
1342
1342 global PYTHONDIR, COVERAGE_FILE
1343 global COVERAGE_FILE
1343 runner.testdir = os.environ['TESTDIR'] = os.getcwd()
1344 runner.testdir = os.environ['TESTDIR'] = os.getcwd()
1344 if options.tmpdir:
1345 if options.tmpdir:
1345 options.keep_tmpdir = True
1346 options.keep_tmpdir = True
@@ -1377,13 +1378,13 b' def main(args, parser=None):'
1377 # "hg" specified by --with-hg is not the only Python script
1378 # "hg" specified by --with-hg is not the only Python script
1378 # executed in the test suite that needs to import 'mercurial'
1379 # executed in the test suite that needs to import 'mercurial'
1379 # ... which means it's not really redundant at all.
1380 # ... which means it's not really redundant at all.
1380 PYTHONDIR = runner.bindir
1381 runner.pythondir = runner.bindir
1381 else:
1382 else:
1382 runner.inst = os.path.join(runner.hgtmp, "install")
1383 runner.inst = os.path.join(runner.hgtmp, "install")
1383 runner.bindir = os.environ["BINDIR"] = os.path.join(runner.inst,
1384 runner.bindir = os.environ["BINDIR"] = os.path.join(runner.inst,
1384 "bin")
1385 "bin")
1385 runner.tmpbindir = runner.bindir
1386 runner.tmpbindir = runner.bindir
1386 PYTHONDIR = os.path.join(runner.inst, "lib", "python")
1387 runner.pythondir = os.path.join(runner.inst, "lib", "python")
1387
1388
1388 os.environ["BINDIR"] = runner.bindir
1389 os.environ["BINDIR"] = runner.bindir
1389 os.environ["PYTHON"] = PYTHON
1390 os.environ["PYTHON"] = PYTHON
@@ -1397,7 +1398,7 b' def main(args, parser=None):'
1397 # can run .../tests/run-tests.py test-foo where test-foo
1398 # can run .../tests/run-tests.py test-foo where test-foo
1398 # adds an extension to HGRC. Also include run-test.py directory to import
1399 # adds an extension to HGRC. Also include run-test.py directory to import
1399 # modules like heredoctest.
1400 # modules like heredoctest.
1400 pypath = [PYTHONDIR, runner.testdir,
1401 pypath = [runner.pythondir, runner.testdir,
1401 os.path.abspath(os.path.dirname(__file__))]
1402 os.path.abspath(os.path.dirname(__file__))]
1402 # We have to augment PYTHONPATH, rather than simply replacing
1403 # We have to augment PYTHONPATH, rather than simply replacing
1403 # it, in case external libraries are only available via current
1404 # it, in case external libraries are only available via current
General Comments 0
You need to be logged in to leave comments. Login now