Show More
@@ -433,6 +433,10 b' class Test(unittest.TestCase):' | |||||
433 | os.remove(self.errpath) |
|
433 | os.remove(self.errpath) | |
434 |
|
434 | |||
435 | def run(self, result): |
|
435 | def run(self, result): | |
|
436 | """Run this test and report results against a TestResult instance.""" | |||
|
437 | # This function is extremely similar to unittest.TestCase.run(). Once | |||
|
438 | # we require Python 2.7 (or at least its version of unittest), this | |||
|
439 | # function can largely go away. | |||
436 | self._result = result |
|
440 | self._result = result | |
437 | result.startTest(self) |
|
441 | result.startTest(self) | |
438 | try: |
|
442 | try: | |
@@ -573,6 +577,12 b' class Test(unittest.TestCase):' | |||||
573 | self._aborted = True |
|
577 | self._aborted = True | |
574 |
|
578 | |||
575 | def _getreplacements(self): |
|
579 | def _getreplacements(self): | |
|
580 | """Obtain a mapping of text replacements to apply to test output. | |||
|
581 | ||||
|
582 | Test output needs to be normalized so it can be compared to expected | |||
|
583 | output. This function defines how some of that normalization will | |||
|
584 | occur. | |||
|
585 | """ | |||
576 | r = [ |
|
586 | r = [ | |
577 | (r':%s\b' % self._startport, ':$HGPORT'), |
|
587 | (r':%s\b' % self._startport, ':$HGPORT'), | |
578 | (r':%s\b' % (self._startport + 1), ':$HGPORT1'), |
|
588 | (r':%s\b' % (self._startport + 1), ':$HGPORT1'), | |
@@ -590,6 +600,7 b' class Test(unittest.TestCase):' | |||||
590 | return r |
|
600 | return r | |
591 |
|
601 | |||
592 | def _getenv(self): |
|
602 | def _getenv(self): | |
|
603 | """Obtain environment variables to use during test execution.""" | |||
593 | env = os.environ.copy() |
|
604 | env = os.environ.copy() | |
594 | env['TESTTMP'] = self._testtmp |
|
605 | env['TESTTMP'] = self._testtmp | |
595 | env['HOME'] = self._testtmp |
|
606 | env['HOME'] = self._testtmp | |
@@ -625,7 +636,7 b' class Test(unittest.TestCase):' | |||||
625 | return env |
|
636 | return env | |
626 |
|
637 | |||
627 | def _createhgrc(self, path): |
|
638 | def _createhgrc(self, path): | |
628 | # create a fresh hgrc |
|
639 | """Create an hgrc file for this test.""" | |
629 | hgrc = open(path, 'w') |
|
640 | hgrc = open(path, 'w') | |
630 | hgrc.write('[ui]\n') |
|
641 | hgrc.write('[ui]\n') | |
631 | hgrc.write('slash = True\n') |
|
642 | hgrc.write('slash = True\n') | |
@@ -1321,6 +1332,7 b' class TestRunner(object):' | |||||
1321 | Tests rely on a lot of state. This object holds it for them. |
|
1332 | Tests rely on a lot of state. This object holds it for them. | |
1322 | """ |
|
1333 | """ | |
1323 |
|
1334 | |||
|
1335 | # Programs required to run tests. | |||
1324 | REQUIREDTOOLS = [ |
|
1336 | REQUIREDTOOLS = [ | |
1325 | os.path.basename(sys.executable), |
|
1337 | os.path.basename(sys.executable), | |
1326 | 'diff', |
|
1338 | 'diff', | |
@@ -1331,6 +1343,7 b' class TestRunner(object):' | |||||
1331 | 'sed', |
|
1343 | 'sed', | |
1332 | ] |
|
1344 | ] | |
1333 |
|
1345 | |||
|
1346 | # Maps file extensions to test class. | |||
1334 | TESTTYPES = [ |
|
1347 | TESTTYPES = [ | |
1335 | ('.py', PythonTest), |
|
1348 | ('.py', PythonTest), | |
1336 | ('.t', TTest), |
|
1349 | ('.t', TTest), | |
@@ -1578,8 +1591,8 b' class TestRunner(object):' | |||||
1578 | pass |
|
1591 | pass | |
1579 |
|
1592 | |||
1580 | def _usecorrectpython(self): |
|
1593 | def _usecorrectpython(self): | |
1581 | # Some tests run the Python interpreter. They must use the |
|
1594 | """Configure the environment to use the appropriate Python in tests.""" | |
1582 | # same interpreter or bad things will happen. |
|
1595 | # Tests must use the same interpreter as us or bad things will happen. | |
1583 | pyexename = sys.platform == 'win32' and 'python.exe' or 'python' |
|
1596 | pyexename = sys.platform == 'win32' and 'python.exe' or 'python' | |
1584 | if getattr(os, 'symlink', None): |
|
1597 | if getattr(os, 'symlink', None): | |
1585 | vlog("# Making python executable in test path a symlink to '%s'" % |
|
1598 | vlog("# Making python executable in test path a symlink to '%s'" % | |
@@ -1612,6 +1625,10 b' class TestRunner(object):' | |||||
1612 | print "WARNING: Cannot find %s in search path" % pyexename |
|
1625 | print "WARNING: Cannot find %s in search path" % pyexename | |
1613 |
|
1626 | |||
1614 | def _installhg(self): |
|
1627 | def _installhg(self): | |
|
1628 | """Install hg into the test environment. | |||
|
1629 | ||||
|
1630 | This will also configure hg with the appropriate testing settings. | |||
|
1631 | """ | |||
1615 | vlog("# Performing temporary installation of HG") |
|
1632 | vlog("# Performing temporary installation of HG") | |
1616 | installerrs = os.path.join("tests", "install.err") |
|
1633 | installerrs = os.path.join("tests", "install.err") | |
1617 | compiler = '' |
|
1634 | compiler = '' | |
@@ -1721,6 +1738,7 b' class TestRunner(object):' | |||||
1721 | return self._hgpath |
|
1738 | return self._hgpath | |
1722 |
|
1739 | |||
1723 | def _outputcoverage(self): |
|
1740 | def _outputcoverage(self): | |
|
1741 | """Produce code coverage output.""" | |||
1724 | vlog('# Producing coverage report') |
|
1742 | vlog('# Producing coverage report') | |
1725 | os.chdir(self._pythondir) |
|
1743 | os.chdir(self._pythondir) | |
1726 |
|
1744 | |||
@@ -1752,8 +1770,7 b' class TestRunner(object):' | |||||
1752 | return None |
|
1770 | return None | |
1753 |
|
1771 | |||
1754 | def _checktools(self): |
|
1772 | def _checktools(self): | |
1755 | # Before we go any further, check for pre-requisite tools |
|
1773 | """Ensure tools required to run tests are present.""" | |
1756 | # stuff from coreutils (cat, rm, etc) are not tested |
|
|||
1757 | for p in self.REQUIREDTOOLS: |
|
1774 | for p in self.REQUIREDTOOLS: | |
1758 | if os.name == 'nt' and not p.endswith('.exe'): |
|
1775 | if os.name == 'nt' and not p.endswith('.exe'): | |
1759 | p += '.exe' |
|
1776 | p += '.exe' |
General Comments 0
You need to be logged in to leave comments.
Login now