Mercurial > hg
comparison tests/run-tests.py @ 38616:c44ae5997869
run-tests: add support for external test result
The goal is to begin experiment with custom test result. I'm not sure we
should offers any backward-compatibility guarantee on that plugin API as it
doesn't change often and shouldn't have too much clients.
Differential Revision: https://phab.mercurial-scm.org/D3700
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Sat, 28 Apr 2018 12:51:44 +0200 |
parents | f83600efa1ca |
children | 948691ea92a9 |
comparison
equal
deleted
inserted
replaced
38614:4d5fb4062f0b | 38616:c44ae5997869 |
---|---|
1849 if interrupted: | 1849 if interrupted: |
1850 with iolock: | 1850 with iolock: |
1851 self.stream.writeln('INTERRUPTED: %s (after %d seconds)' % ( | 1851 self.stream.writeln('INTERRUPTED: %s (after %d seconds)' % ( |
1852 test.name, self.times[-1][3])) | 1852 test.name, self.times[-1][3])) |
1853 | 1853 |
1854 def getTestResult(): | |
1855 """ | |
1856 Returns the relevant test result | |
1857 """ | |
1858 if "CUSTOM_TEST_RESULT" in os.environ: | |
1859 testresultmodule = __import__(os.environ["CUSTOM_TEST_RESULT"]) | |
1860 return testresultmodule.TestResult | |
1861 else: | |
1862 return TestResult | |
1863 | |
1854 class TestSuite(unittest.TestSuite): | 1864 class TestSuite(unittest.TestSuite): |
1855 """Custom unittest TestSuite that knows how to execute Mercurial tests.""" | 1865 """Custom unittest TestSuite that knows how to execute Mercurial tests.""" |
1856 | 1866 |
1857 def __init__(self, testdir, jobs=1, whitelist=None, blacklist=None, | 1867 def __init__(self, testdir, jobs=1, whitelist=None, blacklist=None, |
1858 retest=False, keywords=None, loop=False, runs_per_test=1, | 1868 retest=False, keywords=None, loop=False, runs_per_test=1, |
2088 super(TextTestRunner, self).__init__(*args, **kwargs) | 2098 super(TextTestRunner, self).__init__(*args, **kwargs) |
2089 | 2099 |
2090 self._runner = runner | 2100 self._runner = runner |
2091 | 2101 |
2092 def listtests(self, test): | 2102 def listtests(self, test): |
2093 result = TestResult(self._runner.options, self.stream, | 2103 result = getTestResult()(self._runner.options, self.stream, |
2094 self.descriptions, 0) | 2104 self.descriptions, 0) |
2095 test = sorted(test, key=lambda t: t.name) | 2105 test = sorted(test, key=lambda t: t.name) |
2096 for t in test: | 2106 for t in test: |
2097 print(t.name) | 2107 print(t.name) |
2098 result.addSuccess(t) | 2108 result.addSuccess(t) |
2099 | 2109 |
2107 self._writejson(result, fp) | 2117 self._writejson(result, fp) |
2108 | 2118 |
2109 return result | 2119 return result |
2110 | 2120 |
2111 def run(self, test): | 2121 def run(self, test): |
2112 result = TestResult(self._runner.options, self.stream, | 2122 result = getTestResult()(self._runner.options, self.stream, |
2113 self.descriptions, self.verbosity) | 2123 self.descriptions, self.verbosity) |
2114 | |
2115 test(result) | 2124 test(result) |
2116 | 2125 |
2117 failed = len(result.failures) | 2126 failed = len(result.failures) |
2118 skipped = len(result.skipped) | 2127 skipped = len(result.skipped) |
2119 ignored = len(result.ignored) | 2128 ignored = len(result.ignored) |