comparison tests/run-tests.py @ 21513:acfd19f3e79c

run-tests: move timeout into Test.__init__
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 22 Apr 2014 12:04:15 -0700
parents 265d94cae168
children 59fe123dbb00
comparison
equal deleted inserted replaced
21512:265d94cae168 21513:acfd19f3e79c
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, options, path, count, tmpdir, abort, keeptmpdir=False, 341 def __init__(self, options, path, count, tmpdir, abort, keeptmpdir=False,
342 debug=False, nodiff=False, diffviewer=None, 342 debug=False, nodiff=False, diffviewer=None,
343 interactive=False): 343 interactive=False, timeout=defaults['timeout']):
344 """Create a test from parameters. 344 """Create a test from parameters.
345 345
346 options are parsed command line options that control test execution. 346 options are parsed command line options that control test execution.
347 347
348 path is the full path to the file defining the test. 348 path is the full path to the file defining the test.
364 364
365 diffviewer is the program that should be used to display diffs. Only 365 diffviewer is the program that should be used to display diffs. Only
366 used when output changes. 366 used when output changes.
367 367
368 interactive controls whether the test will run interactively. 368 interactive controls whether the test will run interactively.
369
370 timeout controls the maximum run time of the test. It is ignored when
371 debug is True.
369 """ 372 """
370 373
371 self.path = path 374 self.path = path
372 self.name = os.path.basename(path) 375 self.name = os.path.basename(path)
373 self._testdir = os.path.dirname(path) 376 self._testdir = os.path.dirname(path)
380 self._keeptmpdir = keeptmpdir 383 self._keeptmpdir = keeptmpdir
381 self._debug = debug 384 self._debug = debug
382 self._nodiff = nodiff 385 self._nodiff = nodiff
383 self._diffviewer = diffviewer 386 self._diffviewer = diffviewer
384 self._interactive = interactive 387 self._interactive = interactive
388 self._timeout = timeout
385 self._daemonpids = [] 389 self._daemonpids = []
386 390
387 self._finished = None 391 self._finished = None
388 self._ret = None 392 self._ret = None
389 self._out = None 393 self._out = None
682 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self.path) 686 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self.path)
683 vlog("# Running", cmd) 687 vlog("# Running", cmd)
684 if os.name == 'nt': 688 if os.name == 'nt':
685 replacements.append((r'\r\n', '\n')) 689 replacements.append((r'\r\n', '\n'))
686 return run(cmd, self._testtmp, replacements, env, self._abort, 690 return run(cmd, self._testtmp, replacements, env, self._abort,
687 debug=self._debug, timeout=self._options.timeout) 691 debug=self._debug, timeout=self._timeout)
688 692
689 class TTest(Test): 693 class TTest(Test):
690 """A "t test" is a test backed by a .t file.""" 694 """A "t test" is a test backed by a .t file."""
691 695
692 SKIPPED_PREFIX = 'skipped: ' 696 SKIPPED_PREFIX = 'skipped: '
718 cmd = '%s "%s"' % (self._options.shell, fname) 722 cmd = '%s "%s"' % (self._options.shell, fname)
719 vlog("# Running", cmd) 723 vlog("# Running", cmd)
720 724
721 exitcode, output = run(cmd, self._testtmp, replacements, env, 725 exitcode, output = run(cmd, self._testtmp, replacements, env,
722 self._abort, debug=self._debug, 726 self._abort, debug=self._debug,
723 timeout=self._options.timeout) 727 timeout=self._timeout)
724 # Do not merge output if skipped. Return hghave message instead. 728 # Do not merge output if skipped. Return hghave message instead.
725 # Similarly, with --debug, output is None. 729 # Similarly, with --debug, output is None.
726 if exitcode == self.SKIPPED_STATUS or output is None: 730 if exitcode == self.SKIPPED_STATUS or output is None:
727 return exitcode, output 731 return exitcode, output
728 732
1506 return testcls(self.options, refpath, count, tmpdir, self.abort, 1510 return testcls(self.options, refpath, count, tmpdir, self.abort,
1507 keeptmpdir=self.options.keep_tmpdir, 1511 keeptmpdir=self.options.keep_tmpdir,
1508 debug=self.options.debug, 1512 debug=self.options.debug,
1509 nodiff = self.options.nodiff, 1513 nodiff = self.options.nodiff,
1510 diffviewer=self.options.view, 1514 diffviewer=self.options.view,
1511 interactive=self.options.interactive) 1515 interactive=self.options.interactive,
1516 timeout=self.options.timeout)
1512 1517
1513 def _cleanup(self): 1518 def _cleanup(self):
1514 """Clean up state from this test invocation.""" 1519 """Clean up state from this test invocation."""
1515 1520
1516 if self.options.keep_tmpdir: 1521 if self.options.keep_tmpdir: