comparison tests/run-tests.py @ 21505:3a1881dbf860

run-tests: pass abort into Test.__init__
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 22 Apr 2014 10:12:19 -0700
parents 888a5dfe1569
children bfe2616a2b0e
comparison
equal deleted inserted replaced
21504:888a5dfe1569 21505:3a1881dbf860
336 """ 336 """
337 337
338 # Status code reserved for skipped tests (used by hghave). 338 # Status code reserved for skipped tests (used by hghave).
339 SKIPPED_STATUS = 80 339 SKIPPED_STATUS = 80
340 340
341 def __init__(self, runner, path, count, tmpdir): 341 def __init__(self, runner, path, count, tmpdir, abort):
342 """Create a test from parameters. 342 """Create a test from parameters.
343 343
344 runner is a TestRunner instance. 344 runner is a TestRunner instance.
345 345
346 path is the full path to the file defining the test. 346 path is the full path to the file defining the test.
347 347
348 count is an identifier used to denote this test instance. 348 count is an identifier used to denote this test instance.
349 349
350 tmpdir is the main temporary directory to use for this test. 350 tmpdir is the main temporary directory to use for this test.
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.
351 """ 354 """
352 355
353 self._path = path 356 self._path = path
354 self.name = os.path.basename(path) 357 self.name = os.path.basename(path)
355 self._testdir = os.path.dirname(path) 358 self._testdir = os.path.dirname(path)
357 360
358 self._runner = runner 361 self._runner = runner
359 self._options = runner.options 362 self._options = runner.options
360 self._count = count 363 self._count = count
361 self._threadtmp = tmpdir 364 self._threadtmp = tmpdir
365 self._abort = abort
362 self._daemonpids = [] 366 self._daemonpids = []
363 367
364 self._finished = None 368 self._finished = None
365 self._ret = None 369 self._ret = None
366 self._out = None 370 self._out = None
682 py3kswitch = self._options.py3k_warnings and ' -3' or '' 686 py3kswitch = self._options.py3k_warnings and ' -3' or ''
683 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self._path) 687 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self._path)
684 vlog("# Running", cmd) 688 vlog("# Running", cmd)
685 if os.name == 'nt': 689 if os.name == 'nt':
686 replacements.append((r'\r\n', '\n')) 690 replacements.append((r'\r\n', '\n'))
687 return run(cmd, self._testtmp, replacements, env, self._runner.abort, 691 return run(cmd, self._testtmp, replacements, env, self._abort,
688 debug=self._options.debug, timeout=self._options.timeout) 692 debug=self._options.debug, timeout=self._options.timeout)
689 693
690 class TTest(Test): 694 class TTest(Test):
691 """A "t test" is a test backed by a .t file.""" 695 """A "t test" is a test backed by a .t file."""
692 696
718 722
719 cmd = '%s "%s"' % (self._options.shell, fname) 723 cmd = '%s "%s"' % (self._options.shell, fname)
720 vlog("# Running", cmd) 724 vlog("# Running", cmd)
721 725
722 exitcode, output = run(cmd, self._testtmp, replacements, env, 726 exitcode, output = run(cmd, self._testtmp, replacements, env,
723 self._runner.abort, debug=self._options.debug, 727 self._abort, debug=self._options.debug,
724 timeout=self._options.timeout) 728 timeout=self._options.timeout)
725 # Do not merge output if skipped. Return hghave message instead. 729 # Do not merge output if skipped. Return hghave message instead.
726 # Similarly, with --debug, output is None. 730 # Similarly, with --debug, output is None.
727 if exitcode == self.SKIPPED_STATUS or output is None: 731 if exitcode == self.SKIPPED_STATUS or output is None:
728 return exitcode, output 732 return exitcode, output
1469 break 1473 break
1470 1474
1471 refpath = os.path.join(self.testdir, test) 1475 refpath = os.path.join(self.testdir, test)
1472 tmpdir = os.path.join(self.hgtmp, 'child%d' % count) 1476 tmpdir = os.path.join(self.hgtmp, 'child%d' % count)
1473 1477
1474 return testcls(self, refpath, count, tmpdir) 1478 return testcls(self, refpath, count, tmpdir, self.abort)
1475 1479
1476 def _cleanup(self): 1480 def _cleanup(self):
1477 """Clean up state from this test invocation.""" 1481 """Clean up state from this test invocation."""
1478 1482
1479 if self.options.keep_tmpdir: 1483 if self.options.keep_tmpdir: