Title: [136731] trunk/Tools
Revision
136731
Author
dpra...@chromium.org
Date
2012-12-05 12:19:09 -0800 (Wed, 05 Dec 2012)

Log Message

nrwt: return result_summaries from LayoutTestRunner.run_tests()
https://bugs.webkit.org/show_bug.cgi?id=104051

Reviewed by Ojan Vafai.

This patch completes the refactoring that makes the result summary
an object returned from the layout test runner, rather than having
it passed in and modified. This makes the split of duties between
the manager and runner clearer and makes the data flow more
functionally.

Also clean up some minor lint issues.

* Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py:
(LayoutTestRunner.__init__):
(LayoutTestRunner.run_tests):
(LayoutTestRunner._mark_interrupted_tests_as_skipped):
* Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py:
(FakePrinter.print_expected):
(LockCheckingRunner.__init__):
(LayoutTestRunnerTests._runner):
(LayoutTestRunnerTests._run_tests):
(LayoutTestRunnerTests.test_interrupt_if_at_failure_limits):
* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager.__init__):
(Manager.run):
(Manager._run_tests):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (136730 => 136731)


--- trunk/Tools/ChangeLog	2012-12-05 20:18:02 UTC (rev 136730)
+++ trunk/Tools/ChangeLog	2012-12-05 20:19:09 UTC (rev 136731)
@@ -1,5 +1,35 @@
 2012-12-05  Dirk Pranke  <dpra...@chromium.org>
 
+        nrwt: return result_summaries from LayoutTestRunner.run_tests()
+        https://bugs.webkit.org/show_bug.cgi?id=104051
+
+        Reviewed by Ojan Vafai.
+
+        This patch completes the refactoring that makes the result summary      
+        an object returned from the layout test runner, rather than having      
+        it passed in and modified. This makes the split of duties between       
+        the manager and runner clearer and makes the data flow more             
+        functionally.                                                           
+
+        Also clean up some minor lint issues.
+
+        * Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py:
+        (LayoutTestRunner.__init__):
+        (LayoutTestRunner.run_tests):
+        (LayoutTestRunner._mark_interrupted_tests_as_skipped):
+        * Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py:
+        (FakePrinter.print_expected):
+        (LockCheckingRunner.__init__):
+        (LayoutTestRunnerTests._runner):
+        (LayoutTestRunnerTests._run_tests):
+        (LayoutTestRunnerTests.test_interrupt_if_at_failure_limits):
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        (Manager.__init__):
+        (Manager.run):
+        (Manager._run_tests):
+
+2012-12-05  Dirk Pranke  <dpra...@chromium.org>
+
         nrwt: move creation of the resultsummary objects into Manager._run_tests()
         https://bugs.webkit.org/show_bug.cgi?id=104048
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py (136730 => 136731)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py	2012-12-05 20:18:02 UTC (rev 136730)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py	2012-12-05 20:19:09 UTC (rev 136731)
@@ -33,6 +33,7 @@
 
 from webkitpy.common import message_pool
 from webkitpy.layout_tests.controllers import single_test_runner
+from webkitpy.layout_tests.models.result_summary import ResultSummary
 from webkitpy.layout_tests.models import test_expectations
 from webkitpy.layout_tests.models import test_failures
 from webkitpy.layout_tests.models import test_results
@@ -60,37 +61,47 @@
 
 
 class LayoutTestRunner(object):
-    def __init__(self, options, port, printer, results_directory, expectations, test_is_slow_fn):
+    def __init__(self, options, port, printer, results_directory, test_is_slow_fn):
         self._options = options
         self._port = port
         self._printer = printer
         self._results_directory = results_directory
-        self._expectations = None
         self._test_is_slow = test_is_slow_fn
         self._sharder = Sharder(self._port.split_test, self._options.max_locked_shards)
+        self._filesystem = self._port.host.filesystem
 
-        self._current_result_summary = None
+        self._expectations = None
+        self._test_inputs = []
         self._needs_http = None
         self._needs_websockets = None
         self._retrying = False
-        self._test_files_list = []
+
+        self._current_result_summary = None
         self._remaining_locked_shards = []
         self._has_http_lock = False
-        self._filesystem = self._port.host.filesystem
 
-    def run_tests(self, test_inputs, expectations, result_summary, num_workers, needs_http, needs_websockets, retrying):
-        self._current_result_summary = result_summary
+    def run_tests(self, expectations, test_inputs, tests_to_skip, num_workers, needs_http, needs_websockets, retrying):
         self._expectations = expectations
+        self._test_inputs = test_inputs
         self._needs_http = needs_http
         self._needs_websockets = needs_websockets
         self._retrying = retrying
-        self._test_files_list = [test_input.test_name for test_input in test_inputs]
-        self._printer.num_tests = len(self._test_files_list)
-        self._printer.num_completed = 0
 
+        result_summary = ResultSummary(self._expectations, len(test_inputs))
+        self._current_result_summary = result_summary
+        self._remaining_locked_shards = []
         self._has_http_lock = False
-        self._remaining_locked_shards = []
+        self._printer.num_tests = len(test_inputs)
+        self._printer.num_completed = 0
 
+        if not retrying:
+            self._printer.print_expected(result_summary, self._expectations.get_tests_with_result_type)
+
+        for test_name in set(tests_to_skip):
+            result = test_results.TestResult(test_name)
+            result.type = test_expectations.SKIP
+            result_summary.add(result, expected=True, test_is_slow=self._test_is_slow(test_name))
+
         self._printer.write_update('Sharding tests ...')
         locked_shards, unlocked_shards = self._sharder.shard_tests(test_inputs, int(self._options.child_processes), self._options.fully_parallel)
 
@@ -141,13 +152,13 @@
         return Worker(worker_connection, results_directory, self._options)
 
     def _mark_interrupted_tests_as_skipped(self, result_summary):
-        for test_name in self._test_files_list:
-            if test_name not in result_summary.results:
-                result = test_results.TestResult(test_name, [test_failures.FailureEarlyExit()])
+        for test_input in self._test_inputs:
+            if test_input.test_name not in result_summary.results:
+                result = test_results.TestResult(test_input.test_name, [test_failures.FailureEarlyExit()])
                 # FIXME: We probably need to loop here if there are multiple iterations.
                 # FIXME: Also, these results are really neither expected nor unexpected. We probably
                 # need a third type of result.
-                result_summary.add(result, expected=False, test_is_slow=self._test_is_slow(test_name))
+                result_summary.add(result, expected=False, test_is_slow=self._test_is_slow(test_input.test_name))
 
     def _interrupt_if_at_failure_limits(self, result_summary):
         # Note: The messages in this method are constructed to match old-run-webkit-tests

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py (136730 => 136731)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py	2012-12-05 20:18:02 UTC (rev 136730)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py	2012-12-05 20:19:09 UTC (rev 136731)
@@ -48,6 +48,9 @@
     num_completed = 0
     num_tests = 0
 
+    def print_expected(self, result_summary, get_tests_with_result_type):
+        pass
+
     def print_workers_and_shards(self, num_workers, num_shards, num_locked_shards):
         pass
 
@@ -69,7 +72,7 @@
 
 class LockCheckingRunner(LayoutTestRunner):
     def __init__(self, port, options, printer, tester, http_lock):
-        super(LockCheckingRunner, self).__init__(options, port, printer, port.results_directory(), TestExpectations(port, []), lambda test_name: False)
+        super(LockCheckingRunner, self).__init__(options, port, printer, port.results_directory(), lambda test_name: False)
         self._finished_list_called = False
         self._tester = tester
         self._should_have_http_lock = http_lock
@@ -98,13 +101,10 @@
         port = port or host.port_factory.get(options.platform, options=options)
         return LockCheckingRunner(port, options, FakePrinter(), self, True)
 
-    def _result_summary(self, runner, tests):
-        return ResultSummary(TestExpectations(runner._port, tests), len(tests))
-
     def _run_tests(self, runner, tests):
         test_inputs = [TestInput(test, 6000) for test in tests]
         expectations = TestExpectations(runner._port, tests)
-        runner.run_tests(test_inputs, expectations, self._result_summary(runner, tests),
+        runner.run_tests(expectations, test_inputs, set(),
             num_workers=1, needs_http=any('http' in test for test in tests), needs_websockets=any(['websocket' in test for test in tests]), retrying=False)
 
     def test_http_locking(self):
@@ -120,9 +120,9 @@
         runner._options.exit_after_n_failures = None
         runner._options.exit_after_n_crashes_or_times = None
         test_names = ['passes/text.html', 'passes/image.html']
-        runner._test_files_list = test_names
+        runner._test_inputs = [TestInput(test_name, 6000) for test_name in test_names]
 
-        result_summary = self._result_summary(runner, test_names)
+        result_summary = ResultSummary(TestExpectations(runner._port, test_names), len(test_names))
         result_summary.unexpected_failures = 100
         result_summary.unexpected_crashes = 50
         result_summary.unexpected_timeouts = 50

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (136730 => 136731)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2012-12-05 20:18:02 UTC (rev 136730)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2012-12-05 20:19:09 UTC (rev 136731)
@@ -34,16 +34,11 @@
 create a final report.
 """
 
-import errno
 import logging
-import math
-import Queue
 import random
-import re
 import sys
 import time
 
-from webkitpy.common import message_pool
 from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder
 from webkitpy.layout_tests.controllers.layout_test_runner import LayoutTestRunner
 from webkitpy.layout_tests.controllers.test_result_writer import TestResultWriter
@@ -51,13 +46,8 @@
 from webkitpy.layout_tests.layout_package import json_results_generator
 from webkitpy.layout_tests.models import test_expectations
 from webkitpy.layout_tests.models import test_failures
-from webkitpy.layout_tests.models import test_results
 from webkitpy.layout_tests.models.test_input import TestInput
-from webkitpy.layout_tests.models.result_summary import ResultSummary
-from webkitpy.layout_tests.views import printing
 
-from webkitpy.tool import grammar
-
 _log = logging.getLogger(__name__)
 
 # Builder base URL where we have the archived test results.
@@ -283,7 +273,7 @@
 
         self._results_directory = self._port.results_directory()
         self._finder = LayoutTestFinder(self._port, self._options)
-        self._runner = LayoutTestRunner(self._options, self._port, self._printer, self._results_directory, self._expectations, self._test_is_slow)
+        self._runner = LayoutTestRunner(self._options, self._port, self._printer, self._results_directory, self._test_is_slow)
 
     def _collect_tests(self, args):
         return self._finder.find_tests(self._options, args)
@@ -368,7 +358,7 @@
         self._printer.write_update("Collecting tests ...")
         try:
             paths, test_names = self._collect_tests(args)
-        except IOError as exception:
+        except IOError:
             # This is raised if --test-list doesn't exist
             return -1
 
@@ -441,23 +431,14 @@
         needs_http = self._port.requires_http_server() or any(self._is_http_test(test) for test in tests_to_run)
         needs_websockets = any(self._is_websocket_test(test) for test in tests_to_run)
 
-        summary = ResultSummary(self._expectations, len(set(tests_to_run)) * repeat_each * iterations)
-        for test_name in set(tests_to_skip):
-            result = test_results.TestResult(test_name)
-            result.type = test_expectations.SKIP
-            summary.add(result, expected=True, test_is_slow=self._test_is_slow(test_name))
-
         test_inputs = []
         for _ in xrange(iterations):
             for test in tests_to_run:
                 for _ in xrange(repeat_each):
                     test_inputs.append(self._test_input_for_file(test))
 
-        if not retrying:
-            self._printer.print_expected(summary, self._expectations.get_tests_with_result_type)
+        return self._runner.run_tests(self._expectations, test_inputs, tests_to_skip, num_workers, needs_http, needs_websockets, retrying)
 
-        return self._runner.run_tests(test_inputs, self._expectations, summary, num_workers, needs_http, needs_websockets, retrying)
-
     def _clean_up_run(self):
         """Restores the system after we're done running tests."""
         _log.debug("flushing stdout")
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to