third_party/blink/tools/blinkpy/web_tests/models/test_configuration.py
def to_specifiers_list(self, test_configuration_set):
        """Convert a set of TestConfiguration instances into one or more list of specifiers."""
        # Easy out: if the set is all configurations, the specifier is empty.
        if len(test_configuration_set) == len(self._all_test_configurations):
            return [[]]

        # 1) Build a list of specifier sets, discarding specifiers that don't add value.
        specifiers_list = []
        for config in test_configuration_set:
            values = set(config.values())
            for specifier, junk_specifier_set in \
                self._junk_specifier_combinations.items():
                if specifier in values:
                    values -= junk_specifier_set
            specifiers_list.append(frozenset(values))

        def try_collapsing(size, collapsing_sets):
            if len(specifiers_list) < size:
                return False
            for combination in itertools.combinations(specifiers_list, size):
                if self.symmetric_difference(combination) in collapsing_sets:
                    for item in combination:
                        specifiers_list.remove(item)
                    specifiers_list.append(
                        frozenset(self.intersect_combination(combination)))
                    return True
            return False

        # 2) Collapse specifier sets with common specifiers:
        #   (win7, release), (win7, debug) --> (win7, x86)
        for size, collapsing_sets in self._collapsing_sets_by_size.items():
            while try_collapsing(size, collapsing_sets):
                pass

        def try_abbreviating(collapsing_sets):
            if len(specifiers_list) < 2:
                return False
            for combination in itertools.combinations(specifiers_list, 2):
                for collapsing_set in collapsing_sets:
                    diff = self.symmetric_difference(combination)
                    if diff <= collapsing_set:
                        common = self.intersect_combination(combination)
                        for item in combination:
                            specifiers_list.remove(item)
                        specifiers_list.append(frozenset(common | diff))
                        return True
            return False

        # 3) Abbreviate specifier sets by combining specifiers across categories.
        #   (win7, release), (win10, release) --> (win7, win10, release)
        while try_abbreviating(list(self._collapsing_sets_by_size.values())):
            pass

        # 4) Substitute specifier subsets that match macros within each set:
        #   (win7, win10, release) -> (win, release)
        self.collapse_macros(self.configuration_macros, specifiers_list)

        macro_keys = set(self.configuration_macros.keys())

        # 5) Collapsing macros may have created combinations the can now be abbreviated.
        #   (win7, release), (linux, x86, release), (linux, x86_64, release)
        #   --> (win7, release), (linux, release) --> (win7, linux, release)
        while try_abbreviating(
            [self._collapsing_sets_by_category['version'] | macro_keys]):
            pass

        # 6) Remove cases where we have collapsed but have all macros.
        #   (android, win, mac, linux, release) --> (release)
        specifiers_to_remove = []
        for specifier_set in specifiers_list:
            if macro_keys <= specifier_set:
                specifiers_to_remove.append(specifier_set)

        for specifier_set in specifiers_to_remove:
            specifiers_list.remove(specifier_set)
            specifiers_list.append(frozenset(specifier_set - macro_keys))

        return specifiers_list
Convert a set of TestConfiguration instances into one or more list of specifiers.
Convert a set of TestConfiguration instances into one or more list of specifiers.
Convert a set of TestConfiguration instances into one or more list of specifiers .
def to_specifiers_list(self, test_configuration_set):
        if len(test_configuration_set) == len(self._all_test_configurations):
            return [[]]
        specifiers_list = []
        for config in test_configuration_set:
            values = set(config.values())
            for specifier, junk_specifier_set in \
                self._junk_specifier_combinations.items():
                if specifier in values:
                    values -= junk_specifier_set
            specifiers_list.append(frozenset(values))
        def try_collapsing(size, collapsing_sets):
            if len(specifiers_list) < size:
                return False
            for combination in itertools.combinations(specifiers_list, size):
                if self.symmetric_difference(combination) in collapsing_sets:
                    for item in combination:
                        specifiers_list.remove(item)
                    specifiers_list.append(
                        frozenset(self.intersect_combination(combination)))
                    return True
            return False
        for size, collapsing_sets in self._collapsing_sets_by_size.items():
            while try_collapsing(size, collapsing_sets):
                pass
        def try_abbreviating(collapsing_sets):
            if len(specifiers_list) < 2:
                return False
            for combination in itertools.combinations(specifiers_list, 2):
                for collapsing_set in collapsing_sets:
                    diff = self.symmetric_difference(combination)
                    if diff <= collapsing_set:
                        common = self.intersect_combination(combination)
                        for item in combination:
                            specifiers_list.remove(item)
                        specifiers_list.append(frozenset(common | diff))
                        return True
            return False
        while try_abbreviating(list(self._collapsing_sets_by_size.values())):
            pass
        self.collapse_macros(self.configuration_macros, specifiers_list)
        macro_keys = set(self.configuration_macros.keys())
        while try_abbreviating(
            [self._collapsing_sets_by_category['version'] | macro_keys]):
            pass
        specifiers_to_remove = []
        for specifier_set in specifiers_list:
            if macro_keys <= specifier_set:
                specifiers_to_remove.append(specifier_set)
        for specifier_set in specifiers_to_remove:
            specifiers_list.remove(specifier_set)
            specifiers_list.append(frozenset(specifier_set - macro_keys))
        return specifiers_list
def to_specifiers_list ( self , test_configuration_set ) : if len ( test_configuration_set ) == len ( self . _all_test_configurations ) : return [ [ ] ] specifiers_list = [ ] for config in test_configuration_set : values = set ( config . values ( ) ) for specifier , junk_specifier_set in self . _junk_specifier_combinations . items ( ) : if specifier in values : values -= junk_specifier_set specifiers_list . append ( frozenset ( values ) ) def try_collapsing ( size , collapsing_sets ) : if len ( specifiers_list ) < size : return False for combination in itertools . combinations ( specifiers_list , size ) : if self . symmetric_difference ( combination ) in collapsing_sets : for item in combination : specifiers_list . remove ( item ) specifiers_list . append ( frozenset ( self . intersect_combination ( combination ) ) ) return True return False for size , collapsing_sets in self . _collapsing_sets_by_size . items ( ) : while try_collapsing ( size , collapsing_sets ) : pass def try_abbreviating ( collapsing_sets ) : if len ( specifiers_list ) < 2 : return False for combination in itertools . combinations ( specifiers_list , 2 ) : for collapsing_set in collapsing_sets : diff = self . symmetric_difference ( combination ) if diff <= collapsing_set : common = self . intersect_combination ( combination ) for item in combination : specifiers_list . remove ( item ) specifiers_list . append ( frozenset ( common | diff ) ) return True return False while try_abbreviating ( list ( self . _collapsing_sets_by_size . values ( ) ) ) : pass self . collapse_macros ( self . configuration_macros , specifiers_list ) macro_keys = set ( self . configuration_macros . keys ( ) ) while try_abbreviating ( [ self . _collapsing_sets_by_category [ 'version' ] | macro_keys ] ) : pass specifiers_to_remove = [ ] for specifier_set in specifiers_list : if macro_keys <= specifier_set : specifiers_to_remove . append ( specifier_set ) for specifier_set in specifiers_to_remove : specifiers_list . remove ( specifier_set ) specifiers_list . append ( frozenset ( specifier_set - macro_keys ) ) return specifiers_list
Convert a set of TestConfiguration instances into one or more list of specifiers.
Convert a set of TestConfiguration instances into one or more list of specifiers .
"""Convert a set of TestConfiguration instances into one or more list of specifiers.""" # Easy out: if the set is all configurations, the specifier is empty. # 1) Build a list of specifier sets, discarding specifiers that don't add value. # 2) Collapse specifier sets with common specifiers: #   (win7, release), (win7, debug) --> (win7, x86) # 3) Abbreviate specifier sets by combining specifiers across categories. #   (win7, release), (win10, release) --> (win7, win10, release) # 4) Substitute specifier subsets that match macros within each set: #   (win7, win10, release) -> (win, release) # 5) Collapsing macros may have created combinations the can now be abbreviated. #   (win7, release), (linux, x86, release), (linux, x86_64, release) #   --> (win7, release), (linux, release) --> (win7, linux, release) # 6) Remove cases where we have collapsed but have all macros. #   (android, win, mac, linux, release) --> (release)
self
test_configuration_set