Mercurial > hg-stable
changeset 32350:b96be0098624
run-tests: change test identity from a path to a dict
Previously, we use path to identify a test. A later patch adds more
information so a path is not enough to identify a test. So we change it to a
dictionary.
author | Jun Wu <quark@fb.com> |
---|---|
date | Sat, 29 Apr 2017 11:40:47 -0700 |
parents | 16a5cb4eedb7 |
children | a77a75a428f7 |
files | tests/run-tests.py |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Wed May 17 14:31:47 2017 -0700 +++ b/tests/run-tests.py Sat Apr 29 11:40:47 2017 -0700 @@ -1684,7 +1684,7 @@ def get(): num_tests[0] += 1 if getattr(test, 'should_reload', False): - return self._loadtest(test.path, num_tests[0]) + return self._loadtest(test, num_tests[0]) return test if not os.path.exists(test.path): result.addSkip(test, "Doesn't exist") @@ -1782,7 +1782,7 @@ if getattr(test, 'should_reload', False): num_tests[0] += 1 tests.append( - self._loadtest(test.name, num_tests[0])) + self._loadtest(test, num_tests[0])) else: tests.append(test) if self._jobs == 1: @@ -2095,6 +2095,7 @@ perf = {} def sortkey(f): # run largest tests first, as they tend to take the longest + f = f['path'] try: return perf[f] except KeyError: @@ -2262,11 +2263,16 @@ else: args = os.listdir(b'.') - return [t for t in args + return [{'path': t} for t in args if os.path.basename(t).startswith(b'test-') and (t.endswith(b'.py') or t.endswith(b'.t'))] def _runtests(self, tests): + def _reloadtest(test, i): + # convert a test back to its description dict + desc = {'path': test.path} + return self._gettest(desc, i) + try: if self._installdir: self._installhg() @@ -2280,7 +2286,7 @@ if self.options.restart: orig = list(tests) while tests: - if os.path.exists(tests[0] + ".err"): + if os.path.exists(tests[0]['path'] + ".err"): break tests.pop(0) if not tests: @@ -2304,7 +2310,7 @@ loop=self.options.loop, runs_per_test=self.options.runs_per_test, showchannels=self.options.showchannels, - tests=tests, loadtest=self._gettest) + tests=tests, loadtest=_reloadtest) verbosity = 1 if self.options.verbose: verbosity = 2 @@ -2351,7 +2357,8 @@ Returns a Test instance. The Test may not be runnable if it doesn't map to a known type. """ - lctest = test.lower() + path = test['path'] + lctest = path.lower() testcls = Test for ext, cls in self.TESTTYPES: @@ -2359,7 +2366,7 @@ testcls = cls break - refpath = os.path.join(self._testdir, test) + refpath = os.path.join(self._testdir, path) tmpdir = os.path.join(self._hgtmp, b'child%d' % count) t = testcls(refpath, tmpdir,