Mercurial > hg-stable
comparison tests/run-tests.py @ 35751:6d65cef5b038
merge with stable
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 19 Jan 2018 16:28:11 -0500 |
parents | 31acf6619f08 87676e8ee056 |
children | 4be991331a46 |
comparison
equal
deleted
inserted
replaced
35750:a39a9df7ecca | 35751:6d65cef5b038 |
---|---|
668 # Status code reserved for skipped tests (used by hghave). | 668 # Status code reserved for skipped tests (used by hghave). |
669 SKIPPED_STATUS = 80 | 669 SKIPPED_STATUS = 80 |
670 | 670 |
671 def __init__(self, path, outputdir, tmpdir, keeptmpdir=False, | 671 def __init__(self, path, outputdir, tmpdir, keeptmpdir=False, |
672 debug=False, | 672 debug=False, |
673 first=False, | |
673 timeout=None, | 674 timeout=None, |
674 startport=None, extraconfigopts=None, | 675 startport=None, extraconfigopts=None, |
675 py3kwarnings=False, shell=None, hgcommand=None, | 676 py3kwarnings=False, shell=None, hgcommand=None, |
676 slowtimeout=None, usechg=False, | 677 slowtimeout=None, usechg=False, |
677 useipv6=False): | 678 useipv6=False): |
720 self.errpath = os.path.join(self._outputdir, b'%s.err' % self.bname) | 721 self.errpath = os.path.join(self._outputdir, b'%s.err' % self.bname) |
721 | 722 |
722 self._threadtmp = tmpdir | 723 self._threadtmp = tmpdir |
723 self._keeptmpdir = keeptmpdir | 724 self._keeptmpdir = keeptmpdir |
724 self._debug = debug | 725 self._debug = debug |
726 self._first = first | |
725 self._timeout = timeout | 727 self._timeout = timeout |
726 self._slowtimeout = slowtimeout | 728 self._slowtimeout = slowtimeout |
727 self._startport = startport | 729 self._startport = startport |
728 self._extraconfigopts = extraconfigopts or [] | 730 self._extraconfigopts = extraconfigopts or [] |
729 self._py3kwarnings = py3kwarnings | 731 self._py3kwarnings = py3kwarnings |
904 with open(self.errpath, 'wb') as f: | 906 with open(self.errpath, 'wb') as f: |
905 for line in out: | 907 for line in out: |
906 f.write(line) | 908 f.write(line) |
907 | 909 |
908 # The result object handles diff calculation for us. | 910 # The result object handles diff calculation for us. |
909 if self._result.addOutputMismatch(self, ret, out, self._refout): | 911 with firstlock: |
910 # change was accepted, skip failing | 912 if self._result.addOutputMismatch(self, ret, out, self._refout): |
911 return | 913 # change was accepted, skip failing |
914 return | |
915 if self._first: | |
916 global firsterror | |
917 firsterror = True | |
912 | 918 |
913 if ret: | 919 if ret: |
914 msg = 'output changed and ' + describe(ret) | 920 msg = 'output changed and ' + describe(ret) |
915 else: | 921 else: |
916 msg = 'output changed' | 922 msg = 'output changed' |
1035 """Obtain environment variables to use during test execution.""" | 1041 """Obtain environment variables to use during test execution.""" |
1036 def defineport(i): | 1042 def defineport(i): |
1037 offset = '' if i == 0 else '%s' % i | 1043 offset = '' if i == 0 else '%s' % i |
1038 env["HGPORT%s" % offset] = '%s' % (self._startport + i) | 1044 env["HGPORT%s" % offset] = '%s' % (self._startport + i) |
1039 env = os.environ.copy() | 1045 env = os.environ.copy() |
1040 env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') | 1046 env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or '' |
1041 env['HGEMITWARNINGS'] = '1' | 1047 env['HGEMITWARNINGS'] = '1' |
1042 env['TESTTMP'] = self._testtmp | 1048 env['TESTTMP'] = self._testtmp |
1043 env['HOME'] = self._testtmp | 1049 env['HOME'] = self._testtmp |
1044 # This number should match portneeded in _getport | 1050 # This number should match portneeded in _getport |
1045 for port in xrange(3): | 1051 for port in xrange(3): |
1635 @staticmethod | 1641 @staticmethod |
1636 def _stringescape(s): | 1642 def _stringescape(s): |
1637 return TTest.ESCAPESUB(TTest._escapef, s) | 1643 return TTest.ESCAPESUB(TTest._escapef, s) |
1638 | 1644 |
1639 iolock = threading.RLock() | 1645 iolock = threading.RLock() |
1646 firstlock = threading.RLock() | |
1647 firsterror = False | |
1640 | 1648 |
1641 class TestResult(unittest._TextTestResult): | 1649 class TestResult(unittest._TextTestResult): |
1642 """Holds results when executing via unittest.""" | 1650 """Holds results when executing via unittest.""" |
1643 # Don't worry too much about accessing the non-public _TextTestResult. | 1651 # Don't worry too much about accessing the non-public _TextTestResult. |
1644 # It is relatively common in Python testing tools. | 1652 # It is relatively common in Python testing tools. |
1720 self.testsRun += 1 | 1728 self.testsRun += 1 |
1721 self.stream.flush() | 1729 self.stream.flush() |
1722 | 1730 |
1723 def addOutputMismatch(self, test, ret, got, expected): | 1731 def addOutputMismatch(self, test, ret, got, expected): |
1724 """Record a mismatch in test output for a particular test.""" | 1732 """Record a mismatch in test output for a particular test.""" |
1725 if self.shouldStop: | 1733 if self.shouldStop or firsterror: |
1726 # don't print, some other test case already failed and | 1734 # don't print, some other test case already failed and |
1727 # printed, we're just stale and probably failed due to our | 1735 # printed, we're just stale and probably failed due to our |
1728 # temp dir getting cleaned up. | 1736 # temp dir getting cleaned up. |
1729 return | 1737 return |
1730 | 1738 |
2713 kwds = dict((k, testdesc[k]) for k in ['case'] if k in testdesc) | 2721 kwds = dict((k, testdesc[k]) for k in ['case'] if k in testdesc) |
2714 | 2722 |
2715 t = testcls(refpath, self._outputdir, tmpdir, | 2723 t = testcls(refpath, self._outputdir, tmpdir, |
2716 keeptmpdir=self.options.keep_tmpdir, | 2724 keeptmpdir=self.options.keep_tmpdir, |
2717 debug=self.options.debug, | 2725 debug=self.options.debug, |
2726 first=self.options.first, | |
2718 timeout=self.options.timeout, | 2727 timeout=self.options.timeout, |
2719 startport=self._getport(count), | 2728 startport=self._getport(count), |
2720 extraconfigopts=self.options.extra_config_opt, | 2729 extraconfigopts=self.options.extra_config_opt, |
2721 py3kwarnings=self.options.py3k_warnings, | 2730 py3kwarnings=self.options.py3k_warnings, |
2722 shell=self.options.shell, | 2731 shell=self.options.shell, |