def test_move_baselines_skip_git_commands(self):
     self.fs.write_text_file(
         '/mock-checkout/third_party/WebKit/LayoutTests/VirtualTestSuites',
         '[]')
     self.fs.write_binary_file(
         '/mock-checkout/third_party/WebKit/LayoutTests/platform/win/another/test-expected.txt',
         'result A')
     self.fs.write_binary_file(
         '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac/another/test-expected.txt',
         'result A')
     self.fs.write_binary_file(
         '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt',
         'result B')
     baseline_optimizer = BaselineOptimizer(
         self.host, self.host.port_factory.get(),
         self.host.port_factory.all_port_names())
     baseline_optimizer._move_baselines(
         'another/test-expected.txt', {
             '/mock-checkout/third_party/WebKit/LayoutTests/platform/win':
             'aaa',
             '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac':
             'aaa',
             '/mock-checkout/third_party/WebKit/LayoutTests': 'bbb',
         }, {
             '/mock-checkout/third_party/WebKit/LayoutTests/platform/linux':
             'bbb',
             '/mock-checkout/third_party/WebKit/LayoutTests': 'aaa',
         })
     self.assertEqual(
         self.fs.read_binary_file(
             '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt'
         ), 'result A')
Пример #2
0
    def _assert_optimization(self,
                             results_by_directory,
                             directory_to_new_results,
                             baseline_dirname='',
                             host=None):
        host = host or MockHost()
        fs = host.filesystem
        layout_tests_dir = PathFinder(fs).layout_tests_dir()
        baseline_name = 'mock-baseline-expected.txt'
        fs.write_text_file(
            fs.join(layout_tests_dir, 'VirtualTestSuites'),
            '[{"prefix": "gpu", "base": "fast/canvas", "args": ["--foo"]}]')

        for dirname, contents in results_by_directory.items():
            fs.write_binary_file(
                fs.join(layout_tests_dir, dirname, baseline_name), contents)

        baseline_optimizer = BaselineOptimizer(
            host, host.port_factory.get(), host.port_factory.all_port_names())
        self.assertTrue(
            baseline_optimizer.optimize(
                fs.join(baseline_dirname, baseline_name)))

        for dirname, contents in directory_to_new_results.items():
            path = fs.join(layout_tests_dir, dirname, baseline_name)
            if contents is not None:
                self.assertEqual(fs.read_binary_file(path), contents)
    def _assert_optimization(self, results_by_directory, directory_to_new_results, baseline_dirname=''):
        layout_tests_dir = PathFinder(self.fs).layout_tests_dir()
        test_name = 'mock-test.html'
        baseline_name = 'mock-test-expected.txt'
        self.fs.write_text_file(
            self.fs.join(layout_tests_dir, 'VirtualTestSuites'),
            '[{"prefix": "gpu", "base": "fast/canvas", "args": ["--foo"]}]')

        for dirname, contents in results_by_directory.items():
            self.fs.write_binary_file(self.fs.join(layout_tests_dir, dirname, baseline_name), contents)

        baseline_optimizer = BaselineOptimizer(self.host, self.host.port_factory.get(), self.host.port_factory.all_port_names())
        self.assertTrue(baseline_optimizer.optimize(
            self.fs.join(baseline_dirname, test_name), 'txt'))

        for dirname, contents in directory_to_new_results.items():
            path = self.fs.join(layout_tests_dir, dirname, baseline_name)
            if contents is None:
                # Check files that are explicitly marked as absent.
                self.assertFalse(self.fs.exists(path), '%s should not exist after optimization' % path)
            else:
                self.assertEqual(self.fs.read_binary_file(path), contents, 'Content of %s != "%s"' % (path, contents))

        for dirname in results_by_directory:
            path = self.fs.join(layout_tests_dir, dirname, baseline_name)
            if dirname not in directory_to_new_results or directory_to_new_results[dirname] is None:
                self.assertFalse(self.fs.exists(path), '%s should not exist after optimization' % path)
Пример #4
0
 def test_move_baselines(self):
     host = MockHost()
     host.filesystem.write_text_file(
         '/mock-checkout/third_party/WebKit/LayoutTests/VirtualTestSuites',
         '[]')
     host.filesystem.write_binary_file(
         '/mock-checkout/third_party/WebKit/LayoutTests/platform/win/another/test-expected.txt',
         'result A')
     host.filesystem.write_binary_file(
         '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac/another/test-expected.txt',
         'result A')
     host.filesystem.write_binary_file(
         '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt',
         'result B')
     baseline_optimizer = BaselineOptimizer(
         host, host.port_factory.get(), host.port_factory.all_port_names())
     baseline_optimizer._move_baselines(
         'another/test-expected.txt', {
             '/mock-checkout/third_party/WebKit/LayoutTests/platform/win':
             'aaa',
             '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac':
             'aaa',
             '/mock-checkout/third_party/WebKit/LayoutTests': 'bbb',
         }, {
             '/mock-checkout/third_party/WebKit/LayoutTests': 'aaa',
         })
     self.assertEqual(
         host.filesystem.read_binary_file(
             '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt'
         ), 'result A')
Пример #5
0
 def execute(self, options, args, tool):
     self._tool = tool
     self._baseline_suffix_list = options.suffixes.split(',')
     port_names = tool.port_factory.all_port_names(options.platform)
     if not port_names:
         _log.error("No port names match '%s'", options.platform)
         return
     port = tool.port_factory.get(port_names[0])
     optimizer = BaselineOptimizer(tool, port, port_names)
     tests = port.tests(args)
     for test_name in tests:
         self._optimize_baseline(optimizer, test_name)