# HG changeset patch # User timeless # Date 2015-12-28 17:48:40 # Node ID 50e621fe03625dc358976c130dbd822a99f72233 # Parent 4cea1b918b21cfa8571ce74ba6b319af6c02457b run-tests: skip threading for a single test Threading is incompatible with most Python debuggers, which makes debugging run-tests.py a real pain. If there is only one test to run, skip using a thread for it. Note that --debug is not compatible with debugging tests, since it bypasses the output handling, which is where much of the excitement is. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -1558,41 +1558,45 @@ class TestSuite(unittest.TestSuite): statthread.start() try: - 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) - t = threading.Thread(target=job, name=test.name, - args=(test, result)) - t.start() - running += 1 + 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) + t = threading.Thread(target=job, name=test.name, + args=(test, result)) + t.start() + 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()