Mercurial > hg-stable
changeset 27880:b04df9ce1fb0
run-tests: skip threading for a single test (issue5040)
This version backs out 50e621fe0362 and implements it in
a more consistent manner.
author | timeless <timeless@mozdev.org> |
---|---|
date | Thu, 14 Jan 2016 04:14:50 +0000 |
parents | 52a4ad62b006 |
children | ffa599f3f503 |
files | tests/run-tests.py |
diffstat | 1 files changed, 36 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sat Jan 16 10:50:28 2016 -0500 +++ b/tests/run-tests.py Thu Jan 14 04:14:50 2016 +0000 @@ -1442,6 +1442,8 @@ executes on its own thread. Tests actually spawn new processes, so state mutation should not be an issue. + If there is only one job, it will use the main thread. + whitelist and blacklist denote tests that have been whitelisted and blacklisted, respectively. These arguments don't belong in TestSuite. Instead, whitelist and blacklist should be handled by the thing that @@ -1558,45 +1560,44 @@ statthread.start() try: - if len(tests) == 1: - test = tests.pop(0) - test.run(result) - else: - while tests or running: - if not done.empty() or running == self._jobs or not tests: - try: - done.get(True, 1) - running -= 1 - if result and result.shouldStop: - stoppedearly = True - break - except queue.Empty: - continue - if tests and not running == self._jobs: - test = tests.pop(0) - if self._loop: - if getattr(test, 'should_reload', False): - num_tests[0] += 1 - tests.append( - self._loadtest(test.name, num_tests[0])) - else: - tests.append(test) + while tests or running: + if not done.empty() or running == self._jobs or not tests: + try: + done.get(True, 1) + running -= 1 + if result and result.shouldStop: + stoppedearly = True + break + except queue.Empty: + continue + if tests and not running == self._jobs: + test = tests.pop(0) + if self._loop: + if getattr(test, 'should_reload', False): + num_tests[0] += 1 + tests.append( + self._loadtest(test.name, num_tests[0])) + else: + tests.append(test) + if self._jobs == 1: + job(test, result) + else: t = threading.Thread(target=job, name=test.name, args=(test, result)) t.start() - running += 1 + running += 1 - # If we stop early we still need to wait on started tests to - # finish. Otherwise, there is a race between the test completing - # and the test's cleanup code running. This could result in the - # test reporting incorrect. - if stoppedearly: - while running: - try: - done.get(True, 1) - running -= 1 - except queue.Empty: - continue + # If we stop early we still need to wait on started tests to + # finish. Otherwise, there is a race between the test completing + # and the test's cleanup code running. This could result in the + # test reporting incorrect. + if stoppedearly: + while running: + try: + done.get(True, 1) + running -= 1 + except queue.Empty: + continue except KeyboardInterrupt: for test in runtests: test.abort()