equal
deleted
inserted
replaced
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, options, path, count, tmpdir, abort, keeptmpdir=False, |
341 def __init__(self, options, path, count, tmpdir, abort, keeptmpdir=False, |
342 debug=False): |
342 debug=False, nodiff=False, diffviewer=None): |
343 """Create a test from parameters. |
343 """Create a test from parameters. |
344 |
344 |
345 options are parsed command line options that control test execution. |
345 options are parsed command line options that control test execution. |
346 |
346 |
347 path is the full path to the file defining the test. |
347 path is the full path to the file defining the test. |
356 keeptmpdir determines whether to keep the test's temporary directory |
356 keeptmpdir determines whether to keep the test's temporary directory |
357 after execution. It defaults to removal (False). |
357 after execution. It defaults to removal (False). |
358 |
358 |
359 debug mode will make the test execute verbosely, with unfiltered |
359 debug mode will make the test execute verbosely, with unfiltered |
360 output. |
360 output. |
|
361 |
|
362 nodiff will suppress the printing of a diff when output changes. |
|
363 |
|
364 diffviewer is the program that should be used to display diffs. Only |
|
365 used when output changes. |
361 """ |
366 """ |
362 |
367 |
363 self.path = path |
368 self.path = path |
364 self.name = os.path.basename(path) |
369 self.name = os.path.basename(path) |
365 self._testdir = os.path.dirname(path) |
370 self._testdir = os.path.dirname(path) |
369 self._count = count |
374 self._count = count |
370 self._threadtmp = tmpdir |
375 self._threadtmp = tmpdir |
371 self._abort = abort |
376 self._abort = abort |
372 self._keeptmpdir = keeptmpdir |
377 self._keeptmpdir = keeptmpdir |
373 self._debug = debug |
378 self._debug = debug |
|
379 self._nodiff = nodiff |
|
380 self._diffviewer = diffviewer |
374 self._daemonpids = [] |
381 self._daemonpids = [] |
375 |
382 |
376 self._finished = None |
383 self._finished = None |
377 self._ret = None |
384 self._ret = None |
378 self._out = None |
385 self._out = None |
470 def runTest(self): |
477 def runTest(self): |
471 """Run this test instance. |
478 """Run this test instance. |
472 |
479 |
473 This will return a tuple describing the result of the test. |
480 This will return a tuple describing the result of the test. |
474 """ |
481 """ |
475 options = self._options |
|
476 |
|
477 replacements, port = self._getreplacements() |
482 replacements, port = self._getreplacements() |
478 env = self._getenv(port) |
483 env = self._getenv(port) |
479 self._daemonpids.append(env['DAEMON_PIDS']) |
484 self._daemonpids.append(env['DAEMON_PIDS']) |
480 self._createhgrc(env['HGRCPATH']) |
485 self._createhgrc(env['HGRCPATH']) |
481 |
486 |
510 raise SkipTest(missing[-1]) |
515 raise SkipTest(missing[-1]) |
511 elif ret == 'timeout': |
516 elif ret == 'timeout': |
512 self.fail('timed out', ret) |
517 self.fail('timed out', ret) |
513 elif out != self._refout: |
518 elif out != self._refout: |
514 info = {} |
519 info = {} |
515 if not options.nodiff: |
520 if not self._nodiff: |
516 iolock.acquire() |
521 iolock.acquire() |
517 if options.view: |
522 if self._diffviewer: |
518 os.system("%s %s %s" % (options.view, self._refpath, |
523 os.system("%s %s %s" % (self._diffviewer, self._refpath, |
519 self.errpath)) |
524 self.errpath)) |
520 else: |
525 else: |
521 info = showdiff(self._refout, out, self._refpath, |
526 info = showdiff(self._refout, out, self._refpath, |
522 self.errpath) |
527 self.errpath) |
523 iolock.release() |
528 iolock.release() |
528 msg += 'output changed and ' + describe(ret) |
533 msg += 'output changed and ' + describe(ret) |
529 else: |
534 else: |
530 msg += 'output changed' |
535 msg += 'output changed' |
531 |
536 |
532 if (ret != 0 or out != self._refout) and not self._skipped \ |
537 if (ret != 0 or out != self._refout) and not self._skipped \ |
533 and not options.debug: |
538 and not self._debug: |
534 f = open(self.errpath, 'wb') |
539 f = open(self.errpath, 'wb') |
535 for line in out: |
540 for line in out: |
536 f.write(line) |
541 f.write(line) |
537 f.close() |
542 f.close() |
538 |
543 |
635 hgrc.write('[%s]\n%s\n' % (section, key)) |
640 hgrc.write('[%s]\n%s\n' % (section, key)) |
636 hgrc.close() |
641 hgrc.close() |
637 |
642 |
638 def fail(self, msg, ret): |
643 def fail(self, msg, ret): |
639 warned = ret is False |
644 warned = ret is False |
640 if not self._options.nodiff: |
645 if not self._nodiff: |
641 log("\n%s: %s %s" % (warned and 'Warning' or 'ERROR', self.name, |
646 log("\n%s: %s %s" % (warned and 'Warning' or 'ERROR', self.name, |
642 msg)) |
647 msg)) |
643 if (not ret and self._options.interactive and |
648 if (not ret and self._options.interactive and |
644 os.path.exists(self.errpath)): |
649 os.path.exists(self.errpath)): |
645 iolock.acquire() |
650 iolock.acquire() |
1494 refpath = os.path.join(self.testdir, test) |
1499 refpath = os.path.join(self.testdir, test) |
1495 tmpdir = os.path.join(self.hgtmp, 'child%d' % count) |
1500 tmpdir = os.path.join(self.hgtmp, 'child%d' % count) |
1496 |
1501 |
1497 return testcls(self.options, refpath, count, tmpdir, self.abort, |
1502 return testcls(self.options, refpath, count, tmpdir, self.abort, |
1498 keeptmpdir=self.options.keep_tmpdir, |
1503 keeptmpdir=self.options.keep_tmpdir, |
1499 debug=self.options.debug) |
1504 debug=self.options.debug, |
|
1505 nodiff = self.options.nodiff, |
|
1506 diffviewer=self.options.view) |
1500 |
1507 |
1501 def _cleanup(self): |
1508 def _cleanup(self): |
1502 """Clean up state from this test invocation.""" |
1509 """Clean up state from this test invocation.""" |
1503 |
1510 |
1504 if self.options.keep_tmpdir: |
1511 if self.options.keep_tmpdir: |