def _test_check_test_expectations(self, filename): options = MockOptions() options.git_commit = "" options.non_interactive = True tool = MockTool() tool.user = None # Will cause any access of tool.user to raise an exception. step = Commit(tool, options) state = { "changed_files": [filename + "XXX"], } tool.executive = MockExecutive(should_log=True, should_throw_when_run=False) with OutputCapture(level=logging.INFO) as captured: step.run(state) self.assertEqual(captured.root.log.getvalue(), 'Committed r49824: <https://commits.webkit.org/r49824>\n') state = { "changed_files": ["platform/chromium/" + filename], } with OutputCapture(level=logging.INFO) as captured: step.run(state) self.assertEqual( captured.root.log.getvalue(), '''MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/{}'], cwd=/mock-checkout Committed r49824: <https://commits.webkit.org/r49824> '''.format(filename), ) tool.executive = MockExecutive(should_log=True, should_throw_when_run={"platform/chromium/" + filename}) with self.assertRaises(ScriptError), OutputCapture(): step.run(state)
def _test_check_test_expectations(self, filename): capture = OutputCapture() options = MockOptions() options.git_commit = "" options.non_interactive = True tool = MockTool() tool.user = None # Will cause any access of tool.user to raise an exception. step = Commit(tool, options) state = { "changed_files": [filename + "XXX"], } tool.executive = MockExecutive(should_log=True, should_throw_when_run=False) expected_logs = "Committed r49824: <http://trac.webkit.org/changeset/49824>\n" capture.assert_outputs(self, step.run, [state], expected_logs=expected_logs) state = { "changed_files": ["platform/chromium/" + filename], } expected_logs = """MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/%s'], cwd=/mock-checkout Committed r49824: <http://trac.webkit.org/changeset/49824> """ % filename capture.assert_outputs(self, step.run, [state], expected_logs=expected_logs) tool.executive = MockExecutive(should_log=True, should_throw_when_run=set(["platform/chromium/" + filename])) self.assertRaises(ScriptError, capture.assert_outputs, self, step.run, [state])
def test_check_test_expectations(self): capture = OutputCapture() options = MockOptions() options.git_commit = "" tool = MockTool() step = Commit(tool, options) state = { "changed_files": ["test_expectations.txtXXX"], } tool.executive = MockExecutive(should_log=True, should_throw_when_run=False) capture.assert_outputs( self, step.run, [state], expected_stderr= "Committed r49824: <http://trac.webkit.org/changeset/49824>\n") state = { "changed_files": ["platform/chromium/test_expectations.txt"], } capture.assert_outputs( self, step.run, [state], expected_stderr= "MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/test_expectations.txt'], cwd=/mock-checkout\nCommitted r49824: <http://trac.webkit.org/changeset/49824>\n" ) tool.executive = MockExecutive( should_log=True, should_throw_when_run=set( ["platform/chromium/test_expectations.txt"])) self.assertRaises(SystemExit, capture.assert_outputs, self, step.run, [state])
def test_check_test_expectations(self): capture = OutputCapture() options = MockOptions() options.git_commit = "" tool = MockTool() step = Commit(tool, options) state = {"changed_files": ["test_expectations.txtXXX"]} tool.executive = MockExecutive(should_log=True, should_throw_when_run=False) capture.assert_outputs( self, step.run, [state], expected_stderr="Committed r49824: <http://trac.webkit.org/changeset/49824>\n" ) state = {"changed_files": ["platform/chromium/test_expectations.txt"]} capture.assert_outputs( self, step.run, [state], expected_stderr="MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/test_expectations.txt'], cwd=/mock-checkout\nCommitted r49824: <http://trac.webkit.org/changeset/49824>\n", ) tool.executive = MockExecutive( should_log=True, should_throw_when_run=set(["platform/chromium/test_expectations.txt"]) ) self.assertRaises(SystemExit, capture.assert_outputs, self, step.run, [state])
def test_rebaseline_test_internal_with_move_overwritten_baselines_to(self): old_exact_matches = builders._exact_matches try: builders._exact_matches = { "MOCK Leopard": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])}, "MOCK SnowLeopard": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier"])}, } command = RebaselineTest() tool = MockTool() tool.executive = MockExecutive(should_log=True) command.bind_to_tool(tool) port = tool.port_factory.get('test-mac-snowleopard') tool.filesystem.write_text_file(tool.filesystem.join(port.baseline_version_dir(), 'failures', 'expected', 'image-expected.txt'), '') options = MockOptions(optimize=True, builder="MOCK SnowLeopard", suffixes="txt", move_overwritten_baselines_to=["test-mac-leopard"], verbose=True, test="failures/expected/image.html") oc = OutputCapture() oc.capture_output() try: logs = '' command.execute(options, [], tool) finally: _, _, logs = oc.restore_output() self.assertTrue("Copying baseline from /test.checkout/LayoutTests/platform/test-mac-snowleopard/failures/expected/image-expected.txt to /test.checkout/LayoutTests/platform/test-mac-leopard/failures/expected/image-expected.txt.\n" in logs) finally: builders._exact_matches = old_exact_matches
def test_rebaseline_all(self): old_exact_matches = builders._exact_matches builders._exact_matches = { "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])}, "MOCK builder (Debug)": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier", "debug"])}, } command = RebaselineJson() tool = MockTool() options = MockOptions() options.optimize = True command.bind_to_tool(tool) tool.executive = MockExecutive(should_log=True) expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--builder', 'MOCK builder', '--test', 'user-scripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'user-scripts/another-test.html'], cwd=/mock-checkout """ OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder": ["txt", "png"]}}], expected_stderr=expected_stderr) expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--builder', 'MOCK builder (Debug)', '--test', 'user-scripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'user-scripts/another-test.html'], cwd=/mock-checkout """ OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt", "png"]}}], expected_stderr=expected_stderr) expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'MOCK builder', '--test', 'user-scripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'user-scripts/another-test.html'], cwd=/mock-checkout """ OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt", "png"], "MOCK builder": ["txt"]}}], expected_stderr=expected_stderr) builders._exact_matches = old_exact_matches
def test_rebaseline_multiple_builders_and_tests_command_line(self): old_exact_matches = builders._exact_matches try: builders._exact_matches = { "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])}, "MOCK builder2": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"])}, "MOCK builder3": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"])}, } command = Rebaseline() tool = MockTool() command.bind_to_tool(tool) for port_name in tool.port_factory.all_port_names(): port = tool.port_factory.get(port_name) for path in port.expectations_files(): tool.filesystem.write_text_file(path, '') tool.executive = MockExecutive(should_log=True) expected_stdout = """rebaseline-json: {'mock/path/to/test.html': {'MOCK builder2': ['wav', 'txt', 'png'], 'MOCK builder': ['wav', 'txt', 'png'], 'MOCK builder3': ['wav', 'txt', 'png']}, 'mock/path/to/test2.html': {'MOCK builder2': ['wav', 'txt', 'png'], 'MOCK builder': ['wav', 'txt', 'png'], 'MOCK builder3': ['wav', 'txt', 'png']}} """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'wav,txt,png', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'wav,txt,png', '--builder', 'MOCK builder', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'wav,txt,png', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test2.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'wav,txt,png', '--builder', 'MOCK builder', '--test', 'mock/path/to/test2.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'wav,txt,png', 'mock/path/to/test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'wav,txt,png', 'mock/path/to/test2.html'], cwd=/mock-checkout """ OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=True, builders=["MOCK builder,MOCK builder2", "MOCK builder3"], suffixes=["txt,png", "png,wav,txt"], verbose=True), ["mock/path/to/test.html", "mock/path/to/test2.html"], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr) finally: builders._exact_matches = old_exact_matches
def test_rebaseline_multiple_builders_and_tests_command_line(self): old_exact_matches = builders._exact_matches try: builders._exact_matches = { "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])}, "MOCK builder2": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"])}, "MOCK builder3": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"])}, } command = Rebaseline() tool = MockTool() command.bind_to_tool(tool) for port_name in tool.port_factory.all_port_names(): port = tool.port_factory.get(port_name) for path in port.expectations_files(): tool.filesystem.write_text_file(path, '') tool.executive = MockExecutive(should_log=True) expected_stdout = """rebaseline-json: {'mock/path/to/test.html': {'MOCK builder2': ['txt', 'png', 'wav'], 'MOCK builder': ['txt', 'png', 'wav'], 'MOCK builder3': ['txt', 'png', 'wav']}, 'mock/path/to/test2.html': {'MOCK builder2': ['txt', 'png', 'wav'], 'MOCK builder': ['txt', 'png', 'wav'], 'MOCK builder3': ['txt', 'png', 'wav']}} """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png,wav', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png,wav', '--builder', 'MOCK builder', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png,wav', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test2.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png,wav', '--builder', 'MOCK builder', '--test', 'mock/path/to/test2.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'wav,txt,png', 'mock/path/to/test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'wav,txt,png', 'mock/path/to/test2.html'], cwd=/mock-checkout """ OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=True, builders=["MOCK builder,MOCK builder2", "MOCK builder3"], suffixes=["txt", "png,wav"], verbose=True), ["mock/path/to/test.html", "mock/path/to/test2.html"], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr) finally: builders._exact_matches = old_exact_matches
def test_rollout_updates_working_copy(self): rollout = Rollout() tool = MockTool() tool.executive = MockExecutive(should_log=True) expected_stderr = "MOCK run_and_throw_if_fail: ['mock-update-webkit'], cwd=/mock-checkout\n" OutputCapture().assert_outputs(self, rollout._update_working_copy, [tool], expected_stderr=expected_stderr)
def test_can_build_and_test(self): queue = CommitQueue() tool = MockTool() tool.executive = Mock() queue.bind_to_tool(tool) self.assertTrue(queue._can_build_and_test()) expected_run_args = ["echo", "--status-host=example.com", "build-and-test", "--force-clean", "--build", "--test", "--non-interactive", "--no-update", "--build-style=both", "--quiet"] tool.executive.run_and_throw_if_fail.assert_called_with(expected_run_args)
def test_rebaseline_expectations(self): command = RebaselineExpectations() tool = MockTool() command.bind_to_tool(tool) for port_name in tool.port_factory.all_port_names(): port = tool.port_factory.get(port_name) tool.filesystem.write_text_file(port.path_to_test_expectations_file(), '') # Don't enable logging until after we create the mock expectation files as some Port.__init__'s run subcommands. tool.executive = MockExecutive(should_log=True) expected_stdout = """Retrieving results for chromium-gpu-mac-snowleopard from Webkit Mac10.6 - GPU. Retrieving results for chromium-gpu-win-win7 from Webkit Win7 - GPU. Retrieving results for chromium-gpu-win-xp from Webkit Win - GPU. Retrieving results for chromium-linux-x86 from Webkit Linux 32. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-linux-x86_64 from Webkit Linux. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-leopard from Webkit Mac10.5. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-snowleopard from Webkit Mac10.6. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-vista from Webkit Vista. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-win7 from Webkit Win7. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-xp from Webkit Win. userscripts/another-test.html userscripts/images.svg Optimizing baselines for userscripts/another-test.html. Optimizing baselines for userscripts/images.svg. """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/images.svg'], cwd=/mock-checkout """ command._tests_to_rebaseline = lambda port: [] if not port.name().find('-gpu-') == -1 else ['userscripts/another-test.html', 'userscripts/images.svg'] OutputCapture().assert_outputs(self, command.execute, [None, [], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
def _assert_run_webkit_patch(self, run_args): queue = TestQueue() tool = MockTool() tool.executive = Mock() queue.bind_to_tool(tool) queue.run_webkit_patch(run_args) expected_run_args = ["echo", "--status-host=example.com"] + run_args tool.executive.run_and_throw_if_fail.assert_called_with(expected_run_args)
def test_revert_updates_working_copy(self): revert = Revert() tool = MockTool() tool.executive = MockExecutive(should_log=True) with OutputCapture(level=logging.INFO) as captured: revert._update_working_copy(tool) self.assertEqual( captured.root.log.getvalue(), "MOCK run_and_throw_if_fail: ['mock-update-webkit'], cwd=/mock-checkout\n", )
def test_can_build_and_test(self): queue = CommitQueue() tool = MockTool() tool.executive = Mock() queue.bind_to_tool(tool) self.assertTrue(queue._can_build_and_test()) expected_run_args = [ "echo", "--status-host=example.com", "build-and-test", "--force-clean", "--build", "--test", "--non-interactive", "--no-update", "--build-style=both", "--quiet" ] tool.executive.run_and_throw_if_fail.assert_called_with( expected_run_args)
def test_rebaseline(self): old_exact_matches = builders._exact_matches try: builders._exact_matches = { "MOCK builder": { "port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"]) }, } command = Rebaseline() tool = MockTool() command.bind_to_tool(tool) for port_name in tool.port_factory.all_port_names(): port = tool.port_factory.get(port_name) for path in port.expectations_files(): tool.filesystem.write_text_file(path, '') tool.executive = MockExecutive(should_log=True) def mock_builders_to_pull_from(): return [MockBuilder('MOCK builder')] def mock_tests_to_update(build): return ['mock/path/to/test.html'] command._builders_to_pull_from = mock_builders_to_pull_from command._tests_to_update = mock_tests_to_update expected_stdout = """rebaseline-json: {'mock/path/to/test.html': {'MOCK builder': ['txt']}} """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'MOCK builder', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'mock/path/to/test.html'], cwd=/mock-checkout """ OutputCapture().assert_outputs( self, command.execute, [ MockOptions(optimize=True, builders=None, suffixes=["txt"], verbose=True), [], tool ], expected_stdout=expected_stdout, expected_stderr=expected_stderr) finally: builders._exact_matches = old_exact_matches
def test_rebaseline_expectations(self): command = RebaselineExpectations() tool = MockTool() command.bind_to_tool(tool) lion_port = tool.port_factory.get_from_builder_name("WebKit Mac10.7") for port_name in tool.port_factory.all_port_names(): port = tool.port_factory.get(port_name) for path in port.expectations_files(): tool.filesystem.write_text_file(path, '') # Don't enable logging until after we create the mock expectation files as some Port.__init__'s run subcommands. tool.executive = MockExecutive(should_log=True) def run_in_parallel(commands): print commands return "" tool.executive.run_in_parallel = run_in_parallel expected_logs = "Retrieving results for chromium-linux-x86 from WebKit Linux 32.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-linux-x86_64 from WebKit Linux.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-mac-lion from WebKit Mac10.7.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-mac-mountainlion from WebKit Mac10.8.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-mac-snowleopard from WebKit Mac10.6.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-win-win7 from WebKit Win7.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-win-xp from WebKit XP.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for efl from EFL Linux 64-bit Release.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for gtk from GTK Linux 64-bit Release.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for mac-lion from Apple Lion Release WK1 (Tests).\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for mac-mountainlion from Apple MountainLion Release WK1 (Tests).\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for qt-linux from Qt Linux Release.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for win-7sp0 from Apple Win 7 Release (Tests).\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\n" expected_stdout = "[(['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Linux 32', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Linux', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Mac10.6', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Mac10.7', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Win7', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'Apple Win 7 Release (Tests)', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'EFL Linux 64-bit Release', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Mac10.8', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'GTK Linux 64-bit Release', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'Qt Linux Release', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'Apple Lion Release WK1 (Tests)', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit XP', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'Apple MountainLion Release WK1 (Tests)', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Linux 32', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Linux', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Mac10.6', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Mac10.7', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Win7', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'Apple Win 7 Release (Tests)', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'EFL Linux 64-bit Release', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Mac10.8', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'GTK Linux 64-bit Release', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'Qt Linux Release', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'Apple Lion Release WK1 (Tests)', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit XP', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'Apple MountainLion Release WK1 (Tests)', '--test', 'userscripts/images.svg'], '/mock-checkout')]\n" expected_stderr = """MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None """ command._tests_to_rebaseline = lambda port: {'userscripts/another-test.html': set(['txt']), 'userscripts/images.svg': set(['png'])} OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=False), [], tool], expected_logs=expected_logs, expected_stdout=expected_stdout, expected_stderr=expected_stderr) expected_stderr_with_optimize = """MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'png', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None """ command._tests_to_rebaseline = lambda port: {'userscripts/another-test.html': set(['txt']), 'userscripts/images.svg': set(['png'])} OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=True), [], tool], expected_logs=expected_logs, expected_stdout=expected_stdout, expected_stderr=expected_stderr_with_optimize)
def _assert_run_webkit_patch(self, run_args, port=None): queue = TestQueue() tool = MockTool() tool.executive = Mock() queue.bind_to_tool(tool) queue._options = Mock() queue._options.port = port queue.run_webkit_patch(run_args) expected_run_args = ["echo"] if port: expected_run_args.append("--port=%s" % port) expected_run_args.extend(run_args) tool.executive.run_command.assert_called_with(expected_run_args, cwd='/mock-checkout')
def _assert_run_webkit_patch(self, run_args, port=None): queue = TestQueue() tool = MockTool() tool.status_server.bot_id = "gort" tool.executive = Mock() queue.bind_to_tool(tool) queue._options = Mock() queue._options.port = port queue.run_webkit_patch(run_args) expected_run_args = ["echo", "--status-host=example.com", "--bot-id=gort"] if port: expected_run_args.append("--port=%s" % port) expected_run_args.extend(run_args) tool.executive.run_command.assert_called_with(expected_run_args, cwd='/mock-checkout')
def test_rebaseline_test_internal_with_move_overwritten_baselines_to(self): old_exact_matches = builders._exact_matches try: builders._exact_matches = { "MOCK Leopard": { "port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"]) }, "MOCK SnowLeopard": { "port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier"]) }, } command = RebaselineTest() tool = MockTool() tool.executive = MockExecutive(should_log=True) command.bind_to_tool(tool) port = tool.port_factory.get('test-mac-snowleopard') tool.filesystem.write_text_file( tool.filesystem.join(port.baseline_version_dir(), 'failures', 'expected', 'image-expected.txt'), '') options = MockOptions( optimize=True, builder="MOCK SnowLeopard", suffixes="txt", move_overwritten_baselines_to=["test-mac-leopard"], verbose=True, test="failures/expected/image.html") oc = OutputCapture() oc.capture_output() try: logs = '' command.execute(options, [], tool) finally: _, _, logs = oc.restore_output() self.assertTrue( "Copying baseline from /test.checkout/LayoutTests/platform/test-mac-snowleopard/failures/expected/image-expected.txt to /test.checkout/LayoutTests/platform/test-mac-leopard/failures/expected/image-expected.txt.\n" in logs) finally: builders._exact_matches = old_exact_matches
def test_rebaseline_multiple_builders(self): old_exact_matches = builders._exact_matches try: builders._exact_matches = { "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])}, "MOCK builder2": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"])}, } command = Rebaseline() tool = MockTool() command.bind_to_tool(tool) for port_name in tool.port_factory.all_port_names(): port = tool.port_factory.get(port_name) for path in port.expectations_files(): tool.filesystem.write_text_file(path, '') tool.executive = MockExecutive(should_log=True) def mock_builders_to_pull_from(): return [MockBuilder('MOCK builder'), MockBuilder('MOCK builder2')] def mock_tests_to_update(build): return ['mock/path/to/test.html'] command._builders_to_pull_from = mock_builders_to_pull_from command._tests_to_update = mock_tests_to_update expected_stdout = """rebaseline-json: {'mock/path/to/test.html': {'MOCK builder2': ['txt'], 'MOCK builder': ['txt']}} """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'MOCK builder', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'mock/path/to/test.html'], cwd=/mock-checkout """ OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=True, builders=None, verbose=True), [], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr) finally: builders._exact_matches = old_exact_matches
def test_rebaseline_json_with_move_overwritten_baselines_to(self): old_exact_matches = builders._exact_matches try: builders._exact_matches = { "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])}, "MOCK builder2": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"]), "move_overwritten_baselines_to": ["test-mac-leopard"]}, } command = Rebaseline() tool = MockTool() tool.executive = MockExecutive(should_log=True) command.bind_to_tool(tool) expected_stdout = """rebaseline-json: {'mock/path/to/test.html': {'MOCK builder2': ['txt', 'png']}}\n""" expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test.html', '--move-overwritten-baselines-to', 'test-mac-leopard'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'mock/path/to/test.html'], cwd=/mock-checkout """ options = MockOptions(optimize=True, builders=["MOCK builder2"], suffixes=["txt,png"], verbose=True) OutputCapture().assert_outputs(self, command.execute, [options, ["mock/path/to/test.html"], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr) finally: builders._exact_matches = old_exact_matches
def test_rebaseline_json_with_move_overwritten_baselines_to(self): old_exact_matches = builders._exact_matches try: builders._exact_matches = { "MOCK builder": { "port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"]) }, "MOCK builder2": { "port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"]), "move_overwritten_baselines_to": ["test-mac-leopard"] }, } command = Rebaseline() tool = MockTool() tool.executive = MockExecutive(should_log=True) command.bind_to_tool(tool) expected_stdout = """rebaseline-json: {'mock/path/to/test.html': {'MOCK builder2': ['txt', 'png']}}\n""" expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test.html', '--move-overwritten-baselines-to', 'test-mac-leopard'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'mock/path/to/test.html'], cwd=/mock-checkout """ options = MockOptions(optimize=True, builders=["MOCK builder2"], suffixes=["txt,png"], verbose=True) OutputCapture().assert_outputs( self, command.execute, [options, ["mock/path/to/test.html"], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr) finally: builders._exact_matches = old_exact_matches
def test_rebaseline_expectations(self): command = RebaselineExpectations() tool = MockTool() command.bind_to_tool(tool) for port_name in tool.port_factory.all_port_names(): port = tool.port_factory.get(port_name) for path in port.expectations_files(): tool.filesystem.write_text_file(path, "") # Don't enable logging until after we create the mock expectation files as some Port.__init__'s run subcommands. tool.executive = MockExecutive(should_log=True) expected_logs = """Retrieving results for chromium-linux-x86 from Webkit Linux 32. userscripts/another-test.html (txt) userscripts/images.svg (png) Retrieving results for chromium-linux-x86_64 from Webkit Linux. userscripts/another-test.html (txt) userscripts/images.svg (png) Retrieving results for chromium-mac-leopard from Webkit Mac10.5. userscripts/another-test.html (txt) userscripts/images.svg (png) Retrieving results for chromium-mac-lion from Webkit Mac10.7. userscripts/another-test.html (txt) userscripts/images.svg (png) Retrieving results for chromium-mac-snowleopard from Webkit Mac10.6. userscripts/another-test.html (txt) userscripts/images.svg (png) Retrieving results for chromium-win-vista from Webkit Vista. userscripts/another-test.html (txt) userscripts/images.svg (png) Retrieving results for chromium-win-win7 from Webkit Win7. userscripts/another-test.html (txt) userscripts/images.svg (png) Retrieving results for chromium-win-xp from Webkit Win. userscripts/another-test.html (txt) userscripts/images.svg (png) """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Linux 32', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Linux 32', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Linux', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Mac10.5', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Mac10.5', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Mac10.7', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Mac10.7', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Vista', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Vista', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Win7', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Win7', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'txt', 'Webkit Win', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', '--suffixes', 'png', 'Webkit Win', 'userscripts/images.svg'], cwd=/mock-checkout """ command._tests_to_rebaseline = lambda port: { "userscripts/another-test.html": set(["txt"]), "userscripts/images.svg": set(["png"]), } OutputCapture().assert_outputs( self, command.execute, [MockOptions(optimize=False), [], tool], expected_logs=expected_logs, expected_stderr=expected_stderr, ) expected_logs_with_optimize = expected_logs + ( "Optimizing baselines for userscripts/another-test.html (txt).\n" "Optimizing baselines for userscripts/images.svg (png).\n" ) expected_stderr_with_optimize = expected_stderr + ( "MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'userscripts/another-test.html'], cwd=/mock-checkout\n" "MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'png', 'userscripts/images.svg'], cwd=/mock-checkout\n" ) command._tests_to_rebaseline = lambda port: { "userscripts/another-test.html": set(["txt"]), "userscripts/images.svg": set(["png"]), } OutputCapture().assert_outputs( self, command.execute, [MockOptions(optimize=True), [], tool], expected_logs=expected_logs_with_optimize, expected_stderr=expected_stderr_with_optimize, )
def test_rebaseline_expectations(self): command = RebaselineExpectations() tool = MockTool() tool.executive = MockExecutive(should_log=True) command.bind_to_tool(tool) expected_stdout = """Retrieving results for chromium-cg-mac-leopard from Webkit Mac10.5 (CG). userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-cg-mac-snowleopard from Webkit Mac10.6 (CG). userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-gpu-cg-mac-leopard from Webkit Mac10.5 (CG) - GPU. Retrieving results for chromium-gpu-cg-mac-snowleopard from Webkit Mac10.6 (CG) - GPU. Retrieving results for chromium-gpu-mac-snowleopard from Webkit Mac10.6 - GPU. Retrieving results for chromium-gpu-win-win7 from Webkit Win7 - GPU. Retrieving results for chromium-gpu-win-xp from Webkit Win - GPU. Retrieving results for chromium-linux-x86 from Webkit Linux 32. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-linux-x86_64 from Webkit Linux. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-leopard from Webkit Mac10.5. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-snowleopard from Webkit Mac10.6. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-vista from Webkit Vista. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-win7 from Webkit Win7. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-xp from Webkit Win. userscripts/another-test.html userscripts/images.svg Optimizing baselines for userscripts/another-test.html. Optimizing baselines for userscripts/images.svg. """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5 (CG)', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5 (CG)', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6 (CG)', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6 (CG)', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/images.svg'], cwd=/mock-checkout """ command._tests_to_rebaseline = lambda port: [] if not port.name().find('-gpu-') == -1 else ['userscripts/another-test.html', 'userscripts/images.svg'] OutputCapture().assert_outputs(self, command.execute, [MockTool(), None, None], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
def test_rebaseline_expectations(self): command = RebaselineExpectations() tool = MockTool() command.bind_to_tool(tool) for port_name in tool.port_factory.all_port_names(): port = tool.port_factory.get(port_name) tool.filesystem.write_text_file( port.path_to_test_expectations_file(), '') # Don't enable logging until after we create the mock expectation files as some Port.__init__'s run subcommands. tool.executive = MockExecutive(should_log=True) expected_stdout = """Retrieving results for chromium-linux-x86 from Webkit Linux 32. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-linux-x86_64 from Webkit Linux. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-leopard from Webkit Mac10.5. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-lion from Webkit Mac10.7. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-snowleopard from Webkit Mac10.6. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-vista from Webkit Vista. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-win7 from Webkit Win7. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-xp from Webkit Win. userscripts/another-test.html userscripts/images.svg """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.7', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.7', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/images.svg'], cwd=/mock-checkout """ command._tests_to_rebaseline = lambda port: [ 'userscripts/another-test.html', 'userscripts/images.svg' ] OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=False), [], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr) expected_stdout_with_optimize = expected_stdout + ( "Optimizing baselines for userscripts/another-test.html.\n" "Optimizing baselines for userscripts/images.svg.\n") expected_stderr_with_optimize = expected_stderr + ( "MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/another-test.html'], cwd=/mock-checkout\n" "MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/images.svg'], cwd=/mock-checkout\n" ) command._tests_to_rebaseline = lambda port: [ 'userscripts/another-test.html', 'userscripts/images.svg' ] OutputCapture().assert_outputs( self, command.execute, [MockOptions(optimize=True), [], tool], expected_stdout=expected_stdout_with_optimize, expected_stderr=expected_stderr_with_optimize)
def test_rebaseline_expectations(self): command = RebaselineExpectations() tool = MockTool() command.bind_to_tool(tool) lion_port = tool.port_factory.get_from_builder_name("WebKit Mac10.7") for port_name in tool.port_factory.all_port_names(): port = tool.port_factory.get(port_name) for path in port.expectations_files(): tool.filesystem.write_text_file(path, '') # Don't enable logging until after we create the mock expectation files as some Port.__init__'s run subcommands. tool.executive = MockExecutive(should_log=True) def run_in_parallel(commands): print commands return "" tool.executive.run_in_parallel = run_in_parallel expected_logs = "Retrieving results for chromium-linux-x86 from WebKit Linux 32.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-linux-x86_64 from WebKit Linux.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-mac-lion from WebKit Mac10.7.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-mac-mountainlion from WebKit Mac10.8.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-mac-snowleopard from WebKit Mac10.6.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-win-win7 from WebKit Win7.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for chromium-win-xp from WebKit XP.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for efl from EFL Linux 64-bit Release.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for gtk from GTK Linux 64-bit Release.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for mac-lion from Apple Lion Release WK1 (Tests).\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for mac-mountainlion from Apple MountainLion Release WK1 (Tests).\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for qt-linux from Qt Linux Release.\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\nRetrieving results for win-7sp0 from Apple Win 7 Release (Tests).\n userscripts/another-test.html (txt)\n userscripts/images.svg (png)\n" expected_stdout = "[(['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Linux 32', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Linux', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Mac10.6', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Mac10.7', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Win7', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'Apple Win 7 Release (Tests)', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'EFL Linux 64-bit Release', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit Mac10.8', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'GTK Linux 64-bit Release', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'Qt Linux Release', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'Apple Lion Release WK1 (Tests)', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'WebKit XP', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'Apple MountainLion Release WK1 (Tests)', '--test', 'userscripts/another-test.html'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Linux 32', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Linux', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Mac10.6', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Mac10.7', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Win7', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'Apple Win 7 Release (Tests)', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'EFL Linux 64-bit Release', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit Mac10.8', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'GTK Linux 64-bit Release', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'Qt Linux Release', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'Apple Lion Release WK1 (Tests)', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'WebKit XP', '--test', 'userscripts/images.svg'], '/mock-checkout'), (['echo', 'rebaseline-test-internal', '--suffixes', 'png', '--builder', 'Apple MountainLion Release WK1 (Tests)', '--test', 'userscripts/images.svg'], '/mock-checkout')]\n" expected_stderr = """MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None """ command._tests_to_rebaseline = lambda port: { 'userscripts/another-test.html': set(['txt']), 'userscripts/images.svg': set(['png']) } OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=False), [], tool], expected_logs=expected_logs, expected_stdout=expected_stdout, expected_stderr=expected_stderr) expected_stderr_with_optimize = """MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'png', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None MOCK run_command: ['qmake', '-v'], cwd=None """ command._tests_to_rebaseline = lambda port: { 'userscripts/another-test.html': set(['txt']), 'userscripts/images.svg': set(['png']) } OutputCapture().assert_outputs( self, command.execute, [MockOptions(optimize=True), [], tool], expected_logs=expected_logs, expected_stdout=expected_stdout, expected_stderr=expected_stderr_with_optimize)
def test_rollout_updates_working_copy(self): rollout = Rollout() tool = MockTool() tool.executive = MockExecutive(should_log=True) expected_logs = "MOCK run_and_throw_if_fail: ['mock-update-webkit'], cwd=/mock-checkout\n" OutputCapture().assert_outputs(self, rollout._update_working_copy, [tool], expected_logs=expected_logs)
def test_rebaseline_expectations(self): command = RebaselineExpectations() tool = MockTool() tool.executive = MockExecutive(should_log=True) command.bind_to_tool(tool) expected_stdout = """Retrieving results for chromium-cg-mac-leopard from Webkit Mac10.5 (CG). userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-cg-mac-snowleopard from Webkit Mac10.6 (CG). userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-gpu-cg-mac-leopard from Webkit Mac10.5 (CG) - GPU. Retrieving results for chromium-gpu-cg-mac-snowleopard from Webkit Mac10.6 (CG) - GPU. Retrieving results for chromium-gpu-win-win7 from Webkit Win7 - GPU. Retrieving results for chromium-gpu-win-xp from Webkit Win - GPU. Retrieving results for chromium-linux-x86 from Webkit Linux 32. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-linux-x86_64 from Webkit Linux. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-leopard from Webkit Mac10.5. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-mac-snowleopard from Webkit Mac10.6. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-vista from Webkit Vista. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-win7 from Webkit Win7. userscripts/another-test.html userscripts/images.svg Retrieving results for chromium-win-xp from Webkit Win. userscripts/another-test.html userscripts/images.svg Optimizing baselines for userscripts/another-test.html. Optimizing baselines for userscripts/images.svg. """ expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5 (CG)', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5 (CG)', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6 (CG)', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6 (CG)', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/images.svg'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/another-test.html'], cwd=/mock-checkout MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/images.svg'], cwd=/mock-checkout """ command._tests_to_rebaseline = lambda port: [] if not port.name().find( '-gpu-') == -1 else [ 'userscripts/another-test.html', 'userscripts/images.svg' ] OutputCapture().assert_outputs(self, command.execute, [MockTool(), None, None], expected_stdout=expected_stdout, expected_stderr=expected_stderr)