run-tests: skip threading for a single test
authortimeless <timeless@mozdev.org>
Mon, 28 Dec 2015 17:48:40 +0000
changeset 27689 50e621fe0362
parent 27687 4cea1b918b21
child 27690 8b01558d5d23
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.
tests/run-tests.py
--- a/tests/run-tests.py	Thu Jan 07 12:49:26 2016 +0000
+++ b/tests/run-tests.py	Mon Dec 28 17:48:40 2015 +0000
@@ -1558,41 +1558,45 @@
             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()