def test_move_baselines_skip_git_commands(self): self.fs.write_text_file(MOCK_WEB_TESTS + 'VirtualTestSuites', '[]') self.fs.write_binary_file( MOCK_WEB_TESTS + 'platform/win/another/test-expected.txt', 'result A') self.fs.write_binary_file( MOCK_WEB_TESTS + 'platform/mac/another/test-expected.txt', 'result A') self.fs.write_binary_file(MOCK_WEB_TESTS + '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_WEB_TESTS + 'platform/win': 'aaa', MOCK_WEB_TESTS + 'platform/mac': 'aaa', MOCK_WEB_TESTS[:-1]: 'bbb', }, { MOCK_WEB_TESTS + 'platform/linux': 'bbb', MOCK_WEB_TESTS[:-1]: 'aaa', }) self.assertEqual( self.fs.read_binary_file(MOCK_WEB_TESTS + 'another/test-expected.txt'), 'result A')
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')
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)
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)