third_party/blink/tools/blinkpy/web_tests/update_expectations.py
def _can_delete_line(self, expectation):
        """Returns whether a given line in the expectations can be removed.

        Uses results from builder bots to determine if a given line is stale and
        can safely be removed from the TestExpectations file. (i.e. remove if
        the bots show that it's not flaky.) There are also some rules about when
        not to remove lines (e.g. never remove lines with Rebaseline
        expectations, don't remove non-flaky expectations, etc.)

        Args:
            test_expectation_line (TestExpectationLine): A line in the test
                expectation file to test for possible removal.

        Returns:
            True if the line can be removed, False otherwise.
        """
        expected_results = expectation.results

        if not expected_results:
            return False

        # Don't check lines that have expectations like Skip or Slow.
        if ResultType.Skip in expected_results or expectation.is_slow_test:
            return False

        # Don't check consistent passes.
        if len(expected_results) == 1 and ResultType.Pass in expected_results:
            return False

        # Don't check flakes in fail mode.
        if self._type == 'fail' and ResultType.Pass in expected_results:
            return False

        # Don't check failures in flake mode.
        if self._type == 'flake' and ResultType.Pass not in expected_results:
            return False

        # Initialize OS version to OS dictionary.
        if not self._version_to_os:
            for os, os_versions in \
                self._port.configuration_specifier_macros().items():
                for version in os_versions:
                    self._version_to_os[version.lower()] = os.lower()

        # The line can be deleted if none of the expectations appear in the
        # actual results or only a PASS expectation appears in the actual
        # results.
        builders_checked = []
        builders = []
        for config in self._port.all_test_configurations():
            if set(expectation.tags).issubset(
                    set([
                        self._version_to_os[config.version.lower()],
                        config.version.lower(),
                        config.build_type.lower()
                    ])):
                try_server_configs = [False]
                if self._include_cq_results:
                    try_server_configs.append(True)
                for is_try_server in try_server_configs:
                    builder_name = self._host.builders.builder_name_for_specifiers(
                            config.version, config.build_type, is_try_server)
                    if not builder_name:
                        _log.debug('No builder with config %s for %s',
                                   config, 'CQ' if is_try_server else 'CI')
                        # For many configurations, there is no matching builder in
                        # blinkpy/common/config/builders.json. We ignore these
                        # configurations and make decisions based only on configurations
                        # with actual builders.
                        continue
                    builders.append(builder_name)

        for builder_name in builders:

            builders_checked.append(builder_name)

            if builder_name not in self._builder_results_by_path.keys():
                _log.error('Failed to find results for builder "%s"',
                           builder_name)
                return False

            results_by_path = self._builder_results_by_path[builder_name]

            # No results means the tests were all skipped, or all results are passing.
            if expectation.test not in results_by_path.keys():
                if self._remove_missing:
                    continue
                return False

            results_for_single_test = set(results_by_path[expectation.test])
            expectations_met = expected_results & results_for_single_test
            if (expectations_met != set([ResultType.Pass])
                    and expectations_met != set([])):
                return False
        if builders_checked:
            _log.debug('Checked builders:\n  %s',
                       '\n  '.join(builders_checked))
        else:
            _log.warning('No matching builders for line, deleting line.')
        return True
Returns whether a given line in the expectations can be removed.

        Uses results from builder bots to determine if a given line is stale and
        can safely be removed from the TestExpectations file. (i.e. remove if
        the bots show that it's not flaky.) There are also some rules about when
        not to remove lines (e.g. never remove lines with Rebaseline
        expectations, don't remove non-flaky expectations, etc.)

        Args:
            test_expectation_line (TestExpectationLine): A line in the test
                expectation file to test for possible removal.

        Returns:
            True if the line can be removed, False otherwise.
        
Returns whether a given line in the expectations can be removed.
Uses results from builder bots to determine if a given line is stale and
can safely be removed from the TestExpectations file.  There are also some rules about when
not to remove lines
Returns whether a given line in the expectations can be removed . Uses results from builder bots to determine if a given line is stale and can safely be removed from the TestExpectations file . There are also some rules about when not to remove lines
def _can_delete_line(self, expectation):
        expected_results = expectation.results
        if not expected_results:
            return False
        if ResultType.Skip in expected_results or expectation.is_slow_test:
            return False
        if len(expected_results) == 1 and ResultType.Pass in expected_results:
            return False
        if self._type == 'fail' and ResultType.Pass in expected_results:
            return False
        if self._type == 'flake' and ResultType.Pass not in expected_results:
            return False
        if not self._version_to_os:
            for os, os_versions in \
                self._port.configuration_specifier_macros().items():
                for version in os_versions:
                    self._version_to_os[version.lower()] = os.lower()
        builders_checked = []
        builders = []
        for config in self._port.all_test_configurations():
            if set(expectation.tags).issubset(
                    set([
                        self._version_to_os[config.version.lower()],
                        config.version.lower(),
                        config.build_type.lower()
                    ])):
                try_server_configs = [False]
                if self._include_cq_results:
                    try_server_configs.append(True)
                for is_try_server in try_server_configs:
                    builder_name = self._host.builders.builder_name_for_specifiers(
                            config.version, config.build_type, is_try_server)
                    if not builder_name:
                        _log.debug('No builder with config %s for %s',
                                   config, 'CQ' if is_try_server else 'CI')
                        continue
                    builders.append(builder_name)
        for builder_name in builders:
            builders_checked.append(builder_name)
            if builder_name not in self._builder_results_by_path.keys():
                _log.error('Failed to find results for builder "%s"',
                           builder_name)
                return False
            results_by_path = self._builder_results_by_path[builder_name]
            if expectation.test not in results_by_path.keys():
                if self._remove_missing:
                    continue
                return False
            results_for_single_test = set(results_by_path[expectation.test])
            expectations_met = expected_results & results_for_single_test
            if (expectations_met != set([ResultType.Pass])
                    and expectations_met != set([])):
                return False
        if builders_checked:
            _log.debug('Checked builders:\n  %s',
                       '\n  '.join(builders_checked))
        else:
            _log.warning('No matching builders for line, deleting line.')
        return True
def _can_delete_line ( self , expectation ) : expected_results = expectation . results if not expected_results : return False if ResultType . Skip in expected_results or expectation . is_slow_test : return False if len ( expected_results ) == 1 and ResultType . Pass in expected_results : return False if self . _type == 'fail' and ResultType . Pass in expected_results : return False if self . _type == 'flake' and ResultType . Pass not in expected_results : return False if not self . _version_to_os : for os , os_versions in self . _port . configuration_specifier_macros ( ) . items ( ) : for version in os_versions : self . _version_to_os [ version . lower ( ) ] = os . lower ( ) builders_checked = [ ] builders = [ ] for config in self . _port . all_test_configurations ( ) : if set ( expectation . tags ) . issubset ( set ( [ self . _version_to_os [ config . version . lower ( ) ] , config . version . lower ( ) , config . build_type . lower ( ) ] ) ) : try_server_configs = [ False ] if self . _include_cq_results : try_server_configs . append ( True ) for is_try_server in try_server_configs : builder_name = self . _host . builders . builder_name_for_specifiers ( config . version , config . build_type , is_try_server ) if not builder_name : _log . debug ( 'No builder with config %s for %s' , config , 'CQ' if is_try_server else 'CI' ) continue builders . append ( builder_name ) for builder_name in builders : builders_checked . append ( builder_name ) if builder_name not in self . _builder_results_by_path . keys ( ) : _log . error ( 'Failed to find results for builder "%s"' , builder_name ) return False results_by_path = self . _builder_results_by_path [ builder_name ] if expectation . test not in results_by_path . keys ( ) : if self . _remove_missing : continue return False results_for_single_test = set ( results_by_path [ expectation . test ] ) expectations_met = expected_results & results_for_single_test if ( expectations_met != set ( [ ResultType . Pass ] ) and expectations_met != set ( [ ] ) ) : return False if builders_checked : _log . debug ( 'Checked builders:\n  %s' , '\n  ' . join ( builders_checked ) ) else : _log . warning ( 'No matching builders for line, deleting line.' ) return True
Returns whether a given line in the expectations can be removed.
Returns whether a given line in the expectations can be removed .
"""Returns whether a given line in the expectations can be removed.

        Uses results from builder bots to determine if a given line is stale and
        can safely be removed from the TestExpectations file. (i.e. remove if
        the bots show that it's not flaky.) There are also some rules about when
        not to remove lines (e.g. never remove lines with Rebaseline
        expectations, don't remove non-flaky expectations, etc.)

        Args:
            test_expectation_line (TestExpectationLine): A line in the test
                expectation file to test for possible removal.

        Returns:
            True if the line can be removed, False otherwise.
        """ # Don't check lines that have expectations like Skip or Slow. # Don't check consistent passes. # Don't check flakes in fail mode. # Don't check failures in flake mode. # Initialize OS version to OS dictionary. # The line can be deleted if none of the expectations appear in the # actual results or only a PASS expectation appears in the actual # results. # For many configurations, there is no matching builder in # blinkpy/common/config/builders.json. We ignore these # configurations and make decisions based only on configurations # with actual builders. # No results means the tests were all skipped, or all results are passing.
True if the line can be removed, False otherwise.
True if the line can be removed False otherwise .
self
expectation
test_expectation_line
A line in the test
expectation file to test for possible removal.
A line in the test expectation file to test for possible removal .