Title: [122887] trunk/Tools
Revision
122887
Author
[email protected]
Date
2012-07-17 16:08:10 -0700 (Tue, 17 Jul 2012)

Log Message

nrwt: move the bulk of the "expected" output to printing.py
https://bugs.webkit.org/show_bug.cgi?id=91442

Reviewed by Ojan Vafai.

More printing-related refactoring. This moves all of the code
that prints the results we expect to get, but doesn't move a few
dangling printfs (those'll get hit in a later patch).

No functional changes; covered by existing tests.

* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager._split_into_chunks_if_necessary):
(Manager.prepare_lists_and_print_output):
(Manager.print_config):
* Scripts/webkitpy/layout_tests/views/printing.py:
(Printer.print_expected):
(Printer):
(Printer._print_expected_results_of_type):
(Printer._num_digits):
(Printer._print_expected):
* Scripts/webkitpy/layout_tests/views/printing_unittest.py:
(Testprinter.test_print_expected):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (122886 => 122887)


--- trunk/Tools/ChangeLog	2012-07-17 23:06:38 UTC (rev 122886)
+++ trunk/Tools/ChangeLog	2012-07-17 23:08:10 UTC (rev 122887)
@@ -1,3 +1,29 @@
+2012-07-17  Dirk Pranke  <[email protected]>
+
+        nrwt: move the bulk of the "expected" output to printing.py
+        https://bugs.webkit.org/show_bug.cgi?id=91442
+
+        Reviewed by Ojan Vafai.
+
+        More printing-related refactoring. This moves all of the code
+        that prints the results we expect to get, but doesn't move a few
+        dangling printfs (those'll get hit in a later patch).
+        
+        No functional changes; covered by existing tests.
+
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        (Manager._split_into_chunks_if_necessary):
+        (Manager.prepare_lists_and_print_output):
+        (Manager.print_config):
+        * Scripts/webkitpy/layout_tests/views/printing.py:
+        (Printer.print_expected):
+        (Printer):
+        (Printer._print_expected_results_of_type):
+        (Printer._num_digits):
+        (Printer._print_expected):
+        * Scripts/webkitpy/layout_tests/views/printing_unittest.py:
+        (Testprinter.test_print_expected):
+
 2012-07-17  Christophe Dumez  <[email protected]>
 
         [EFL] Replace 0 by NULL in public headers documentation

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2012-07-17 23:06:38 UTC (rev 122886)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2012-07-17 23:08:10 UTC (rev 122887)
@@ -418,14 +418,14 @@
         files = test_files[slice_start:slice_end]
 
         tests_run_msg = 'Running: %d tests (chunk slice [%d:%d] of %d)' % ((slice_end - slice_start), slice_start, slice_end, num_tests)
-        self._printer.print_expected(tests_run_msg)
+        self._printer._print_expected(tests_run_msg)
 
         # If we reached the end and we don't have enough tests, we run some
         # from the beginning.
         if slice_end - slice_start < chunk_len:
             extra = chunk_len - (slice_end - slice_start)
             extra_msg = ('   last chunk is partial, appending [0:%d]' % extra)
-            self._printer.print_expected(extra_msg)
+            self._printer._print_expected(extra_msg)
             tests_run_msg += "\n" + extra_msg
             files.extend(test_files[0:extra])
         tests_run_filename = self._filesystem.join(self._results_directory, "tests_run.txt")
@@ -512,11 +512,7 @@
             (self._options.iterations if self._options.iterations else 1)
         result_summary = ResultSummary(self._expectations, self._test_files | skipped, iterations)
 
-        self._printer.print_expected('Found %s.' % grammar.pluralize('test', num_all_test_files))
-        self._print_expected_results_of_type(result_summary, test_expectations.PASS, "passes")
-        self._print_expected_results_of_type(result_summary, test_expectations.FAIL, "failures")
-        self._print_expected_results_of_type(result_summary, test_expectations.FLAKY, "flaky")
-        self._print_expected_results_of_type(result_summary, test_expectations.SKIP, "skipped")
+        self._printer.print_expected(num_all_test_files, result_summary, self._expectations.get_tests_with_result_type)
 
         if self._options.skipped != 'ignore':
             # Note that we don't actually run the skipped tests (they were
@@ -527,15 +523,7 @@
                 result.type = test_expectations.SKIP
                 for iteration in range(iterations):
                     result_summary.add(result, expected=True, test_is_slow=self._test_is_slow(test))
-        self._printer.print_expected('')
 
-        if self._options.repeat_each > 1:
-            self._printer.print_expected('Running each test %d times.' % self._options.repeat_each)
-        if self._options.iterations > 1:
-            self._printer.print_expected('Running %d iterations of the tests.' % self._options.iterations)
-        if iterations > 1:
-            self._printer.print_expected('')
-
         return result_summary
 
     def _get_dir_for_test_file(self, test_file):
@@ -1128,26 +1116,6 @@
                        ' '.join(self._port.driver_cmd_line()))
         p.print_config("")
 
-    def _print_expected_results_of_type(self, result_summary,
-                                        result_type, result_type_str):
-        """Print the number of the tests in a given result class.
-
-        Args:
-          result_summary - the object containing all the results to report on
-          result_type - the particular result type to report in the summary.
-          result_type_str - a string description of the result_type.
-        """
-        tests = self._expectations.get_tests_with_result_type(result_type)
-        now = result_summary.tests_by_timeline[test_expectations.NOW]
-        wontfix = result_summary.tests_by_timeline[test_expectations.WONTFIX]
-
-        # We use a fancy format string in order to print the data out in a
-        # nicely-aligned table.
-        fmtstr = ("Expect: %%5d %%-8s (%%%dd now, %%%dd wontfix)"
-                  % (self._num_digits(now), self._num_digits(wontfix)))
-        self._printer.print_expected(fmtstr %
-            (len(tests), result_type_str, len(tests & now), len(tests & wontfix)))
-
     def _num_digits(self, num):
         """Returns the number of digits needed to represent the length of a
         sequence."""

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py (122886 => 122887)


--- trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py	2012-07-17 23:06:38 UTC (rev 122886)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py	2012-07-17 23:08:10 UTC (rev 122887)
@@ -194,6 +194,50 @@
     def help_printing(self):
         self._write(HELP_PRINTING)
 
+    def print_expected(self, num_all_test_files, result_summary, tests_with_result_type_callback):
+        self._print_expected('Found %s.' % grammar.pluralize('test', num_all_test_files))
+        self._print_expected_results_of_type(result_summary, test_expectations.PASS, "passes", tests_with_result_type_callback)
+        self._print_expected_results_of_type(result_summary, test_expectations.FAIL, "failures", tests_with_result_type_callback)
+        self._print_expected_results_of_type(result_summary, test_expectations.FLAKY, "flaky", tests_with_result_type_callback)
+        self._print_expected_results_of_type(result_summary, test_expectations.SKIP, "skipped", tests_with_result_type_callback)
+        self._print_expected('')
+
+        if self._options.repeat_each > 1:
+            self._print_expected('Running each test %d times.' % self._options.repeat_each)
+        if self._options.iterations > 1:
+            self._print_expected('Running %d iterations of the tests.' % self._options.iterations)
+        if self._options.iterations > 1 or self._options.repeat_each > 1:
+            self._print_expected('')
+
+    def _print_expected_results_of_type(self, result_summary,
+                                        result_type, result_type_str, tests_with_result_type_callback):
+        """Print the number of the tests in a given result class.
+
+        Args:
+          result_summary - the object containing all the results to report on
+          result_type - the particular result type to report in the summary.
+          result_type_str - a string description of the result_type.
+          expectations - populated TestExpectations object for stats
+        """
+        tests = tests_with_result_type_callback(result_type)
+        now = result_summary.tests_by_timeline[test_expectations.NOW]
+        wontfix = result_summary.tests_by_timeline[test_expectations.WONTFIX]
+
+        # We use a fancy format string in order to print the data out in a
+        # nicely-aligned table.
+        fmtstr = ("Expect: %%5d %%-8s (%%%dd now, %%%dd wontfix)"
+                  % (self._num_digits(now), self._num_digits(wontfix)))
+        self._print_expected(fmtstr %
+            (len(tests), result_type_str, len(tests & now), len(tests & wontfix)))
+
+    def _num_digits(self, num):
+        """Returns the number of digits needed to represent the length of a
+        sequence."""
+        ndigits = 1
+        if len(num):
+            ndigits = int(math.log10(len(num))) + 1
+        return ndigits
+
     def print_results(self, run_time, thread_timings, test_timings, individual_test_timings, result_summary, unexpected_results):
         self._print_timing_statistics(run_time, thread_timings, test_timings, individual_test_timings, result_summary)
         self._print_result_summary(result_summary)
@@ -420,7 +464,7 @@
     def print_config(self, msg):
         self.write(msg, 'config')
 
-    def print_expected(self, msg):
+    def _print_expected(self, msg):
         self.write(msg, 'expected')
 
     def print_timing(self, msg):

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/views/printing_unittest.py (122886 => 122887)


--- trunk/Tools/Scripts/webkitpy/layout_tests/views/printing_unittest.py	2012-07-17 23:06:38 UTC (rev 122886)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/views/printing_unittest.py	2012-07-17 23:08:10 UTC (rev 122887)
@@ -188,7 +188,7 @@
         self.do_switch_tests('print_config', 'config', to_buildbot=False)
 
     def test_print_expected(self):
-        self.do_switch_tests('print_expected', 'expected', to_buildbot=False)
+        self.do_switch_tests('_print_expected', 'expected', to_buildbot=False)
 
     def test_print_timing(self):
         self.do_switch_tests('print_timing', 'timing', to_buildbot=False)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to