##// END OF EJS Templates
run-tests: move debug into an argument to Test.__init__
Gregory Szorc -
r21510:97127c4c default
parent child Browse files
Show More
@@ -338,7 +338,8 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, options, path, count, tmpdir, abort, keeptmpdir=False):
341 def __init__(self, options, path, count, tmpdir, abort, keeptmpdir=False,
342 debug=False):
342 343 """Create a test from parameters.
343 344
344 345 options are parsed command line options that control test execution.
@@ -354,6 +355,9 b' class Test(unittest.TestCase):'
354 355
355 356 keeptmpdir determines whether to keep the test's temporary directory
356 357 after execution. It defaults to removal (False).
358
359 debug mode will make the test execute verbosely, with unfiltered
360 output.
357 361 """
358 362
359 363 self.path = path
@@ -366,6 +370,7 b' class Test(unittest.TestCase):'
366 370 self._threadtmp = tmpdir
367 371 self._abort = abort
368 372 self._keeptmpdir = keeptmpdir
373 self._debug = debug
369 374 self._daemonpids = []
370 375
371 376 self._finished = None
@@ -376,7 +381,7 b' class Test(unittest.TestCase):'
376 381
377 382 # If we're not in --debug mode and reference output file exists,
378 383 # check test output against it.
379 if options.debug:
384 if debug:
380 385 self._refout = None # to match "out is None"
381 386 elif os.path.exists(self._refpath):
382 387 f = open(self._refpath, 'r')
@@ -546,7 +551,7 b' class Test(unittest.TestCase):'
546 551 shutil.rmtree(self._threadtmp, True)
547 552
548 553 if (self._ret != 0 or self._out != self._refout) and not self._skipped \
549 and not self._options.debug and self._out:
554 and not self._debug and self._out:
550 555 f = open(self.errpath, 'wb')
551 556 for line in self._out:
552 557 f.write(line)
@@ -670,7 +675,7 b' class PythonTest(Test):'
670 675 if os.name == 'nt':
671 676 replacements.append((r'\r\n', '\n'))
672 677 return run(cmd, self._testtmp, replacements, env, self._abort,
673 debug=self._options.debug, timeout=self._options.timeout)
678 debug=self._debug, timeout=self._options.timeout)
674 679
675 680 class TTest(Test):
676 681 """A "t test" is a test backed by a .t file."""
@@ -705,7 +710,7 b' class TTest(Test):'
705 710 vlog("# Running", cmd)
706 711
707 712 exitcode, output = run(cmd, self._testtmp, replacements, env,
708 self._abort, debug=self._options.debug,
713 self._abort, debug=self._debug,
709 714 timeout=self._options.timeout)
710 715 # Do not merge output if skipped. Return hghave message instead.
711 716 # Similarly, with --debug, output is None.
@@ -761,7 +766,7 b' class TTest(Test):'
761 766 # can generate the surrounding doctest magic.
762 767 inpython = False
763 768
764 if self._options.debug:
769 if self._debug:
765 770 script.append('set -x\n')
766 771 if os.getenv('MSYSTEM'):
767 772 script.append('alias pwd="pwd -W"\n')
@@ -1490,7 +1495,8 b' class TestRunner(object):'
1490 1495 tmpdir = os.path.join(self.hgtmp, 'child%d' % count)
1491 1496
1492 1497 return testcls(self.options, refpath, count, tmpdir, self.abort,
1493 keeptmpdir=self.options.keep_tmpdir)
1498 keeptmpdir=self.options.keep_tmpdir,
1499 debug=self.options.debug)
1494 1500
1495 1501 def _cleanup(self):
1496 1502 """Clean up state from this test invocation."""
General Comments 0
You need to be logged in to leave comments. Login now