当前位置: 首页>>代码示例>>Python>>正文


Python PortFactory.test_expectations方法代码示例

本文整理汇总了Python中webkitpy.layout_tests.port.factory.PortFactory.test_expectations方法的典型用法代码示例。如果您正苦于以下问题:Python PortFactory.test_expectations方法的具体用法?Python PortFactory.test_expectations怎么用?Python PortFactory.test_expectations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webkitpy.layout_tests.port.factory.PortFactory的用法示例。


在下文中一共展示了PortFactory.test_expectations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Rebaseliner

# 需要导入模块: from webkitpy.layout_tests.port.factory import PortFactory [as 别名]
# 或者: from webkitpy.layout_tests.port.factory.PortFactory import test_expectations [as 别名]
class Rebaseliner(object):
    """Class to produce new baselines for a given platform."""

    REVISION_REGEX = r"<a href=\"(\d+)/\">"

    def __init__(
        self, running_port, target_port, platform, options, url_fetcher, zip_factory, scm, logged_before=False
    ):
        """
        Args:
            running_port: the Port the script is running on.
            target_port: the Port the script uses to find port-specific
                configuration information like the test_expectations.txt
                file location and the list of test platforms.
            platform: the test platform to rebaseline
            options: the command-line options object.
            url_fetcher: object that can fetch objects from URLs
            zip_factory: optional object that can fetch zip files from URLs
            scm: scm object for adding new baselines
            logged_before: whether the previous running port logged anything.
        """
        self._platform = platform
        self._options = options
        self._port = running_port
        self._filesystem = running_port._filesystem
        self._target_port = target_port

        # FIXME: This should get its PortFactory from a Host object.
        # Note: using running_port.executive, running_port.user since we can't get them from a host.
        self._rebaseline_port = PortFactory().get(
            platform, options, filesystem=self._filesystem, executive=running_port.executive, user=running_port.user
        )
        self._rebaselining_tests = set()
        self._rebaselined_tests = []
        self._logged_before = logged_before
        self.did_log = False

        # Create tests and expectations helper which is used to:
        #   -. compile list of tests that need rebaselining.
        #   -. update the tests in test_expectations file after rebaseline
        #      is done.
        expectations_str = self._rebaseline_port.test_expectations()
        self._test_expectations = test_expectations.TestExpectations(
            self._rebaseline_port, None, expectations_str, self._rebaseline_port.test_configuration(), False
        )
        self._url_fetcher = url_fetcher
        self._zip_factory = zip_factory
        self._scm = scm

    def run(self):
        """Run rebaseline process."""

        log_dashed_string("Compiling rebaselining tests", self._platform, logging.DEBUG)
        if not self._compile_rebaselining_tests():
            return False
        if not self._rebaselining_tests:
            return True

        self.did_log = True
        log_dashed_string("Downloading archive", self._platform, logging.DEBUG)
        archive_file = self._download_buildbot_archive()
        _log.debug("")
        if not archive_file:
            _log.error("No archive found.")
            return False

        log_dashed_string("Extracting and adding new baselines", self._platform, logging.DEBUG)
        self._extract_and_add_new_baselines(archive_file)
        archive_file.close()

        log_dashed_string("Updating rebaselined tests in file", self._platform)

        if len(self._rebaselining_tests) != len(self._rebaselined_tests):
            _log.debug("")
            _log.debug("NOT ALL TESTS WERE REBASELINED.")
            _log.debug("  Number marked for rebaselining: %d", len(self._rebaselining_tests))
            _log.debug("  Number actually rebaselined: %d", len(self._rebaselined_tests))
            _log.info("")
            return False

        _log.debug("  All tests needing rebaselining were successfully rebaselined.")
        _log.info("")
        return True

    def remove_rebaselining_expectations(self, tests, backup):
        """if backup is True, we backup the original test expectations file."""
        new_expectations = self._test_expectations.remove_rebaselined_tests(tests)
        path = self._target_port.path_to_test_expectations_file()
        if backup:
            date_suffix = time.strftime("%Y%m%d%H%M%S", time.localtime(time.time()))
            backup_file = "%s.orig.%s" % (path, date_suffix)
            if self._filesystem.exists(backup_file):
                self._filesystem.remove(backup_file)
            _log.debug('Saving original file to "%s"', backup_file)
            self._filesystem.move(path, backup_file)

        self._filesystem.write_text_file(path, new_expectations)
        # self._scm.add(path)

    def get_rebaselined_tests(self):
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


注:本文中的webkitpy.layout_tests.port.factory.PortFactory.test_expectations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。