Show More
@@ -338,7 +338,7 b' class Test(unittest.TestCase):' | |||
|
338 | 338 | # Status code reserved for skipped tests (used by hghave). |
|
339 | 339 | SKIPPED_STATUS = 80 |
|
340 | 340 | |
|
341 |
def __init__(self, path, tmpdir, |
|
|
341 | def __init__(self, path, tmpdir, keeptmpdir=False, | |
|
342 | 342 | debug=False, nodiff=False, diffviewer=None, |
|
343 | 343 | interactive=False, timeout=defaults['timeout'], |
|
344 | 344 | startport=defaults['port'], extraconfigopts=None, |
@@ -349,9 +349,6 b' class Test(unittest.TestCase):' | |||
|
349 | 349 | |
|
350 | 350 | tmpdir is the main temporary directory to use for this test. |
|
351 | 351 | |
|
352 | abort is a flag that turns to True if test execution should be aborted. | |
|
353 | It is consulted periodically during the execution of tests. | |
|
354 | ||
|
355 | 352 | keeptmpdir determines whether to keep the test's temporary directory |
|
356 | 353 | after execution. It defaults to removal (False). |
|
357 | 354 | |
@@ -388,7 +385,6 b' class Test(unittest.TestCase):' | |||
|
388 | 385 | self.errpath = os.path.join(self._testdir, '%s.err' % self.name) |
|
389 | 386 | |
|
390 | 387 | self._threadtmp = tmpdir |
|
391 | self._abort = abort | |
|
392 | 388 | self._keeptmpdir = keeptmpdir |
|
393 | 389 | self._debug = debug |
|
394 | 390 | self._nodiff = nodiff |
@@ -399,8 +395,9 b' class Test(unittest.TestCase):' | |||
|
399 | 395 | self._extraconfigopts = extraconfigopts or [] |
|
400 | 396 | self._py3kwarnings = py3kwarnings |
|
401 | 397 | self._shell = shell |
|
398 | ||
|
399 | self._aborted = False | |
|
402 | 400 | self._daemonpids = [] |
|
403 | ||
|
404 | 401 | self._finished = None |
|
405 | 402 | self._ret = None |
|
406 | 403 | self._out = None |
@@ -447,12 +444,11 b' class Test(unittest.TestCase):' | |||
|
447 | 444 | |
|
448 | 445 | def run(self, result): |
|
449 | 446 | result.startTest(self) |
|
450 | interrupted = False | |
|
451 | 447 | try: |
|
452 | 448 | try: |
|
453 | 449 | self.setUp() |
|
454 | 450 | except (KeyboardInterrupt, SystemExit): |
|
455 |
|
|
|
451 | self._aborted = True | |
|
456 | 452 | raise |
|
457 | 453 | except Exception: |
|
458 | 454 | result.addError(self, sys.exc_info()) |
@@ -462,7 +458,7 b' class Test(unittest.TestCase):' | |||
|
462 | 458 | try: |
|
463 | 459 | self.runTest() |
|
464 | 460 | except KeyboardInterrupt: |
|
465 |
|
|
|
461 | self._aborted = True | |
|
466 | 462 | raise |
|
467 | 463 | except SkipTest, e: |
|
468 | 464 | result.addSkip(self, str(e)) |
@@ -484,7 +480,7 b' class Test(unittest.TestCase):' | |||
|
484 | 480 | try: |
|
485 | 481 | self.tearDown() |
|
486 | 482 | except (KeyboardInterrupt, SystemExit): |
|
487 |
|
|
|
483 | self._aborted = True | |
|
488 | 484 | raise |
|
489 | 485 | except Exception: |
|
490 | 486 | result.addError(self, sys.exc_info()) |
@@ -493,7 +489,7 b' class Test(unittest.TestCase):' | |||
|
493 | 489 | if success: |
|
494 | 490 | result.addSuccess(self) |
|
495 | 491 | finally: |
|
496 |
result.stopTest(self, interrupted= |
|
|
492 | result.stopTest(self, interrupted=self._aborted) | |
|
497 | 493 | |
|
498 | 494 | def runTest(self): |
|
499 | 495 | """Run this test instance. |
@@ -589,6 +585,10 b' class Test(unittest.TestCase):' | |||
|
589 | 585 | # This should be implemented in child classes to run tests. |
|
590 | 586 | raise SkipTest('unknown test type') |
|
591 | 587 | |
|
588 | def abort(self): | |
|
589 | """Terminate execution of this test.""" | |
|
590 | self._aborted = True | |
|
591 | ||
|
592 | 592 | def _getreplacements(self): |
|
593 | 593 | r = [ |
|
594 | 594 | (r':%s\b' % self._startport, ':$HGPORT'), |
@@ -698,8 +698,12 b' class PythonTest(Test):' | |||
|
698 | 698 | vlog("# Running", cmd) |
|
699 | 699 | if os.name == 'nt': |
|
700 | 700 | replacements.append((r'\r\n', '\n')) |
|
701 |
re |
|
|
701 | result = run(cmd, self._testtmp, replacements, env, | |
|
702 | 702 | debug=self._debug, timeout=self._timeout) |
|
703 | if self._aborted: | |
|
704 | raise KeyboardInterrupt() | |
|
705 | ||
|
706 | return result | |
|
703 | 707 | |
|
704 | 708 | class TTest(Test): |
|
705 | 709 | """A "t test" is a test backed by a .t file.""" |
@@ -734,8 +738,11 b' class TTest(Test):' | |||
|
734 | 738 | vlog("# Running", cmd) |
|
735 | 739 | |
|
736 | 740 | exitcode, output = run(cmd, self._testtmp, replacements, env, |
|
737 |
|
|
|
738 | timeout=self._timeout) | |
|
741 | debug=self._debug, timeout=self._timeout) | |
|
742 | ||
|
743 | if self._aborted: | |
|
744 | raise KeyboardInterrupt() | |
|
745 | ||
|
739 | 746 | # Do not merge output if skipped. Return hghave message instead. |
|
740 | 747 | # Similarly, with --debug, output is None. |
|
741 | 748 | if exitcode == self.SKIPPED_STATUS or output is None: |
@@ -1012,7 +1019,7 b' class TTest(Test):' | |||
|
1012 | 1019 | |
|
1013 | 1020 | |
|
1014 | 1021 | wifexited = getattr(os, "WIFEXITED", lambda x: False) |
|
1015 |
def run(cmd, wd, replacements, env, |
|
|
1022 | def run(cmd, wd, replacements, env, debug=False, timeout=None): | |
|
1016 | 1023 | """Run command in a sub-process, capturing the output (stdout and stderr). |
|
1017 | 1024 | Return a tuple (exitcode, output). output is None in debug mode.""" |
|
1018 | 1025 | if debug: |
@@ -1049,9 +1056,6 b' def run(cmd, wd, replacements, env, abor' | |||
|
1049 | 1056 | if ret: |
|
1050 | 1057 | killdaemons(env['DAEMON_PIDS']) |
|
1051 | 1058 | |
|
1052 | if abort[0]: | |
|
1053 | raise KeyboardInterrupt() | |
|
1054 | ||
|
1055 | 1059 | for s, r in replacements: |
|
1056 | 1060 | output = re.sub(s, r, output) |
|
1057 | 1061 | return ret, output.splitlines(True) |
@@ -1196,6 +1200,7 b' class TestSuite(unittest.TestSuite):' | |||
|
1196 | 1200 | |
|
1197 | 1201 | tests.append(test) |
|
1198 | 1202 | |
|
1203 | runtests = list(tests) | |
|
1199 | 1204 | jobs = self._runner.options.jobs |
|
1200 | 1205 | done = queue.Queue() |
|
1201 | 1206 | running = 0 |
@@ -1229,7 +1234,8 b' class TestSuite(unittest.TestSuite):' | |||
|
1229 | 1234 | t.start() |
|
1230 | 1235 | running += 1 |
|
1231 | 1236 | except KeyboardInterrupt: |
|
1232 | self._runner.abort[0] = True | |
|
1237 | for test in runtests: | |
|
1238 | test.abort() | |
|
1233 | 1239 | |
|
1234 | 1240 | return result |
|
1235 | 1241 | |
@@ -1315,7 +1321,6 b' class TestRunner(object):' | |||
|
1315 | 1321 | self.tmpbinddir = None |
|
1316 | 1322 | self.pythondir = None |
|
1317 | 1323 | self.coveragefile = None |
|
1318 | self.abort = [False] | |
|
1319 | 1324 | self._createdfiles = [] |
|
1320 | 1325 | self._hgpath = None |
|
1321 | 1326 | |
@@ -1518,7 +1523,7 b' class TestRunner(object):' | |||
|
1518 | 1523 | refpath = os.path.join(self.testdir, test) |
|
1519 | 1524 | tmpdir = os.path.join(self.hgtmp, 'child%d' % count) |
|
1520 | 1525 | |
|
1521 |
return testcls(refpath, tmpdir, |
|
|
1526 | return testcls(refpath, tmpdir, | |
|
1522 | 1527 | keeptmpdir=self.options.keep_tmpdir, |
|
1523 | 1528 | debug=self.options.debug, |
|
1524 | 1529 | nodiff = self.options.nodiff, |
General Comments 0
You need to be logged in to leave comments.
Login now