Mercurial > hg
comparison tests/run-tests.py @ 21506:bfe2616a2b0e
run-tests: no longer pass a TestRunner into Test.__init__
We no longer access any attributes on TestRunner besides options, so we
stop passing a TestRunner to Test.__init__ and now pass the options
data structure instead.
Subsequent patches will move accessed options attributes into named
arguments.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 22 Apr 2014 10:13:41 -0700 |
parents | 3a1881dbf860 |
children | d839e4820da7 |
comparison
equal
deleted
inserted
replaced
21505:3a1881dbf860 | 21506:bfe2616a2b0e |
---|---|
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, abort): | 341 def __init__(self, options, 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 options are parsed command line options that control test execution. |
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 |
356 self._path = path | 356 self._path = path |
357 self.name = os.path.basename(path) | 357 self.name = os.path.basename(path) |
358 self._testdir = os.path.dirname(path) | 358 self._testdir = os.path.dirname(path) |
359 self._errpath = os.path.join(self._testdir, '%s.err' % self.name) | 359 self._errpath = os.path.join(self._testdir, '%s.err' % self.name) |
360 | 360 |
361 self._runner = runner | 361 self._options = options |
362 self._options = runner.options | |
363 self._count = count | 362 self._count = count |
364 self._threadtmp = tmpdir | 363 self._threadtmp = tmpdir |
365 self._abort = abort | 364 self._abort = abort |
366 self._daemonpids = [] | 365 self._daemonpids = [] |
367 | 366 |
371 self._skipped = None | 370 self._skipped = None |
372 self._testtmp = None | 371 self._testtmp = None |
373 | 372 |
374 # If we're not in --debug mode and reference output file exists, | 373 # If we're not in --debug mode and reference output file exists, |
375 # check test output against it. | 374 # check test output against it. |
376 if runner.options.debug: | 375 if options.debug: |
377 self._refout = None # to match "out is None" | 376 self._refout = None # to match "out is None" |
378 elif os.path.exists(self._refpath): | 377 elif os.path.exists(self._refpath): |
379 f = open(self._refpath, 'r') | 378 f = open(self._refpath, 'r') |
380 self._refout = f.read().splitlines(True) | 379 self._refout = f.read().splitlines(True) |
381 f.close() | 380 f.close() |
1473 break | 1472 break |
1474 | 1473 |
1475 refpath = os.path.join(self.testdir, test) | 1474 refpath = os.path.join(self.testdir, test) |
1476 tmpdir = os.path.join(self.hgtmp, 'child%d' % count) | 1475 tmpdir = os.path.join(self.hgtmp, 'child%d' % count) |
1477 | 1476 |
1478 return testcls(self, refpath, count, tmpdir, self.abort) | 1477 return testcls(self.options, refpath, count, tmpdir, self.abort) |
1479 | 1478 |
1480 def _cleanup(self): | 1479 def _cleanup(self): |
1481 """Clean up state from this test invocation.""" | 1480 """Clean up state from this test invocation.""" |
1482 | 1481 |
1483 if self.options.keep_tmpdir: | 1482 if self.options.keep_tmpdir: |