2011-02-08 Dirk Pranke <dpranke@chromium.org>
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Feb 2011 01:17:02 +0000 (01:17 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Feb 2011 01:17:02 +0000 (01:17 +0000)
        Reviewed by Tony Chang.

        new-run-webkit-tests: move the logic that starts and stops the
        servers from dump_render_tree_thread into single_test_runner
        so that we can reuse it in the new multiprocessing worker class
        as well.

        https://bugs.webkit.org/show_bug.cgi?id=53840

        * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
        * Scripts/webkitpy/layout_tests/layout_package/single_test_runner.py:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@77998 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py
Tools/Scripts/webkitpy/layout_tests/layout_package/single_test_runner.py

index a0003f32d17fcbeee59e698561324090c3201be9..f09e963d8ea0afce35c31197a21b888705e6b039 100644 (file)
@@ -1,3 +1,17 @@
+2011-02-08  Dirk Pranke  <dpranke@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        new-run-webkit-tests: move the logic that starts and stops the
+        servers from dump_render_tree_thread into single_test_runner
+        so that we can reuse it in the new multiprocessing worker class
+        as well.
+
+        https://bugs.webkit.org/show_bug.cgi?id=53840
+
+        * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
+        * Scripts/webkitpy/layout_tests/layout_package/single_test_runner.py:
 2011-02-08  Dirk Pranke  <dpranke@chromium.org>
 
         Reviewed by Mihai Parparita.
index 704cc11af6a46b7154c338ca3c619feede909fe6..7ddd7b0f9ac18ba4805c8d40918edaa783bd8815 100644 (file)
@@ -74,32 +74,16 @@ class TestShellThread(threading.Thread):
         self._result_queue = result_queue
         self._current_group = None
         self._filename_list = []
-        self._single_test_runner = None
         self._test_group_timing_stats = {}
         self._test_results = []
         self._num_tests = 0
         self._start_time = 0
         self._stop_time = 0
-        self._have_http_lock = False
         self._http_lock_wait_begin = 0
         self._http_lock_wait_end = 0
 
-    def cleanup(self):
-        if self._single_test_runner:
-            self._single_test_runner.cleanup()
-        if self._have_http_lock:
-            self._stop_servers_with_lock()
-
-        # Current group of tests we're running.
-        self._current_group = None
-        # Number of tests in self._current_group.
-        self._num_tests_in_current_group = None
-        # Time at which we started running tests from self._current_group.
-        self._current_group_start_time = None
-
     def cancel(self):
         """Set a flag telling this thread to quit."""
-        self.cleanup()
         self._canceled = True
 
     def clear_next_timeout(self):
@@ -191,7 +175,7 @@ class TestShellThread(threading.Thread):
 
         If test_runner is not None, then we call test_runner.UpdateSummary()
         with the results of each test."""
-        self._single_test_runner = SingleTestRunner(self._options, self._port,
+        single_test_runner = SingleTestRunner(self._options, self._port,
             self._name, self._worker_number)
 
         batch_size = self._options.batch_size
@@ -207,7 +191,7 @@ class TestShellThread(threading.Thread):
             if self._canceled:
                 _log.debug('Testing cancelled')
                 tests_run_file.close()
-                self.cleanup()
+                single_test_runner.cleanup()
                 return
 
             if len(self._filename_list) is 0:
@@ -220,14 +204,16 @@ class TestShellThread(threading.Thread):
                     self._current_group, self._filename_list = \
                         self._filename_list_queue.get_nowait()
                 except Queue.Empty:
-                    self.cleanup()
                     tests_run_file.close()
+                    single_test_runner.cleanup()
                     return
 
                 if self._current_group == "tests_to_http_lock":
-                    self._start_servers_with_lock()
-                elif self._have_http_lock:
-                    self._stop_servers_with_lock()
+                    self._http_lock_wait_begin = time.time()
+                    single_test_runner.start_servers_with_lock()
+                    self._http_lock_wait_end = time.time()
+                elif single_test_runner.has_http_lock:
+                    single_test_runner.stop_servers_with_lock()
 
                 self._num_tests_in_current_group = len(self._filename_list)
                 self._current_group_start_time = time.time()
@@ -238,15 +224,15 @@ class TestShellThread(threading.Thread):
             batch_count += 1
             self._num_tests += 1
 
-            timeout = self._single_test_runner.timeout(test_input)
-            result = self._single_test_runner.run_test(test_input, timeout)
+            timeout = single_test_runner.timeout(test_input)
+            result = single_test_runner.run_test(test_input, timeout)
 
             tests_run_file.write(test_input.filename + "\n")
             test_name = self._port.relative_test_filename(test_input.filename)
             if result.failures:
                 # Check and kill DumpRenderTree if we need to.
                 if any([f.should_kill_dump_render_tree() for f in result.failures]):
-                    self._single_test_runner.kill_dump_render_tree()
+                    single_test_runner.kill_dump_render_tree()
                     # Reset the batch count since the shell just bounced.
                     batch_count = 0
 
@@ -260,31 +246,8 @@ class TestShellThread(threading.Thread):
 
             if batch_size > 0 and batch_count >= batch_size:
                 # Bounce the shell and reset count.
-                self._single_test_runner.kill_dump_render_tree()
+                single_test_runner.kill_dump_render_tree()
                 batch_count = 0
 
             if test_runner:
                 test_runner.update_summary(result_summary)
-
-    def _start_servers_with_lock(self):
-        """Acquire http lock and start the servers."""
-        self._http_lock_wait_begin = time.time()
-        _log.debug('Acquire http lock ...')
-        self._port.acquire_http_lock()
-        _log.debug('Starting HTTP server ...')
-        self._port.start_http_server()
-        _log.debug('Starting WebSocket server ...')
-        self._port.start_websocket_server()
-        self._http_lock_wait_end = time.time()
-        self._have_http_lock = True
-
-    def _stop_servers_with_lock(self):
-        """Stop the servers and release http lock."""
-        if self._have_http_lock:
-            _log.debug('Stopping HTTP server ...')
-            self._port.stop_http_server()
-            _log.debug('Stopping WebSocket server ...')
-            self._port.stop_websocket_server()
-            _log.debug('Release http lock ...')
-            self._port.release_http_lock()
-            self._have_http_lock = False
index edcf6fe873c7091ef4d0bbcbe81327792496fef3..8f151e8c3a2ab89a9c2003b639b9c64b9b882ad9 100644 (file)
@@ -60,12 +60,15 @@ class SingleTestRunner:
         self._worker_number = worker_number
         self._driver = None
         self._test_types = []
+        self.has_http_lock = False
         for cls in self._get_test_type_classes():
             self._test_types.append(cls(self._port,
                                         self._options.results_directory))
 
     def cleanup(self):
         self.kill_dump_render_tree()
+        if self.has_http_lock:
+            self.stop_servers_with_lock()
 
     def _get_test_type_classes(self):
         classes = [text_diff.TestTextDiff]
@@ -232,6 +235,26 @@ class SingleTestRunner:
         return TestResult(self._filename, failures, driver_output.test_time,
                           total_time_for_all_diffs, time_for_diffs)
 
+    def start_servers_with_lock(self):
+        _log.debug('Acquiring http lock ...')
+        self._port.acquire_http_lock()
+        _log.debug('Starting HTTP server ...')
+        self._port.start_http_server()
+        _log.debug('Starting WebSocket server ...')
+        self._port.start_websocket_server()
+        self.has_http_lock = True
+
+    def stop_servers_with_lock(self):
+        """Stop the servers and release http lock."""
+        if self.has_http_lock:
+            _log.debug('Stopping HTTP server ...')
+            self._port.stop_http_server()
+            _log.debug('Stopping WebSocket server ...')
+            self._port.stop_websocket_server()
+            _log.debug('Releasing server lock ...')
+            self._port.release_http_lock()
+            self.has_http_lock = False
+
     def kill_dump_render_tree(self):
         """Kill the DumpRenderTree process if it's running."""
         if self._driver: