Changeset 251961 in webkit


Ignore:
Timestamp:
Nov 1, 2019 6:17:10 PM (4 years ago)
Author:
Jonathan Bedard
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.

Location:
trunk/Tools
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r251959 r251961  
     12019-11-01  Jonathan Bedard  <jbedard@apple.com>
     2
     3        Python 3: Add support in webkitpy.layout_tests.model
     4        https://bugs.webkit.org/show_bug.cgi?id=203702
     5
     6        Reviewed by Stephanie Lewis.
     7
     8        * Scripts/test-webkitpy-python3: Add webkitpy.layout_tests.model.
     9        * Scripts/webkitpy/layout_tests/models/test_configuration.py:
     10        (SpecifierSorter.sort_specifiers): Convert iterator to list.
     11        (TestConfigurationConverter.to_config_set): Use reduce from functors.
     12        (TestConfigurationConverter.intersect_combination): Ditto.
     13        * Scripts/webkitpy/layout_tests/models/test_expectations.py:
     14        (TestExpectationsModel.get_test_set_for_keyword): Use iterators in both Python 2
     15        and Python 3.
     16        (TestExpectationsModel._remove_from_sets): Ditto.
     17        (TestExpectations.parse_generic_expectations): Covert iterators to lists for indexing.
     18        (TestExpectations.parse_default_port_expectations): Ditto.
     19        (TestExpectations.parse_override_expectations): Ditto.
     20        (TestExpectations.remove_configuration_from_test): Use any instead of just checking the
     21        first element in the set.
     22        * Scripts/webkitpy/layout_tests/models/test_run_results.py:
     23        (summarize_results): Use items instead of iteritems.
     24
    1252019-11-01  Devin Rousso  <drousso@apple.com>
    226
  • trunk/Tools/Scripts/test-webkitpy-python3

    r251955 r251961  
    3636PYTHON3_COMPATIBLE_DIRECTORIES = [
    3737  'webkitpy.common',
     38  'webkitpy.layout_tests.models',
    3839  'webkitpy.port',
    3940  'webkitpy.results',
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py

    r225856 r251961  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29import functools
    2930import itertools
    3031
     
    9899
    99100    def sort_specifiers(self, specifiers):
    100         category_slots = map(lambda x: [], TestConfiguration.category_order())
     101        category_slots = list(map(lambda x: [], TestConfiguration.category_order()))
    101102        for specifier in specifiers:
    102103            category_slots[self.specifier_priority(specifier)].append(specifier)
     
    106107            return result + specifier_list
    107108
    108         return reduce(sort_and_return, category_slots, [])
     109        return functools.reduce(sort_and_return, category_slots, [])
    109110
    110111
     
    163164                matching_sets.setdefault(category, set()).update(configurations)
    164165
    165         return reduce(set.intersection, matching_sets.values())
     166        return functools.reduce(set.intersection, matching_sets.values())
    166167
    167168    @classmethod
     
    197198    @classmethod
    198199    def intersect_combination(cls, combination):
    199         return reduce(set.intersection, [set(specifiers) for specifiers in combination])
     200        return functools.reduce(set.intersection, [set(specifiers) for specifiers in combination])
    200201
    201202    @classmethod
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py

    r251112 r251961  
    3333import logging
    3434import re
    35 
     35import sys
     36
     37from webkitpy.common.iteration_compatibility import iteritems, itervalues
    3638from webkitpy.layout_tests.models.test_configuration import TestConfigurationConverter
    3739
     
    567569        # We must not have an index on this modifier.
    568570        matching_tests = set()
    569         for test, modifiers in self._test_to_modifiers.iteritems():
     571        for test, modifiers in iteritems(self._test_to_modifiers):
    570572            if keyword.lower() in modifiers:
    571573                matching_tests.add(test)
     
    695697          test: test to look for
    696698          dict: dict of sets of files"""
    697         for set_of_tests in dict_of_sets_of_tests.itervalues():
     699        for set_of_tests in itervalues(dict_of_sets_of_tests):
    698700            if test in set_of_tests:
    699701                set_of_tests.remove(test)
     
    950952        if self._port.path_to_generic_test_expectations_file() in self._expectations_dict:
    951953            if self._include_generic:
    952                 expectations = self._parser.parse(self._expectations_dict.keys()[self._expectations_dict_index], self._expectations_dict.values()[self._expectations_dict_index])
     954                expectations = self._parser.parse(list(self._expectations_dict.keys())[self._expectations_dict_index], list(self._expectations_dict.values())[self._expectations_dict_index])
    953955                self._add_expectations(expectations)
    954956                self._expectations += expectations
     
    957959    def parse_default_port_expectations(self):
    958960        if len(self._expectations_dict) > self._expectations_dict_index:
    959             expectations = self._parser.parse(self._expectations_dict.keys()[self._expectations_dict_index], self._expectations_dict.values()[self._expectations_dict_index])
     961            expectations = self._parser.parse(list(self._expectations_dict.keys())[self._expectations_dict_index], list(self._expectations_dict.values())[self._expectations_dict_index])
    960962            self._add_expectations(expectations)
    961963            self._expectations += expectations
     
    964966    def parse_override_expectations(self):
    965967        while len(self._expectations_dict) > self._expectations_dict_index and self._include_overrides:
    966             expectations = self._parser.parse(self._expectations_dict.keys()[self._expectations_dict_index], self._expectations_dict.values()[self._expectations_dict_index])
     968            expectations = self._parser.parse(list(self._expectations_dict.keys())[self._expectations_dict_index], list(self._expectations_dict.values())[self._expectations_dict_index])
    967969            self._add_expectations(expectations)
    968970            self._expectations += expectations
     
    10511053            if expectation.name != test or expectation.is_flaky() or not expectation.parsed_expectations:
    10521054                continue
    1053             if iter(expectation.parsed_expectations).next() not in (FAIL, IMAGE):
     1055            if not any([value in (FAIL, IMAGE) for value in expectation.parsed_expectations]):
    10541056                continue
    10551057            if test_configuration not in expectation.matching_configurations:
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_run_results.py

    r240150 r251961  
    3131import logging
    3232import signal
    33 
     33import sys
     34
     35from webkitpy.common.iteration_compatibility import iteritems
    3436from webkitpy.layout_tests.models import test_expectations
    3537from webkitpy.layout_tests.models import test_failures
     
    221223    num_regressions = 0
    222224    keywords = {}
    223     for expectation_string, expectation_enum in test_expectations.TestExpectations.EXPECTATIONS.iteritems():
     225    for expectation_string, expectation_enum in test_expectations.TestExpectations.EXPECTATIONS.items():
    224226        keywords[expectation_enum] = expectation_string.upper()
    225227
    226     for modifier_string, modifier_enum in test_expectations.TestExpectations.MODIFIERS.iteritems():
     228    for modifier_string, modifier_enum in test_expectations.TestExpectations.MODIFIERS.items():
    227229        keywords[modifier_enum] = modifier_string.upper()
    228230
     
    230232    other_crashes_dict = {}
    231233
    232     for test_name, result in initial_results.results_by_name.iteritems():
     234    for test_name, result in iteritems(initial_results.results_by_name):
    233235        # Note that if a test crashed in the original run, we ignore
    234236        # whether or not it crashed when we retried it (if we retried it),
     
    239241        # This works because tests are run on the first device type which won't skip them, regardless of other expectations, and never re-run.
    240242        expected = 'SKIP'
    241         expectations = expectations_by_type.values()[0]
    242         for element in expectations_by_type.itervalues():
     243        expectations = list(expectations_by_type.values())[0]
     244        for element in expectations_by_type.values():
    243245            test_expectation = element.filtered_expectations_for_test(test_name, pixel_tests_enabled, port_obj._options.world_leaks)
    244246            expected = element.model().expectations_to_string(test_expectation)
Note: See TracChangeset for help on using the changeset viewer.