Title: [251961] trunk/Tools
Revision
251961
Author
jbed...@apple.com
Date
2019-11-01 18:17:10 -0700 (Fri, 01 Nov 2019)

Log Message

Python 3: Add support in webkitpy.layout_tests.model
https://bugs.webkit.org/show_bug.cgi?id=203702

Reviewed by Stephanie Lewis.

* Scripts/test-webkitpy-python3: Add webkitpy.layout_tests.model.
* Scripts/webkitpy/layout_tests/models/test_configuration.py:
(SpecifierSorter.sort_specifiers): Convert iterator to list.
(TestConfigurationConverter.to_config_set): Use reduce from functors.
(TestConfigurationConverter.intersect_combination): Ditto.
* Scripts/webkitpy/layout_tests/models/test_expectations.py:
(TestExpectationsModel.get_test_set_for_keyword): Use iterators in both Python 2
and Python 3.
(TestExpectationsModel._remove_from_sets): Ditto.
(TestExpectations.parse_generic_expectations): Covert iterators to lists for indexing.
(TestExpectations.parse_default_port_expectations): Ditto.
(TestExpectations.parse_override_expectations): Ditto.
(TestExpectations.remove_configuration_from_test): Use any instead of just checking the
first element in the set.
* Scripts/webkitpy/layout_tests/models/test_run_results.py:
(summarize_results): Use items instead of iteritems.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (251960 => 251961)


--- trunk/Tools/ChangeLog	2019-11-02 00:54:04 UTC (rev 251960)
+++ trunk/Tools/ChangeLog	2019-11-02 01:17:10 UTC (rev 251961)
@@ -1,3 +1,27 @@
+2019-11-01  Jonathan Bedard  <jbed...@apple.com>
+
+        Python 3: Add support in webkitpy.layout_tests.model
+        https://bugs.webkit.org/show_bug.cgi?id=203702
+
+        Reviewed by Stephanie Lewis.
+
+        * Scripts/test-webkitpy-python3: Add webkitpy.layout_tests.model.
+        * Scripts/webkitpy/layout_tests/models/test_configuration.py:
+        (SpecifierSorter.sort_specifiers): Convert iterator to list.
+        (TestConfigurationConverter.to_config_set): Use reduce from functors.
+        (TestConfigurationConverter.intersect_combination): Ditto.
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py:
+        (TestExpectationsModel.get_test_set_for_keyword): Use iterators in both Python 2
+        and Python 3.
+        (TestExpectationsModel._remove_from_sets): Ditto.
+        (TestExpectations.parse_generic_expectations): Covert iterators to lists for indexing.
+        (TestExpectations.parse_default_port_expectations): Ditto.
+        (TestExpectations.parse_override_expectations): Ditto.
+        (TestExpectations.remove_configuration_from_test): Use any instead of just checking the
+        first element in the set.
+        * Scripts/webkitpy/layout_tests/models/test_run_results.py:
+        (summarize_results): Use items instead of iteritems.
+
 2019-11-01  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: Timelines: add a timeline that shows information about any recorded CSS animation/transition

Modified: trunk/Tools/Scripts/test-webkitpy-python3 (251960 => 251961)


--- trunk/Tools/Scripts/test-webkitpy-python3	2019-11-02 00:54:04 UTC (rev 251960)
+++ trunk/Tools/Scripts/test-webkitpy-python3	2019-11-02 01:17:10 UTC (rev 251961)
@@ -35,6 +35,7 @@
 
 PYTHON3_COMPATIBLE_DIRECTORIES = [
   'webkitpy.common',
+  'webkitpy.layout_tests.models',
   'webkitpy.port',
   'webkitpy.results',
   'webkitpy.xcode',

Added: trunk/Tools/Scripts/webkitpy/common/iteration_compatibility.py (0 => 251961)


--- trunk/Tools/Scripts/webkitpy/common/iteration_compatibility.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/iteration_compatibility.py	2019-11-02 01:17:10 UTC (rev 251961)
@@ -0,0 +1,44 @@
+# Copyright (C) 2019 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import sys
+
+
+def iteritems(dictionary):
+    if sys.version_info > (3, 0):
+        return dictionary.items()
+    else:
+        return dictionary.iteritems()
+
+
+def iterkeys(dictionary):
+    if sys.version_info > (3, 0):
+        return dictionary.keys()
+    else:
+        return dictionary.iterkeys()
+
+
+def itervalues(dictionary):
+    if sys.version_info > (3, 0):
+        return dictionary.values()
+    else:
+        return dictionary.itervalues()

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py (251960 => 251961)


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py	2019-11-02 00:54:04 UTC (rev 251960)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py	2019-11-02 01:17:10 UTC (rev 251961)
@@ -26,6 +26,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import functools
 import itertools
 
 
@@ -97,7 +98,7 @@
         return self._specifier_to_category.get(specifier)
 
     def sort_specifiers(self, specifiers):
-        category_slots = map(lambda x: [], TestConfiguration.category_order())
+        category_slots = list(map(lambda x: [], TestConfiguration.category_order()))
         for specifier in specifiers:
             category_slots[self.specifier_priority(specifier)].append(specifier)
 
@@ -105,7 +106,7 @@
             specifier_list.sort()
             return result + specifier_list
 
-        return reduce(sort_and_return, category_slots, [])
+        return functools.reduce(sort_and_return, category_slots, [])
 
 
 class TestConfigurationConverter(object):
@@ -162,7 +163,7 @@
                 category = self._specifier_sorter.category_for_specifier(expanded_specifier)
                 matching_sets.setdefault(category, set()).update(configurations)
 
-        return reduce(set.intersection, matching_sets.values())
+        return functools.reduce(set.intersection, matching_sets.values())
 
     @classmethod
     def collapse_macros(cls, macros_dict, specifiers_list):
@@ -196,7 +197,7 @@
 
     @classmethod
     def intersect_combination(cls, combination):
-        return reduce(set.intersection, [set(specifiers) for specifiers in combination])
+        return functools.reduce(set.intersection, [set(specifiers) for specifiers in combination])
 
     @classmethod
     def symmetric_difference(cls, iterable):

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py (251960 => 251961)


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2019-11-02 00:54:04 UTC (rev 251960)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2019-11-02 01:17:10 UTC (rev 251961)
@@ -32,7 +32,9 @@
 
 import logging
 import re
+import sys
 
+from webkitpy.common.iteration_compatibility import iteritems, itervalues
 from webkitpy.layout_tests.models.test_configuration import TestConfigurationConverter
 
 _log = logging.getLogger(__name__)
@@ -566,7 +568,7 @@
 
         # We must not have an index on this modifier.
         matching_tests = set()
-        for test, modifiers in self._test_to_modifiers.iteritems():
+        for test, modifiers in iteritems(self._test_to_modifiers):
             if keyword.lower() in modifiers:
                 matching_tests.add(test)
         return matching_tests
@@ -694,7 +696,7 @@
         Args:
           test: test to look for
           dict: dict of sets of files"""
-        for set_of_tests in dict_of_sets_of_tests.itervalues():
+        for set_of_tests in itervalues(dict_of_sets_of_tests):
             if test in set_of_tests:
                 set_of_tests.remove(test)
 
@@ -949,7 +951,7 @@
     def parse_generic_expectations(self):
         if self._port.path_to_generic_test_expectations_file() in self._expectations_dict:
             if self._include_generic:
-                expectations = self._parser.parse(self._expectations_dict.keys()[self._expectations_dict_index], self._expectations_dict.values()[self._expectations_dict_index])
+                expectations = self._parser.parse(list(self._expectations_dict.keys())[self._expectations_dict_index], list(self._expectations_dict.values())[self._expectations_dict_index])
                 self._add_expectations(expectations)
                 self._expectations += expectations
             self._expectations_dict_index += 1
@@ -956,7 +958,7 @@
 
     def parse_default_port_expectations(self):
         if len(self._expectations_dict) > self._expectations_dict_index:
-            expectations = self._parser.parse(self._expectations_dict.keys()[self._expectations_dict_index], self._expectations_dict.values()[self._expectations_dict_index])
+            expectations = self._parser.parse(list(self._expectations_dict.keys())[self._expectations_dict_index], list(self._expectations_dict.values())[self._expectations_dict_index])
             self._add_expectations(expectations)
             self._expectations += expectations
             self._expectations_dict_index += 1
@@ -963,7 +965,7 @@
 
     def parse_override_expectations(self):
         while len(self._expectations_dict) > self._expectations_dict_index and self._include_overrides:
-            expectations = self._parser.parse(self._expectations_dict.keys()[self._expectations_dict_index], self._expectations_dict.values()[self._expectations_dict_index])
+            expectations = self._parser.parse(list(self._expectations_dict.keys())[self._expectations_dict_index], list(self._expectations_dict.values())[self._expectations_dict_index])
             self._add_expectations(expectations)
             self._expectations += expectations
             self._expectations_dict_index += 1
@@ -1050,7 +1052,7 @@
         for expectation in self._expectations:
             if expectation.name != test or expectation.is_flaky() or not expectation.parsed_expectations:
                 continue
-            if iter(expectation.parsed_expectations).next() not in (FAIL, IMAGE):
+            if not any([value in (FAIL, IMAGE) for value in expectation.parsed_expectations]):
                 continue
             if test_configuration not in expectation.matching_configurations:
                 continue

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_run_results.py (251960 => 251961)


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_run_results.py	2019-11-02 00:54:04 UTC (rev 251960)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_run_results.py	2019-11-02 01:17:10 UTC (rev 251961)
@@ -30,7 +30,9 @@
 import datetime
 import logging
 import signal
+import sys
 
+from webkitpy.common.iteration_compatibility import iteritems
 from webkitpy.layout_tests.models import test_expectations
 from webkitpy.layout_tests.models import test_failures
 
@@ -220,16 +222,16 @@
     num_missing = 0
     num_regressions = 0
     keywords = {}
-    for expectation_string, expectation_enum in test_expectations.TestExpectations.EXPECTATIONS.iteritems():
+    for expectation_string, expectation_enum in test_expectations.TestExpectations.EXPECTATIONS.items():
         keywords[expectation_enum] = expectation_string.upper()
 
-    for modifier_string, modifier_enum in test_expectations.TestExpectations.MODIFIERS.iteritems():
+    for modifier_string, modifier_enum in test_expectations.TestExpectations.MODIFIERS.items():
         keywords[modifier_enum] = modifier_string.upper()
 
     tests = {}
     other_crashes_dict = {}
 
-    for test_name, result in initial_results.results_by_name.iteritems():
+    for test_name, result in iteritems(initial_results.results_by_name):
         # Note that if a test crashed in the original run, we ignore
         # whether or not it crashed when we retried it (if we retried it),
         # and always consider the result not flaky.
@@ -238,8 +240,8 @@
         # We're basically trying to find the first non-skip expectation, and use that expectation object for the remainder of the loop.
         # This works because tests are run on the first device type which won't skip them, regardless of other expectations, and never re-run.
         expected = 'SKIP'
-        expectations = expectations_by_type.values()[0]
-        for element in expectations_by_type.itervalues():
+        expectations = list(expectations_by_type.values())[0]
+        for element in expectations_by_type.values():
             test_expectation = element.filtered_expectations_for_test(test_name, pixel_tests_enabled, port_obj._options.world_leaks)
             expected = element.model().expectations_to_string(test_expectation)
             if expected != 'SKIP':
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to