Show More
@@ -432,7 +432,7 b' def usecorrectpython():' | |||
|
432 | 432 | if not findprogram(pyexename): |
|
433 | 433 | print "WARNING: Cannot find %s in search path" % pyexename |
|
434 | 434 | |
|
435 | def installhg(options): | |
|
435 | def installhg(runner, options): | |
|
436 | 436 | vlog("# Performing temporary installation of HG") |
|
437 | 437 | installerrs = os.path.join("tests", "install.err") |
|
438 | 438 | compiler = '' |
@@ -472,7 +472,7 b' def installhg(options):' | |||
|
472 | 472 | print line, |
|
473 | 473 | f.close() |
|
474 | 474 | sys.exit(1) |
|
475 | os.chdir(TESTDIR) | |
|
475 | os.chdir(runner.testdir) | |
|
476 | 476 | |
|
477 | 477 | usecorrectpython() |
|
478 | 478 | |
@@ -504,11 +504,11 b' def installhg(options):' | |||
|
504 | 504 | print 'WARNING: cannot fix hg.bat reference to python.exe' |
|
505 | 505 | |
|
506 | 506 | if options.anycoverage: |
|
507 |
custom = os.path.join( |
|
|
507 | custom = os.path.join(runner.testdir, 'sitecustomize.py') | |
|
508 | 508 | target = os.path.join(PYTHONDIR, 'sitecustomize.py') |
|
509 | 509 | vlog('# Installing coverage trigger to %s' % target) |
|
510 | 510 | shutil.copyfile(custom, target) |
|
511 |
rc = os.path.join( |
|
|
511 | rc = os.path.join(runner.testdir, '.coveragerc') | |
|
512 | 512 | vlog('# Installing coverage rc to %s' % rc) |
|
513 | 513 | os.environ['COVERAGE_PROCESS_START'] = rc |
|
514 | 514 | fn = os.path.join(INST, '..', '.coverage') |
@@ -522,7 +522,7 b' def outputtimes(options):' | |||
|
522 | 522 | for test, timetaken in times: |
|
523 | 523 | print cols % (timetaken, test) |
|
524 | 524 | |
|
525 | def outputcoverage(options): | |
|
525 | def outputcoverage(runner, options): | |
|
526 | 526 | |
|
527 | 527 | vlog('# Producing coverage report') |
|
528 | 528 | os.chdir(PYTHONDIR) |
@@ -533,13 +533,13 b' def outputcoverage(options):' | |||
|
533 | 533 | os.system(cmd) |
|
534 | 534 | |
|
535 | 535 | covrun('-c') |
|
536 |
omit = ','.join(os.path.join(x, '*') for x in [BINDIR, |
|
|
536 | omit = ','.join(os.path.join(x, '*') for x in [BINDIR, runner.testdir]) | |
|
537 | 537 | covrun('-i', '-r', '"--omit=%s"' % omit) # report |
|
538 | 538 | if options.htmlcov: |
|
539 |
htmldir = os.path.join( |
|
|
539 | htmldir = os.path.join(runner.testdir, 'htmlcov') | |
|
540 | 540 | covrun('-i', '-b', '"--directory=%s"' % htmldir, '"--omit=%s"' % omit) |
|
541 | 541 | if options.annotate: |
|
542 |
adir = os.path.join( |
|
|
542 | adir = os.path.join(runner.testdir, 'annotated') | |
|
543 | 543 | if not os.path.isdir(adir): |
|
544 | 544 | os.mkdir(adir) |
|
545 | 545 | covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit) |
@@ -555,6 +555,7 b' class Test(object):' | |||
|
555 | 555 | path = os.path.join(testdir, test) |
|
556 | 556 | errpath = os.path.join(testdir, '%s.err' % test) |
|
557 | 557 | |
|
558 | self._testdir = testdir | |
|
558 | 559 | self._test = test |
|
559 | 560 | self._path = path |
|
560 | 561 | self._options = options |
@@ -847,7 +848,7 b' class TTest(Test):' | |||
|
847 | 848 | |
|
848 | 849 | def _hghave(self, reqs, testtmp): |
|
849 | 850 | # TODO do something smarter when all other uses of hghave are gone. |
|
850 |
tdir = |
|
|
851 | tdir = self._testdir.replace('\\', '/') | |
|
851 | 852 | proc = Popen4('%s -c "%s/hghave %s"' % |
|
852 | 853 | (self._options.shell, tdir, ' '.join(reqs)), |
|
853 | 854 | testtmp, 0) |
@@ -1084,7 +1085,7 b' class TTest(Test):' | |||
|
1084 | 1085 | return '+glob' |
|
1085 | 1086 | return False |
|
1086 | 1087 | |
|
1087 |
def gettest( |
|
|
1088 | def gettest(runner, test, options, count): | |
|
1088 | 1089 | """Obtain a Test by looking at its filename. |
|
1089 | 1090 | |
|
1090 | 1091 | Returns a Test instance. The Test may not be runnable if it doesn't map |
@@ -1092,17 +1093,17 b' def gettest(testdir, test, options, coun' | |||
|
1092 | 1093 | """ |
|
1093 | 1094 | |
|
1094 | 1095 | lctest = test.lower() |
|
1095 | refpath = os.path.join(testdir, test) | |
|
1096 | refpath = os.path.join(runner.testdir, test) | |
|
1096 | 1097 | |
|
1097 |
|
|
|
1098 | testcls = Test | |
|
1098 | 1099 | |
|
1099 | 1100 | for ext, cls, out in testtypes: |
|
1100 | 1101 | if lctest.endswith(ext): |
|
1101 |
|
|
|
1102 | refpath = os.path.join(testdir, test + out) | |
|
1102 | testcls = cls | |
|
1103 | refpath = os.path.join(runner.testdir, test + out) | |
|
1103 | 1104 | break |
|
1104 | 1105 | |
|
1105 |
return runner |
|
|
1106 | return testcls(runner.testdir, test, options, count, refpath) | |
|
1106 | 1107 | |
|
1107 | 1108 | wifexited = getattr(os, "WIFEXITED", lambda x: False) |
|
1108 | 1109 | def run(cmd, wd, options, replacements, env): |
@@ -1191,7 +1192,7 b' def scheduletests(runner, options, tests' | |||
|
1191 | 1192 | |
|
1192 | 1193 | def job(test, count): |
|
1193 | 1194 | try: |
|
1194 |
t = gettest( |
|
|
1195 | t = gettest(runner, test, options, count) | |
|
1195 | 1196 | done.put(t.run()) |
|
1196 | 1197 | t.cleanup() |
|
1197 | 1198 | except KeyboardInterrupt: |
@@ -1225,7 +1226,7 b' def scheduletests(runner, options, tests' | |||
|
1225 | 1226 | def runtests(runner, options, tests): |
|
1226 | 1227 | try: |
|
1227 | 1228 | if INST: |
|
1228 | installhg(options) | |
|
1229 | installhg(runner, options) | |
|
1229 | 1230 | _checkhglib("Testing") |
|
1230 | 1231 | else: |
|
1231 | 1232 | usecorrectpython() |
@@ -1265,7 +1266,7 b' def runtests(runner, options, tests):' | |||
|
1265 | 1266 | outputtimes(options) |
|
1266 | 1267 | |
|
1267 | 1268 | if options.anycoverage: |
|
1268 | outputcoverage(options) | |
|
1269 | outputcoverage(runner, options) | |
|
1269 | 1270 | except KeyboardInterrupt: |
|
1270 | 1271 | failed = True |
|
1271 | 1272 | print "\ninterrupted!" |
@@ -1283,6 +1284,8 b' class TestRunner(object):' | |||
|
1283 | 1284 | |
|
1284 | 1285 | Tests rely on a lot of state. This object holds it for them. |
|
1285 | 1286 | """ |
|
1287 | def __init__(self): | |
|
1288 | self.testdir = None | |
|
1286 | 1289 | |
|
1287 | 1290 | def main(args, parser=None): |
|
1288 | 1291 | runner = TestRunner() |
@@ -1330,8 +1333,8 b' def main(args, parser=None):' | |||
|
1330 | 1333 | # we do the randomness ourself to know what seed is used |
|
1331 | 1334 | os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) |
|
1332 | 1335 | |
|
1333 |
global |
|
|
1334 |
|
|
|
1336 | global HGTMP, INST, BINDIR, TMPBINDIR, PYTHONDIR, COVERAGE_FILE | |
|
1337 | runner.testdir = os.environ['TESTDIR'] = os.getcwd() | |
|
1335 | 1338 | if options.tmpdir: |
|
1336 | 1339 | options.keep_tmpdir = True |
|
1337 | 1340 | tmpdir = options.tmpdir |
@@ -1387,7 +1390,8 b' def main(args, parser=None):' | |||
|
1387 | 1390 | # can run .../tests/run-tests.py test-foo where test-foo |
|
1388 | 1391 | # adds an extension to HGRC. Also include run-test.py directory to import |
|
1389 | 1392 | # modules like heredoctest. |
|
1390 | pypath = [PYTHONDIR, TESTDIR, os.path.abspath(os.path.dirname(__file__))] | |
|
1393 | pypath = [PYTHONDIR, runner.testdir, | |
|
1394 | os.path.abspath(os.path.dirname(__file__))] | |
|
1391 | 1395 | # We have to augment PYTHONPATH, rather than simply replacing |
|
1392 | 1396 | # it, in case external libraries are only available via current |
|
1393 | 1397 | # PYTHONPATH. (In particular, the Subversion bindings on OS X |
@@ -1397,9 +1401,9 b' def main(args, parser=None):' | |||
|
1397 | 1401 | pypath.append(oldpypath) |
|
1398 | 1402 | os.environ[IMPL_PATH] = os.pathsep.join(pypath) |
|
1399 | 1403 | |
|
1400 |
COVERAGE_FILE = os.path.join( |
|
|
1404 | COVERAGE_FILE = os.path.join(runner.testdir, ".coverage") | |
|
1401 | 1405 | |
|
1402 |
vlog("# Using TESTDIR", |
|
|
1406 | vlog("# Using TESTDIR", runner.testdir) | |
|
1403 | 1407 | vlog("# Using HGTMP", HGTMP) |
|
1404 | 1408 | vlog("# Using PATH", os.environ["PATH"]) |
|
1405 | 1409 | vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH]) |
General Comments 0
You need to be logged in to leave comments.
Login now