Mercurial > hg
changeset 21372:3a44787e50e2
run-tests: move test shuffling and sorting into TestRunner
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Apr 2014 10:03:08 -0700 |
parents | a10ba7870c2d |
children | e478a9aab533 |
files | tests/run-tests.py |
diffstat | 1 files changed, 19 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sun Apr 20 10:00:59 2014 -0700 +++ b/tests/run-tests.py Sun Apr 20 10:03:08 2014 -0700 @@ -1019,6 +1019,25 @@ return self._run(tests) def _run(self, tests): + if self.options.random: + random.shuffle(tests) + else: + # keywords for slow tests + slow = 'svn gendoc check-code-hg'.split() + def sortkey(f): + # run largest tests first, as they tend to take the longest + try: + val = -os.stat(f).st_size + except OSError, e: + if e.errno != errno.ENOENT: + raise + return -1e9 # file does not exist, tell early + for kw in slow: + if kw in f: + val *= 10 + return val + tests.sort(key=sortkey) + self.testdir = os.environ['TESTDIR'] = os.getcwd() if 'PYTHONHASHSEED' not in os.environ: @@ -1444,25 +1463,6 @@ tests = runner.findtests(args) - if options.random: - random.shuffle(tests) - else: - # keywords for slow tests - slow = 'svn gendoc check-code-hg'.split() - def sortkey(f): - # run largest tests first, as they tend to take the longest - try: - val = -os.stat(f).st_size - except OSError, e: - if e.errno != errno.ENOENT: - raise - return -1e9 # file does not exist, tell early - for kw in slow: - if kw in f: - val *= 10 - return val - tests.sort(key=sortkey) - return runner.run(tests) if __name__ == '__main__':