Mercurial > hg-stable
changeset 21496:f145914e698d
run-tests: move _executetests into TestSuite
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Apr 2014 17:42:31 -0700 |
parents | b162bdc78bef |
children | 798c81e32b5e |
files | tests/run-tests.py |
diffstat | 1 files changed, 37 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sun Apr 20 17:39:26 2014 -0700 +++ b/tests/run-tests.py Sun Apr 20 17:42:31 2014 -0700 @@ -1138,7 +1138,43 @@ self._runner = runner def run(self, result): - self._runner._executetests(self._tests, result=result) + # We modify the list, so copy so callers aren't confused. + tests = list(self._tests) + + jobs = self._runner.options.jobs + done = queue.Queue() + running = 0 + + def job(test, result): + try: + test(result) + done.put(None) + except KeyboardInterrupt: + pass + except: # re-raises + done.put(('!', test, 'run-test raised an error, see traceback')) + raise + + try: + while tests or running: + if not done.empty() or running == jobs or not tests: + try: + done.get(True, 1) + if result and result.shouldStop: + break + except queue.Empty: + continue + running -= 1 + if tests and not running == jobs: + test = tests.pop(0) + if self._runner.options.loop: + tests.append(test) + t = threading.Thread(target=job, name=test.name, + args=(test, result)) + t.start() + running += 1 + except KeyboardInterrupt: + self._runner.abort[0] = True return result @@ -1609,45 +1645,6 @@ os.mkdir(adir) covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit) - def _executetests(self, tests, result): - # We modify the list, so copy so callers aren't confused. - tests = list(tests) - - jobs = self.options.jobs - done = queue.Queue() - running = 0 - - def job(test, result): - try: - test(result) - done.put(None) - except KeyboardInterrupt: - pass - except: # re-raises - done.put(('!', test, 'run-test raised an error, see traceback')) - raise - - try: - while tests or running: - if not done.empty() or running == jobs or not tests: - try: - done.get(True, 1) - if result and result.shouldStop: - break - except queue.Empty: - continue - running -= 1 - if tests and not running == jobs: - test = tests.pop(0) - if self.options.loop: - tests.append(test) - t = threading.Thread(target=job, name=test.name, - args=(test, result)) - t.start() - running += 1 - except KeyboardInterrupt: - self.abort[0] = True - def _findprogram(self, program): """Search PATH for a executable program""" for p in os.environ.get('PATH', os.defpath).split(os.pathsep):