def test_run_working_directory_changes_force(self):
     tool = MockTool()
     tool._scm = Mock()
     step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=True))
     tool._scm.has_working_directory_changes = lambda: True
     step.run({})
     self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 1)
Example #2
0
    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])
Example #3
0
    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
Example #4
0
    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])
Example #5
0
    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_no_clean(self):
     tool = MockTool()
     tool._scm = Mock()
     step = CleanWorkingDirectory(tool, MockOptions(clean=False))
     step.run({})
     self.assertEqual(tool._scm.ensure_no_local_commits.call_count, 0)
     self.assertEqual(tool._scm.ensure_clean_working_directory.call_count, 0)
Example #7
0
    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 _assert_emails_for_tests(self, emails):
     queue = CommitQueue()
     tool = MockTool()
     queue.bind_to_tool(tool)
     commit_infos = [MockCommitInfo(email) for email in emails]
     tool.checkout().recent_commit_infos_for_files = lambda paths: set(commit_infos)
     self.assertEqual(queue._author_emails_for_tests([]), set(emails))
Example #9
0
 def test_fetch_next_work_item(self):
     queue = AbstractPatchQueue()
     tool = MockTool()
     queue.bind_to_tool(tool)
     self.assertEquals(queue._fetch_next_work_item(), None)
     tool.status_server = MockStatusServer(work_items=[2, 1, 3])
     self.assertEquals(queue._fetch_next_work_item(), 2)
Example #10
0
 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_no_changes_exist_with_force(self):
     tool = MockTool()
     tool._scm = Mock()
     tool._scm.has_working_directory_changes = lambda: False
     tool._scm.has_local_commits = lambda: False
     step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=True))
     step.run({})
     self.assertEqual(tool._scm.discard_local_changes.call_count, 1)
 def test_missing_unit_test_results_path(self):
     tool = MockTool()
     tool.port().unit_tests_results_path = lambda: None
     reader = LayoutTestResultsReader(tool, "/var/logs")
     reader._create_layout_test_results = lambda: LayoutTestResults([])
     # layout_test_results shouldn't raise even if the unit tests xml file is missing.
     self.assertNotEquals(reader.results(), None)
     self.assertEqual(reader.results().failing_tests(), [])
 def test_run(self):
     tool = MockTool()
     tool._scm = Mock()
     tool._scm.checkout_root = '/mock-checkout'
     step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=False))
     step.run({})
     self.assertEqual(tool._scm.ensure_no_local_commits.call_count, 1)
     self.assertEqual(tool._scm.ensure_clean_working_directory.call_count, 1)
 def test_error_local_commits_exist_without_force(self):
     tool = MockTool()
     tool._scm = Mock()
     tool._scm.has_working_directory_changes = lambda: False
     tool._scm.has_local_commits = lambda: True
     step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=False))
     self.assertRaises(ScriptError, step.run, {})
     self.assertEqual(tool._scm.discard_local_changes.call_count, 0)
Example #15
0
    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 test_land_diff(self):
     expected_stderr = "Building WebKit\nRunning Python unit tests\nRunning Perl unit tests\nRunning JavaScriptCore tests\nRunning run-webkit-tests\nCommitted r49824: <http://trac.webkit.org/changeset/49824>\nUpdating bug 42\n"
     mock_tool = MockTool()
     mock_tool.scm().create_patch = Mock(return_value="Patch1\nMockPatch\n")
     mock_tool.checkout().modified_changelogs = Mock(return_value=[])
     self.assert_execute_outputs(Land(), [42], options=self._default_options(), expected_stderr=expected_stderr, tool=mock_tool)
     # Make sure we're not calling expensive calls too often.
     self.assertEqual(mock_tool.scm().create_patch.call_count, 1)
     self.assertEqual(mock_tool.checkout().modified_changelogs.call_count, 1)
Example #17
0
    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_missing_layout_test_results(self):
     tool = MockTool()
     reader = LayoutTestResultsReader(tool, "/var/logs")
     results_path = '/mock-results/results.html'
     tool.filesystem = MockFileSystem({results_path: None})
     # Make sure that our filesystem mock functions as we expect.
     self.assertRaises(IOError, tool.filesystem.read_text_file, results_path)
     # layout_test_results shouldn't raise even if the results.html file is missing.
     self.assertEquals(reader.results(), None)
 def test_missing_layout_test_results(self):
     queue = CommitQueue()
     tool = MockTool()
     results_path = '/mock/results.html'
     tool.filesystem = MockFileSystem({results_path: None})
     queue.bind_to_tool(tool)
     # Make sure that our filesystem mock functions as we expect.
     self.assertRaises(IOError, tool.filesystem.read_text_file, results_path)
     # layout_test_results shouldn't raise even if the results.html file is missing.
     self.assertEquals(queue.layout_test_results(), None)
Example #20
0
    def test_update_command_non_interactive(self):
        tool = MockTool()
        options = MockOptions(non_interactive=True)
        step = Update(tool, options)
        self.assertEqual(["mock-update-webkit"], step._update_command())

        tool._deprecated_port = ChromiumPort()
        self.assertEqual(["Tools/Scripts/update-webkit", "--chromium", "--force-update"], step._update_command())

        tool._deprecated_port = ChromiumXVFBPort()
        self.assertEqual(["Tools/Scripts/update-webkit", "--chromium", "--force-update"], step._update_command())
Example #21
0
    def test_update_command_interactive(self):
        tool = MockTool()
        options = MockOptions(non_interactive=False)
        step = Update(tool, options)
        self.assertEqual(["mock-update-webkit"], step._update_command())

        tool._port = tool.port_factory.get("mac")
        self.assertEqual(["Tools/Scripts/update-webkit"], step._update_command())

        tool._port = tool.port_factory.get("mac-wk2")
        self.assertEqual(["Tools/Scripts/update-webkit"], step._update_command())
Example #22
0
    def test_blame_line_for_revision(self):
        tool = MockTool()
        command = FailureReason()
        command.bind_to_tool(tool)
        # This is an artificial example, mostly to test the CommitInfo lookup failure case.
        self.assertEqual(command._blame_line_for_revision(0), "FAILED to fetch CommitInfo for r0, likely missing ChangeLog")

        def raising_mock(self):
            raise Exception("MESSAGE")
        tool.checkout().commit_info_for_revision = raising_mock
        self.assertEqual(command._blame_line_for_revision(0), "FAILED to fetch CommitInfo for r0, exception: MESSAGE")
Example #23
0
    def test_update_command_interactive(self):
        tool = MockTool()
        options = MockOptions(non_interactive=False)
        step = Update(tool, options)
        self.assertEqual(["mock-update-webkit"], step._update_command())

        tool._deprecated_port = MacPort()
        self.assertEqual(["Tools/Scripts/update-webkit"], step._update_command())

        tool._deprecated_port = MacWK2Port()
        self.assertEqual(["Tools/Scripts/update-webkit"], step._update_command())
Example #24
0
    def test_integration(self):
        command = flakytests.FlakyTests()
        tool = MockTool()
        tool.builders = FakeBuilders()
        command.expectations_factory = FakeBotTestExpectationsFactory
        options = MockOptions(upload=True)
        expected_stdout = flakytests.FlakyTests.OUTPUT % (
            flakytests.FlakyTests.HEADER,
            '',
            flakytests.FlakyTests.FLAKINESS_DASHBOARD_URL % '') + '\n'

        self.assert_execute_outputs(command, options=options, tool=tool, expected_stdout=expected_stdout)
Example #25
0
 def test_missing_layout_test_results(self):
     tool = MockTool()
     reader = LayoutTestResultsReader(tool, "/var/logs")
     layout_tests_results_path = '/mock-results/full_results.json'
     unit_tests_results_path = '/mock-results/webkit_unit_tests_output.xml'
     tool.filesystem = MockFileSystem({layout_tests_results_path: None,
                                       unit_tests_results_path: None})
     # Make sure that our filesystem mock functions as we expect.
     self.assertRaises(IOError, tool.filesystem.read_text_file, layout_tests_results_path)
     self.assertRaises(IOError, tool.filesystem.read_text_file, unit_tests_results_path)
     # layout_test_results shouldn't raise even if the results.json file is missing.
     self.assertEqual(reader.results(), None)
Example #26
0
    def test_skipped_ports(self):
        tool = MockTool()
        tool.port_factory = MockPortFactory()

        expected_stdout = "Ports skipping test 'media/foo/bar.html': test_port1, test_port2\n"
        self.assert_execute_outputs(SkippedPorts(), ("media/foo/bar.html",), expected_stdout, tool=tool)

        expected_stdout = "Ports skipping test 'foo': test_port1\n"
        self.assert_execute_outputs(SkippedPorts(), ("foo",), expected_stdout, tool=tool)

        expected_stdout = "Test 'media' is not skipped by any port.\n"
        self.assert_execute_outputs(SkippedPorts(), ("media",), expected_stdout, tool=tool)
Example #27
0
 def test_next_patch(self):
     queue = AbstractPatchQueue()
     tool = MockTool()
     queue.bind_to_tool(tool)
     queue._options = Mock()
     queue._options.port = None
     self.assertEquals(queue._next_patch(), None)
     tool.status_server = MockStatusServer(work_items=[2, 10000])
     expected_stdout = "MOCK: fetch_attachment: 2 is not a known attachment id\n"  # A mock-only message to prevent us from making mistakes.
     expected_stderr = "MOCK: release_work_item: None 2\n"
     patch_id = OutputCapture().assert_outputs(self, queue._next_patch, expected_stdout=expected_stdout, expected_stderr=expected_stderr)
     self.assertEquals(patch_id, None)  # 2 is an invalid patch id
     self.assertEquals(queue._next_patch().id(), 10000)
    def test_create_unit_test_results(self):
        tool = MockTool()
        reader = LayoutTestResultsReader(tool, "/var/logs")
        unit_tests_results_path = '/mock-results/webkit_unit_tests_output.xml'
        no_failures_xml = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="0" disabled="0" errors="0" time="11.35" name="AllTests">
  <testsuite name="RenderTableCellDeathTest" tests="3" failures="0" disabled="0" errors="0" time="0.677">
    <testcase name="CanSetColumn" status="run" time="0.168" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetColumnIndex" status="run" time="0.129" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetRowIndex" status="run" time="0.123" classname="RenderTableCellDeathTest" />
  </testsuite>
</testsuites>"""
        tool.filesystem = MockFileSystem({unit_tests_results_path: no_failures_xml})
        self.assertEqual(reader._create_unit_test_results(), [])
Example #29
0
    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)
Example #30
0
    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')
Example #31
0
    def test_apply_watch_list(self):
        expected_logs = """Processing 1 patch from 1 bug.
Updating working directory
MOCK run_and_throw_if_fail: ['mock-update-webkit'], cwd=/mock-checkout
Processing patch 10000 from bug 50000.
MockWatchList: determine_cc_and_messages
No bug was updated because no id was given.
Result of watchlist: cc "[email protected], [email protected], [email protected]" messages "Message1.

Message2."
"""
        self.assert_execute_outputs(ApplyWatchList(), [10000], options=self._default_options(), expected_logs=expected_logs, tool=MockTool(log_executive=True))
Example #32
0
 def test_summary_text(self):
     tool = MockTool()
     self.assertEqual(
         BotInfo(tool, 'port-name').summary_text(),
         "Port: port-name  Platform: MockPlatform 1.0")
Example #33
0
 def test_disabled(self):
     step = SuggestReviewers(MockTool(), MockOptions(suggest_reviewers=False))
     OutputCapture().assert_outputs(self, step.run, [{}])
 def test_guess_reviewer_from_multipatch_bug(self):
     step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions())
     with OutputCapture(level=logging.INFO) as captured:
         step._guess_reviewer_from_bug(50000)
     self.assertEqual(captured.root.log.getvalue(), 'Guessing "Reviewer2" as reviewer from attachment 10001 on bug 50000.\n')
 def setUp(self):
     self.tool = MockTool()
     self.command = self.command_constructor()  # lint warns that command_constructor might not be set, but this is intentional; pylint: disable=E1102
     self.command.bind_to_tool(self.tool)
     self.lion_port = self.tool.port_factory.get_from_builder_name("WebKit Mac10.7")
     self.lion_expectations_path = self.lion_port.path_to_test_expectations_file()
Example #36
0
    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)

        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.
    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-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-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)
Retrieving results for efl from EFL Linux 64-bit Release.
    userscripts/another-test.html (txt)
    userscripts/images.svg (png)
Retrieving results for gtk from GTK Linux 64-bit Release.
    userscripts/another-test.html (txt)
    userscripts/images.svg (png)
Retrieving results for mac-lion from Apple Lion Release WK1 (Tests).
    userscripts/another-test.html (txt)
    userscripts/images.svg (png)
Retrieving results for qt-linux from Qt Linux Release.
    userscripts/another-test.html (txt)
    userscripts/images.svg (png)
Retrieving results for win-7sp0 from Apple Win 7 Release (Tests).
    userscripts/another-test.html (txt)
    userscripts/images.svg (png)
Using the chromium port without having the downstream skia_test_expectations.txt file checked out. Expectations related things might be wonky.
Using the chromium port without having the downstream skia_test_expectations.txt file checked out. Expectations related things might be wonky.
Using the chromium port without having the downstream skia_test_expectations.txt file checked out. Expectations related things might be wonky.
Using the chromium port without having the downstream skia_test_expectations.txt file checked out. Expectations related things might be wonky.
Using the chromium port without having the downstream skia_test_expectations.txt file checked out. Expectations related things might be wonky.
Using the chromium port without having the downstream skia_test_expectations.txt file checked out. Expectations related things might be wonky.
"""

        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 Win', '--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', '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 Win', '--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')]
"""

        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)
Example #37
0
 def setUp(self):
     # Port._build_path() calls Tools/Scripts/webkit-build-directory and caches the result. When capturing output,
     # this can cause the first invocation of Port._build_path() to have more output than subsequent invocations.
     # This may cause test flakiness when test order changes. By explicitly calling Port._build_path() before running
     # tests in this suite, we avoid such flakiness.
     MockTool().port_factory.get(options=self._step_options())._build_path()
Example #38
0
 def test_commit_message_for_current_diff(self):
     tool = MockTool()
     expected_stdout = "This is a fake commit message that is at least 50 characters.\n"
     self.assert_execute_outputs(CommitMessageForCurrentDiff(), [], expected_stdout=expected_stdout, tool=tool)
Example #39
0
 def setUp(self):
     self.oc = None
     self.tool = MockTool()
     self.test_port = self.tool.port_factory.get('test-win-xp')
     self.tool.port_factory.get = lambda port_name=None: self.test_port
     self.tool.port_factory.all_port_names = lambda: TestPort.ALL_BASELINE_VARIANTS
Example #40
0
    def test_rollout(self):
        rollout = Rollout()
        self.assertEqual(([1234], "testing foo"),
                          rollout._parse_args(["1234", "testing", "foo"]))

        self.assertEqual(([554], "testing foo"),
                          rollout._parse_args(["r554", "testing", "foo"]))

        self.assertEqual(([556, 792], "testing foo"),
                          rollout._parse_args(["r556", "792", "testing", "foo"]))

        self.assertEqual(([128, 256], "testing foo"),
                          rollout._parse_args(["r128,r256", "testing", "foo"]))

        self.assertEqual(([512, 1024, 2048], "testing foo"),
                          rollout._parse_args(["512,", "1024,2048", "testing", "foo"]))

        # Test invalid argument parsing:
        self.assertEqual((None, None), rollout._parse_args([]))
        self.assertEqual((None, None), rollout._parse_args(["--bar", "1234"]))

        # Invalid arguments result in the USAGE message.
        self.assertEqual("tom: Usage: rollout SVN_REVISION [SVN_REVISIONS] REASON",
                          rollout.execute("tom", [], None, None))

        tool = MockTool()
        tool.filesystem.files["/mock-checkout/test/file/one"] = ""
        tool.filesystem.files["/mock-checkout/test/file/two"] = ""
        self.assertEqual("Failed to apply reverse diff for files: test/file/one, test/file/two",
                          rollout._check_diff_failure("""
Preparing rollout for bug 123456.
Updating working directory
Failed to apply reverse diff for revision 123456 because of the following conflicts:
test/file/one
test/file/two
Failed to apply reverse diff for revision 123456 because of the following conflicts:
test/file/one
test/file/two
Updating OpenSource
Current branch master is up to date.
        """, tool))

        self.assertEqual("Failed to apply reverse diff for file: test/file/one",
                          rollout._check_diff_failure("""
Preparing rollout for bug 123456.
Updating working directory
Failed to apply reverse diff for revision 123456 because of the following conflicts:
test/file/one
Updating OpenSource
Current branch master is up to date.
        """, tool))

        self.assertEqual(None, rollout._check_diff_failure("""
Preparing rollout for bug 123456.
Updating working directory
Some other error report involving file paths:
test/file/one
test/file/two
Updating OpenSource
Current branch master is up to date.
        """, tool))
Example #41
0
 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 __init__(self):
     self.tool = MockTool()
     self.tool.executive = MockExecutive(should_log=True)
     self.tool.filesystem.files[
         TestPortFactory.path_to_test_expectations_file()] = ""
Example #43
0
 def test_update_step(self):
     tool = MockTool()
     options = self._step_options()
     options.update = True
     expected_logs = "Updating working directory\n"
     OutputCapture().assert_outputs(self, self._run_step, [steps.Update, tool, options], expected_logs=expected_logs)
Example #44
0
 def test_basic(self):
     capture = OutputCapture()
     step = SuggestReviewers(MockTool(), MockOptions(suggest_reviewers=True, git_commit=None))
     expected_stdout = "The following reviewers have recently modified files in your patch:\nFoo Bar\n"
     expected_logs = "Would you like to CC them?\n"
     capture.assert_outputs(self, step.run, [{"bug_id": "123"}], expected_stdout=expected_stdout, expected_logs=expected_logs)
 def run():
     tool = MockTool()
     tool.buildbot.light_tree_on_fire()
     sheriff = Sheriff(tool, MockSheriffBot())
     revisions_causing_failures = {}
     sheriff.provoke_flaky_builders(revisions_causing_failures)
Example #46
0
 def test_did_pass_testing_ews(self):
     tool = MockTool()
     patch = tool.bugs.fetch_attachment(10000)
     queue = TestCommitQueue(tool)
     self.assertFalse(queue.did_pass_testing_ews(patch))
Example #47
0
 def test_tests_to_update(self):
     command = Rebaseline()
     command.bind_to_tool(MockTool())
     build = Mock()
     OutputCapture().assert_outputs(self, command._tests_to_update, [build])
Example #48
0
    def assert_queue_outputs(self,
                             queue,
                             args=None,
                             work_item=None,
                             expected_stdout=None,
                             expected_stderr=None,
                             expected_exceptions=None,
                             options=None,
                             tool=None):
        if not tool:
            tool = MockTool()
            # This is a hack to make it easy for callers to not have to setup a custom MockFileSystem just to test the commit-queue
            # the cq tries to read the layout test results, and will hit a KeyError in MockFileSystem if we don't do this.
            tool.filesystem.write_text_file('/mock-results/results.html', "")
        if not expected_stdout:
            expected_stdout = {}
        if not expected_stderr:
            expected_stderr = {}
        if not args:
            args = []
        if not options:
            options = Mock()
            options.port = None
        if not work_item:
            work_item = self.mock_work_item
        tool.user.prompt = lambda message: "yes"

        queue.execute(options, args, tool, engine=MockQueueEngine)

        self.assert_outputs(queue.queue_log_path, "queue_log_path", [],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.work_item_log_path, "work_item_log_path",
                            [work_item], expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.begin_work_queue, "begin_work_queue", [],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.should_continue_work_queue,
                            "should_continue_work_queue", [], expected_stdout,
                            expected_stderr, expected_exceptions)
        self.assert_outputs(queue.next_work_item, "next_work_item", [],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.should_proceed_with_work_item,
                            "should_proceed_with_work_item", [work_item],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.process_work_item, "process_work_item",
                            [work_item], expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.handle_unexpected_error,
                            "handle_unexpected_error",
                            [work_item, "Mock error message"], expected_stdout,
                            expected_stderr, expected_exceptions)
        # Should we have a different function for testing StepSequenceErrorHandlers?
        if isinstance(queue, StepSequenceErrorHandler):
            self.assert_outputs(
                queue.handle_script_error, "handle_script_error", [
                    tool, {
                        "patch": self.mock_work_item
                    },
                    ScriptError(message="ScriptError error message",
                                script_args="MockErrorCommand")
                ], expected_stdout, expected_stderr, expected_exceptions)
Example #49
0
 def test_rebaseline_test(self):
     command = RebaselineTest()
     command.bind_to_tool(MockTool())
     expected_logs = "Retrieving http://example.com/f/builders/Webkit Linux/results/layout-test-results/userscripts/another-test-actual.txt.\n"
     OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Linux", "userscripts/another-test.html", None, "txt"], expected_logs=expected_logs)
Example #50
0
class QueuesTest(unittest.TestCase):
    # This is _patch1 in mocktool.py
    mock_work_item = MockTool().bugs.fetch_attachment(10000)

    def assert_outputs(self, func, func_name, args, expected_stdout,
                       expected_stderr, expected_exceptions):
        exception = None
        if expected_exceptions and func_name in expected_exceptions:
            exception = expected_exceptions[func_name]

        OutputCapture().assert_outputs(
            self,
            func,
            args=args,
            expected_stdout=expected_stdout.get(func_name, ""),
            expected_stderr=expected_stderr.get(func_name, ""),
            expected_exception=exception)

    def _default_begin_work_queue_stderr(self, name):
        checkout_dir = '/mock-checkout'
        string_replacements = {"name": name, 'checkout_dir': checkout_dir}
        return "CAUTION: %(name)s will discard all local changes in \"%(checkout_dir)s\"\nRunning WebKit %(name)s.\nMOCK: update_status: %(name)s Starting Queue\n" % string_replacements

    def assert_queue_outputs(self,
                             queue,
                             args=None,
                             work_item=None,
                             expected_stdout=None,
                             expected_stderr=None,
                             expected_exceptions=None,
                             options=None,
                             tool=None):
        if not tool:
            tool = MockTool()
            # This is a hack to make it easy for callers to not have to setup a custom MockFileSystem just to test the commit-queue
            # the cq tries to read the layout test results, and will hit a KeyError in MockFileSystem if we don't do this.
            tool.filesystem.write_text_file('/mock-results/results.html', "")
        if not expected_stdout:
            expected_stdout = {}
        if not expected_stderr:
            expected_stderr = {}
        if not args:
            args = []
        if not options:
            options = Mock()
            options.port = None
        if not work_item:
            work_item = self.mock_work_item
        tool.user.prompt = lambda message: "yes"

        queue.execute(options, args, tool, engine=MockQueueEngine)

        self.assert_outputs(queue.queue_log_path, "queue_log_path", [],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.work_item_log_path, "work_item_log_path",
                            [work_item], expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.begin_work_queue, "begin_work_queue", [],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.should_continue_work_queue,
                            "should_continue_work_queue", [], expected_stdout,
                            expected_stderr, expected_exceptions)
        self.assert_outputs(queue.next_work_item, "next_work_item", [],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.should_proceed_with_work_item,
                            "should_proceed_with_work_item", [work_item],
                            expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.process_work_item, "process_work_item",
                            [work_item], expected_stdout, expected_stderr,
                            expected_exceptions)
        self.assert_outputs(queue.handle_unexpected_error,
                            "handle_unexpected_error",
                            [work_item, "Mock error message"], expected_stdout,
                            expected_stderr, expected_exceptions)
        # Should we have a different function for testing StepSequenceErrorHandlers?
        if isinstance(queue, StepSequenceErrorHandler):
            self.assert_outputs(
                queue.handle_script_error, "handle_script_error", [
                    tool, {
                        "patch": self.mock_work_item
                    },
                    ScriptError(message="ScriptError error message",
                                script_args="MockErrorCommand")
                ], expected_stdout, expected_stderr, expected_exceptions)
Example #51
0
    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)
Example #52
0
 def test_empty_state(self):
     capture = OutputCapture()
     step = UpdateChangeLogsWithReviewer(MockTool(), Mock())
     capture.assert_outputs(self, step.run, [{}])
 def test_guess_reviewer_from_bug(self):
     step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions())
     with OutputCapture(level=logging.INFO) as captured:
         step._guess_reviewer_from_bug(50001)
     self.assertEqual(captured.root.log.getvalue(), 'No reviewed patches on bug 50001, cannot infer reviewer.\n')
Example #54
0
def run(message):
    tool = MockTool()
    tool.ensure_irc_connected(None)
    bot = SheriffIRCBot(tool, Sheriff(tool, MockSheriffBot()))
    bot._message_queue.post(["mock_nick", message])
    bot.process_pending_messages()
Example #55
0
    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)
Example #56
0
    def test_check_style(self):
        expected_logs = """Processing 1 patch from 1 bug.
Updating working directory
MOCK run_and_throw_if_fail: ['mock-update-webkit'], cwd=/mock-checkout
Processing patch 10000 from bug 50000.
MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--git-commit', 'MOCK git commit', '--diff-files', 'MockFile1'], cwd=/mock-checkout
"""
        self.assert_execute_outputs(CheckStyle(), [10000], options=self._default_options(), expected_logs=expected_logs, tool=MockTool(log_executive=True))
Example #57
0
 def test_prompt_for_bug_or_title_step(self):
     tool = MockTool()
     tool.user.prompt = lambda message: 50000
     self._run_step(steps.PromptForBugOrTitle, tool=tool)
Example #58
0
 def test_archive_last_layout_test_results(self):
     queue = CommitQueue()
     queue.bind_to_tool(MockTool())
     patch = queue._tool.bugs.fetch_attachment(128)
     # This is just to test that the method doesn't raise.
     queue.archive_last_layout_test_results(patch)
Example #59
0
 def _assert_step_output_with_bug(self, step, bug_id, expected_logs, options=None):
     state = {'bug_id': bug_id}
     OutputCapture().assert_outputs(self, self._run_step, [step, MockTool(), options, state], expected_logs=expected_logs)
 def test_no_clean(self):
     tool = MockTool()
     tool._scm = Mock()
     step = CleanWorkingDirectory(tool, MockOptions(clean=False))
     step.run({})
     self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 0)