Delete code for old commit queue
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2020 18:24:04 +0000 (18:24 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2020 18:24:04 +0000 (18:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211581

Reviewed by Alexey Proskuryakov.

* Scripts/webkitpy/common/config/committervalidator.py: Removed.
* Scripts/webkitpy/common/config/committervalidator_unittest.py: Removed.
* Scripts/webkitpy/tool/bot/commitqueuetask.py: Removed.
* Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py: Removed.
* Scripts/webkitpy/tool/commands/queues.py:
(PatchProcessingQueue._upload_results_archive_for_patch):
(CommitQueue): Deleted.
* Scripts/webkitpy/tool/commands/queues_unittest.py:
(NeedsUpdateSequence._run):
(TestCommitQueue): Deleted.
(AlwaysCommitQueueTool): Deleted.
(SecondThoughtsCommitQueue): Deleted.
(CommitQueueTest): Deleted.
(test_did_pass_testing_ews): Deleted.
* Scripts/webkitpy/tool/steps/validatechangelogs.py:
* Scripts/webkitpy/tool/steps/validatereviewer.py:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261319 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/config/committervalidator.py [deleted file]
Tools/Scripts/webkitpy/common/config/committervalidator_unittest.py [deleted file]
Tools/Scripts/webkitpy/tool/bot/commitqueuetask.py [deleted file]
Tools/Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py [deleted file]
Tools/Scripts/webkitpy/tool/commands/queues.py
Tools/Scripts/webkitpy/tool/commands/queues_unittest.py
Tools/Scripts/webkitpy/tool/steps/validatechangelogs.py
Tools/Scripts/webkitpy/tool/steps/validatereviewer.py

index 1e659a4..80a8ead 100644 (file)
@@ -1,3 +1,27 @@
+2020-05-07  Aakash Jain  <aakash_jain@apple.com>
+
+        Delete code for old commit queue
+        https://bugs.webkit.org/show_bug.cgi?id=211581
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Scripts/webkitpy/common/config/committervalidator.py: Removed.
+        * Scripts/webkitpy/common/config/committervalidator_unittest.py: Removed.
+        * Scripts/webkitpy/tool/bot/commitqueuetask.py: Removed.
+        * Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py: Removed.
+        * Scripts/webkitpy/tool/commands/queues.py:
+        (PatchProcessingQueue._upload_results_archive_for_patch):
+        (CommitQueue): Deleted.
+        * Scripts/webkitpy/tool/commands/queues_unittest.py:
+        (NeedsUpdateSequence._run):
+        (TestCommitQueue): Deleted.
+        (AlwaysCommitQueueTool): Deleted.
+        (SecondThoughtsCommitQueue): Deleted.
+        (CommitQueueTest): Deleted.
+        (test_did_pass_testing_ews): Deleted.
+        * Scripts/webkitpy/tool/steps/validatechangelogs.py:
+        * Scripts/webkitpy/tool/steps/validatereviewer.py:
+
 2020-05-07  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, reverting r261286.
diff --git a/Tools/Scripts/webkitpy/common/config/committervalidator.py b/Tools/Scripts/webkitpy/common/config/committervalidator.py
deleted file mode 100644 (file)
index c3b289b..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-# Copyright (c) 2009 Google Inc. All rights reserved.
-# Copyright (c) 2009 Apple Inc. All rights reserved.
-# Copyright (c) 2010 Research In Motion Limited. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-from webkitpy.common.config import committers, urls
-
-
-class CommitterValidator(object):
-    def __init__(self, host):
-        self.host = host
-
-    def _contributors_json_path(self):
-        # contributors.json resides in the same directory as committers.py
-        dirname = self.host.filesystem.dirname(self.host.filesystem.path_to_module(committers.__name__))
-        path = self.host.filesystem.join(dirname, 'contributors.json')
-        return self.host.filesystem.relpath(path, self.host.scm().checkout_root)
-
-    def _flag_permission_rejection_message(self, setter_email, flag_name):
-        # This could be queried from the tool.
-        queue_name = "commit-queue"
-        committers_list = self._contributors_json_path()
-        message = "%s does not have %s permissions according to %s." % (
-                        setter_email,
-                        flag_name,
-                        urls.view_source_url(committers_list))
-        message += "\n\n- If you do not have %s rights please read %s for instructions on how to use bugzilla flags." % (
-                        flag_name, urls.contribution_guidelines)
-        message += "\n\n- If you have %s rights please correct the error in %s by adding yourself to the file (no review needed).  " % (
-                        flag_name, committers_list)
-        message += "The %s restarts itself every 2 hours.  After restart the %s will correctly respect your %s rights." % (
-                        queue_name, queue_name, flag_name)
-        return message
-
-    def _validate_setter_email(self, patch, result_key, rejection_function):
-        committer = getattr(patch, result_key)()
-        # If the flag is set, and we don't recognize the setter, reject the flag!
-        setter_email = patch._attachment_dictionary.get("%s_email" % result_key)
-        if setter_email and not committer:
-            rejection_function(patch.id(), self._flag_permission_rejection_message(setter_email, result_key))
-            return False
-        return True
-
-    def _reject_patch_if_flags_are_invalid(self, patch):
-        return (self._validate_setter_email(patch, "reviewer", self.reject_patch_from_review_queue)
-            and self._validate_setter_email(patch, "committer", self.reject_patch_from_commit_queue))
-
-    def patches_after_rejecting_invalid_commiters_and_reviewers(self, patches):
-        return [patch for patch in patches if self._reject_patch_if_flags_are_invalid(patch)]
-
-    def reject_patch_from_commit_queue(self,
-                                       attachment_id,
-                                       additional_comment_text=None):
-        comment_text = "Rejecting attachment %s from commit-queue." % attachment_id
-        if additional_comment_text:
-            comment_text += "\n\n%s" % additional_comment_text
-        self.host.bugs.set_flag_on_attachment(attachment_id,
-                                              "commit-queue",
-                                              "-",
-                                              comment_text)
-
-    def reject_patch_from_review_queue(self,
-                                       attachment_id,
-                                       additional_comment_text=None):
-        comment_text = "Rejecting attachment %s from review queue." % attachment_id
-        if additional_comment_text:
-            comment_text += "\n\n%s" % additional_comment_text
-        self.host.bugs.set_flag_on_attachment(attachment_id,
-                                              'review',
-                                              '-',
-                                              comment_text)
diff --git a/Tools/Scripts/webkitpy/common/config/committervalidator_unittest.py b/Tools/Scripts/webkitpy/common/config/committervalidator_unittest.py
deleted file mode 100644 (file)
index a5ee6a1..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (C) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#    * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#    * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#    * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import unittest
-
-from webkitpy.common.host_mock import MockHost
-from webkitpy.common.config.committervalidator import CommitterValidator
-
-
-class CommitterValidatorTest(unittest.TestCase):
-    def test_flag_permission_rejection_message(self):
-        validator = CommitterValidator(MockHost())
-        self.assertEqual(validator._contributors_json_path(), "Tools/Scripts/webkitpy/common/config/contributors.json")
-        expected_messsage = """foo@foo.com does not have review permissions according to https://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/contributors.json.
-
-- If you do not have review rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags.
-
-- If you have review rights please correct the error in Tools/Scripts/webkitpy/common/config/contributors.json by adding yourself to the file (no review needed).  The commit-queue restarts itself every 2 hours.  After restart the commit-queue will correctly respect your review rights."""
-        self.assertMultiLineEqual(validator._flag_permission_rejection_message("foo@foo.com", "review"), expected_messsage)
diff --git a/Tools/Scripts/webkitpy/tool/bot/commitqueuetask.py b/Tools/Scripts/webkitpy/tool/bot/commitqueuetask.py
deleted file mode 100644 (file)
index a53ca1d..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright (c) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-from webkitpy.tool.bot.patchanalysistask import PatchAnalysisTask, PatchAnalysisTaskDelegate, PatchIsNotValid
-
-
-class CommitQueueTaskDelegate(PatchAnalysisTaskDelegate):
-    def parent_command(self):
-        return "commit-queue"
-
-    def did_pass_testing_ews(self, patch):
-        raise NotImplementedError("subclasses must implement")
-
-
-class CommitQueueTask(PatchAnalysisTask):
-    def validate(self):
-        # Bugs might get closed, or patches might be obsoleted or r-'d while the
-        # commit-queue is processing.
-        self._patch = self._delegate.refetch_patch(self._patch)
-        if self._patch.is_obsolete():
-            self.error = "Patch is obsolete."
-            return False
-        if self._patch.bug().is_closed():
-            self.error = "Bug is already closed."
-            return False
-        if not self._patch.committer():
-            self.error = "No patch committer found."
-            return False
-        if self._patch.review() == "-":
-            self.error = "Patch is marked r-."
-            return False
-        return True
-
-    def _validate_changelog(self):
-        return self._run_command([
-            "validate-changelog",
-            "--check-oops",
-            "--non-interactive",
-            self._patch.id(),
-        ],
-        "ChangeLog validated",
-        "ChangeLog did not pass validation")
-
-    def _did_pass_tests_recently(self):
-        if self._delegate.did_pass_testing_ews(self._patch):
-            return True
-        return self._test_patch()
-
-    def run(self):
-        if not self._clean():
-            return False
-        if not self._update():
-            return False
-        if not self._apply():
-            return self.report_failure()
-        if not self._validate_changelog():
-            return self.report_failure()
-        if not self._patch.is_revert():
-            if not self._build():
-                if not self._build_without_patch():
-                    return False
-                return self.report_failure()
-            if not self._did_pass_tests_recently():
-                return False
-        # FIXME: We should understand why the land failure occurred and retry if possible.
-        if not self._land():
-            return self.report_failure()
-        return True
diff --git a/Tools/Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py b/Tools/Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py
deleted file mode 100644 (file)
index bcf8863..0000000
+++ /dev/null
@@ -1,583 +0,0 @@
-# Copyright (c) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-from datetime import datetime
-import logging
-import unittest
-
-from webkitpy.common.net import bugzilla
-from webkitpy.common.net.layouttestresults import LayoutTestResults
-from webkitpy.common.system.executive import ScriptError
-from webkitpy.common.system.outputcapture import OutputCapture
-from webkitpy.layout_tests.models import test_results
-from webkitpy.layout_tests.models import test_failures
-from webkitpy.thirdparty.mock import Mock
-from webkitpy.tool.bot.commitqueuetask import *
-from webkitpy.tool.mocktool import MockTool
-
-_log = logging.getLogger(__name__)
-
-
-class MockCommitQueue(CommitQueueTaskDelegate):
-    def __init__(self, error_plan):
-        self._error_plan = error_plan
-        self._failure_status_id = 0
-        self._flaky_tests = []
-
-    def run_command(self, command):
-        _log.info("run_webkit_patch: %s" % command)
-        if self._error_plan:
-            error = self._error_plan.pop(0)
-            if error:
-                raise error
-
-    def command_passed(self, success_message, patch):
-        _log.info("command_passed: success_message='%s' patch='%s'" % (
-            success_message, patch.id()))
-
-    def command_failed(self, failure_message, script_error, patch):
-        _log.info("command_failed: failure_message='%s' script_error='%s' patch='%s'" % (
-            failure_message, script_error, patch.id()))
-        self._failure_status_id += 1
-        return self._failure_status_id
-
-    def refetch_patch(self, patch):
-        return patch
-
-    def test_results(self):
-        return LayoutTestResults(test_results=[], did_exceed_test_failure_limit=False)
-
-    def report_flaky_tests(self, patch, flaky_results, results_archive):
-        current_flaky_tests = [result.test_name for result in flaky_results]
-        self._flaky_tests += current_flaky_tests
-        _log.info("report_flaky_tests: patch='%s' flaky_tests='%s' archive='%s'" % (patch.id(), current_flaky_tests, results_archive.filename))
-
-    def get_reported_flaky_tests(self):
-        return self._flaky_tests
-
-    def archive_last_test_results(self, patch):
-        _log.info("archive_last_test_results: patch='%s'" % patch.id())
-        archive = Mock()
-        archive.filename = "mock-archive-%s.zip" % patch.id()
-        return archive
-
-    def build_style(self):
-        return "release"
-
-    def did_pass_testing_ews(self, patch):
-        return False
-
-
-class FailingTestCommitQueue(MockCommitQueue):
-    def __init__(self, error_plan, test_failure_plan):
-        MockCommitQueue.__init__(self, error_plan)
-        self._test_run_counter = -1  # Special value to indicate tests have never been run.
-        self._test_failure_plan = test_failure_plan
-
-    def run_command(self, command):
-        if command[0] == "build-and-test":
-            self._test_run_counter += 1
-        MockCommitQueue.run_command(self, command)
-
-    def _mock_test_result(self, testname):
-        return test_results.TestResult(testname, [test_failures.FailureTextMismatch()])
-
-    def test_results(self):
-        # Doesn't make sense to ask for the test_results until the tests have run at least once.
-        assert(self._test_run_counter >= 0)
-        failures_for_run = self._test_failure_plan[self._test_run_counter]
-        assert(isinstance(failures_for_run, list))
-        results = LayoutTestResults(test_results=list(map(self._mock_test_result, failures_for_run)), did_exceed_test_failure_limit=(len(failures_for_run) >= 10))
-        return results
-
-
-class PatchAnalysisResult(object):
-    FAIL = "Fail"
-    DEFER = "Defer"
-    PASS = "Pass"
-
-
-class MockSimpleTestPlanCommitQueue(MockCommitQueue):
-    def __init__(self, first_test_failures, second_test_failures, clean_test_failures):
-        MockCommitQueue.__init__(self, [])
-        self._did_run_clean_tests = False
-        self._patch_test_results = [first_test_failures, second_test_failures]
-        self._clean_test_results = [clean_test_failures]
-        self._current_test_results = []
-
-    def run_command(self, command):
-        MockCommitQueue.run_command(self, command)
-        if command[0] == "build-and-test":
-            if "--no-clean" in command:
-                self._current_test_results = self._patch_test_results.pop(0)
-            else:
-                self._current_test_results = self._clean_test_results.pop(0)
-                self._did_run_clean_tests = True
-
-            if self._current_test_results:
-                raise ScriptError("MOCK test failure")
-
-    def _mock_test_result(self, testname):
-        return test_results.TestResult(testname, [test_failures.FailureTextMismatch()])
-
-    def test_results(self):
-        assert(isinstance(self._current_test_results, list))
-        return LayoutTestResults(test_results=list(map(self._mock_test_result, self._current_test_results)), did_exceed_test_failure_limit=(len(self._current_test_results) >= 10))
-
-    def did_run_clean_tests(self):
-        return self._did_run_clean_tests
-
-
-# We use GoldenScriptError to make sure that the code under test throws the
-# correct (i.e., golden) exception.
-class GoldenScriptError(ScriptError):
-    pass
-
-
-_lots_of_failing_tests = list(map(lambda num: "test-%s.html" % num, range(0, 100)))
-
-
-class CommitQueueTaskTest(unittest.TestCase):
-    def _run_and_expect_patch_analysis_result(self, commit_queue, expected_analysis_result, expected_reported_flaky_tests=[], expect_clean_tests_to_run=False, expected_failure_status_id=0):
-        tool = MockTool(log_executive=True)
-        patch = tool.bugs.fetch_attachment(10000)
-        task = CommitQueueTask(commit_queue, patch)
-
-        try:
-            result = task.run()
-            if result:
-                analysis_result = PatchAnalysisResult.PASS
-            else:
-                analysis_result = PatchAnalysisResult.DEFER
-        except ScriptError:
-            analysis_result = PatchAnalysisResult.FAIL
-
-        self.assertEqual(analysis_result, expected_analysis_result)
-        self.assertEqual(frozenset(commit_queue.get_reported_flaky_tests()), frozenset(expected_reported_flaky_tests))
-        self.assertEqual(commit_queue.did_run_clean_tests(), expect_clean_tests_to_run)
-
-        # The failure status only means anything if we actually failed.
-        if expected_analysis_result == PatchAnalysisResult.FAIL:
-            self.assertEqual(task.failure_status_id, expected_failure_status_id)
-            self.assertIsInstance(task.results_from_patch_test_run(patch), LayoutTestResults)
-
-    def _run_through_task(self, commit_queue, expected_logs, expected_exception=None, expect_retry=False):
-        self.maxDiff = None
-        tool = MockTool(log_executive=True)
-        patch = tool.bugs.fetch_attachment(10000)
-        task = CommitQueueTask(commit_queue, patch)
-        success = OutputCapture().assert_outputs(self, task.run, expected_logs=expected_logs, expected_exception=expected_exception)
-        if not expected_exception:
-            self.assertEqual(success, not expect_retry)
-        return task
-
-    def test_success_case(self):
-        commit_queue = MockCommitQueue([])
-        expected_logs = """run_webkit_patch: ['clean']
-command_passed: success_message='Cleaned working directory' patch='10000'
-run_webkit_patch: ['update']
-command_passed: success_message='Updated working directory' patch='10000'
-run_webkit_patch: ['apply-attachment', '--no-update', '--non-interactive', 10000]
-command_passed: success_message='Applied patch' patch='10000'
-run_webkit_patch: ['validate-changelog', '--check-oops', '--non-interactive', 10000]
-command_passed: success_message='ChangeLog validated' patch='10000'
-run_webkit_patch: ['build', '--no-clean', '--no-update', '--build-style=release']
-command_passed: success_message='Built patch' patch='10000'
-run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive', '--build-style=release']
-command_passed: success_message='Passed tests' patch='10000'
-run_webkit_patch: ['land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', 10000]
-command_passed: success_message='Landed patch' patch='10000'
-"""
-        self._run_through_task(commit_queue, expected_logs)
-
-    def test_fast_success_case(self):
-        commit_queue = MockCommitQueue([])
-        commit_queue.did_pass_testing_ews = lambda patch: True
-        expected_logs = """run_webkit_patch: ['clean']
-command_passed: success_message='Cleaned working directory' patch='10000'
-run_webkit_patch: ['update']
-command_passed: success_message='Updated working directory' patch='10000'
-run_webkit_patch: ['apply-attachment', '--no-update', '--non-interactive', 10000]
-command_passed: success_message='Applied patch' patch='10000'
-run_webkit_patch: ['validate-changelog', '--check-oops', '--non-interactive', 10000]
-command_passed: success_message='ChangeLog validated' patch='10000'
-run_webkit_patch: ['build', '--no-clean', '--no-update', '--build-style=release']
-command_passed: success_message='Built patch' patch='10000'
-run_webkit_patch: ['land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', 10000]
-command_passed: success_message='Landed patch' patch='10000'
-"""
-        self._run_through_task(commit_queue, expected_logs)
-
-    def test_clean_failure(self):
-        commit_queue = MockCommitQueue([
-            ScriptError("MOCK clean failure"),
-        ])
-        expected_logs = """run_webkit_patch: ['clean']
-command_failed: failure_message='Unable to clean working directory' script_error='MOCK clean failure' patch='10000'
-"""
-        self._run_through_task(commit_queue, expected_logs, expect_retry=True)
-
-    def test_update_failure(self):
-        commit_queue = MockCommitQueue([
-            None,
-            ScriptError("MOCK update failure"),
-        ])
-        expected_logs = """run_webkit_patch: ['clean']
-command_passed: success_message='Cleaned working directory' patch='10000'
-run_webkit_patch: ['update']
-command_failed: failure_message='Unable to update working directory' script_error='MOCK update failure' patch='10000'
-"""
-        self._run_through_task(commit_queue, expected_logs, expect_retry=True)
-
-    def test_apply_failure(self):
-        commit_queue = MockCommitQueue([
-            None,
-            None,
-            GoldenScriptError("MOCK apply failure"),
-        ])
-        expected_logs = """run_webkit_patch: ['clean']
-command_passed: success_message='Cleaned working directory' patch='10000'
-run_webkit_patch: ['update']
-command_passed: success_message='Updated working directory' patch='10000'
-run_webkit_patch: ['apply-attachment', '--no-update', '--non-interactive', 10000]
-command_failed: failure_message='Patch does not apply' script_error='MOCK apply failure' patch='10000'
-"""
-        self._run_through_task(commit_queue, expected_logs, GoldenScriptError)
-
-    def test_validate_changelog_failure(self):
-        commit_queue = MockCommitQueue([
-            None,
-            None,
-            None,
-            GoldenScriptError("MOCK validate failure"),
-        ])
-        expected_logs = """run_webkit_patch: ['clean']
-command_passed: success_message='Cleaned working directory' patch='10000'
-run_webkit_patch: ['update']
-command_passed: success_message='Updated working directory' patch='10000'
-run_webkit_patch: ['apply-attachment', '--no-update', '--non-interactive', 10000]
-command_passed: success_message='Applied patch' patch='10000'
-run_webkit_patch: ['validate-changelog', '--check-oops', '--non-interactive', 10000]
-command_failed: failure_message='ChangeLog did not pass validation' script_error='MOCK validate failure' patch='10000'
-"""
-        self._run_through_task(commit_queue, expected_logs, GoldenScriptError)
-
-    def test_build_failure(self):
-        commit_queue = MockCommitQueue([
-            None,
-            None,
-            None,
-            None,
-            GoldenScriptError("MOCK build failure"),
-        ])
-        expected_logs = """run_webkit_patch: ['clean']
-command_passed: success_message='Cleaned working directory' patch='10000'
-run_webkit_patch: ['update']
-command_passed: success_message='Updated working directory' patch='10000'
-run_webkit_patch: ['apply-attachment', '--no-update', '--non-interactive', 10000]
-command_passed: success_message='Applied patch' patch='10000'
-run_webkit_patch: ['validate-changelog', '--check-oops', '--non-interactive', 10000]
-command_passed: success_message='ChangeLog validated' patch='10000'
-run_webkit_patch: ['build', '--no-clean', '--no-update', '--build-style=release']
-command_failed: failure_message='Patch does not build' script_error='MOCK build failure' patch='10000'
-run_webkit_patch: ['build', '--force-clean', '--no-update', '--build-style=release']
-command_passed: success_message='Able to build without patch' patch='10000'
-"""
-        self._run_through_task(commit_queue, expected_logs, GoldenScriptError)
-
-    def test_red_build_failure(self):
-        commit_queue = MockCommitQueue([
-            None,
-            None,
-            None,
-            None,
-            ScriptError("MOCK build failure"),
-            ScriptError("MOCK clean build failure"),
-        ])
-        expected_logs = """run_webkit_patch: ['clean']
-command_passed: success_message='Cleaned working directory' patch='10000'
-run_webkit_patch: ['update']
-command_passed: success_message='Updated working directory' patch='10000'
-run_webkit_patch: ['apply-attachment', '--no-update', '--non-interactive', 10000]
-command_passed: success_message='Applied patch' patch='10000'
-run_webkit_patch: ['validate-changelog', '--check-oops', '--non-interactive', 10000]
-command_passed: success_message='ChangeLog validated' patch='10000'
-run_webkit_patch: ['build', '--no-clean', '--no-update', '--build-style=release']
-command_failed: failure_message='Patch does not build' script_error='MOCK build failure' patch='10000'
-run_webkit_patch: ['build', '--force-clean', '--no-update', '--build-style=release']
-command_failed: failure_message='Unable to build without patch' script_error='MOCK clean build failure' patch='10000'
-"""
-        self._run_through_task(commit_queue, expected_logs, expect_retry=True)
-
-    def test_land_failure(self):
-        commit_queue = MockCommitQueue([
-            None,
-            None,
-            None,
-            None,
-            None,
-            None,
-            GoldenScriptError("MOCK land failure"),
-        ])
-        expected_logs = """run_webkit_patch: ['clean']
-command_passed: success_message='Cleaned working directory' patch='10000'
-run_webkit_patch: ['update']
-command_passed: success_message='Updated working directory' patch='10000'
-run_webkit_patch: ['apply-attachment', '--no-update', '--non-interactive', 10000]
-command_passed: success_message='Applied patch' patch='10000'
-run_webkit_patch: ['validate-changelog', '--check-oops', '--non-interactive', 10000]
-command_passed: success_message='ChangeLog validated' patch='10000'
-run_webkit_patch: ['build', '--no-clean', '--no-update', '--build-style=release']
-command_passed: success_message='Built patch' patch='10000'
-run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive', '--build-style=release']
-command_passed: success_message='Passed tests' patch='10000'
-run_webkit_patch: ['land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', 10000]
-command_failed: failure_message='Unable to land patch' script_error='MOCK land failure' patch='10000'
-"""
-        # FIXME: This should really be expect_retry=True for a better user experiance.
-        self._run_through_task(commit_queue, expected_logs, GoldenScriptError)
-
-    def test_failed_archive(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1"],
-            second_test_failures=[],
-            clean_test_failures=[])
-
-        # It's possible for the delegate to fail to archive layout tests,
-        # but we shouldn't try to report flaky tests when that happens.
-        commit_queue.archive_last_test_results = lambda patch: None
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.PASS)
-
-    def test_double_flaky_test_failure(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1"],
-            second_test_failures=["Fail2"],
-            clean_test_failures=["Fail1"])
-
-        # The (subtle) point of this test is that report_flaky_tests does not get
-        # called for this run.
-        # Note also that there is no attempt to run the tests w/o the patch.
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expected_reported_flaky_tests=["Fail1", "Fail2"])
-
-    def test_test_failure(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1"],
-            second_test_failures=["Fail1"],
-            clean_test_failures=[])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.FAIL, expect_clean_tests_to_run=True, expected_failure_status_id=1)
-
-    def test_red_test_failure(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1"],
-            second_test_failures=["Fail1"],
-            clean_test_failures=["Fail1"])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.PASS, expect_clean_tests_to_run=True)
-
-    def test_first_failure_limit(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=_lots_of_failing_tests,
-            second_test_failures=[],
-            clean_test_failures=[])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=True, expected_failure_status_id=1)
-
-    def test_first_failure_limit_with_some_tree_redness(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=_lots_of_failing_tests,
-            second_test_failures=["Fail1", "Fail2", "Fail3"],
-            clean_test_failures=["Fail1", "Fail2", "Fail3"])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=True, expected_failure_status_id=1)
-
-    def test_second_failure_limit(self):
-        # There need to be some failures in the first set of tests, or it won't even make it to the second test.
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1", "Fail2", "Fail3"],
-            second_test_failures=_lots_of_failing_tests,
-            clean_test_failures=["Fail1", "Fail2", "Fail3"])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=True, expected_failure_status_id=2)
-
-    def test_tree_failure_limit_with_patch_that_potentially_fixes_some_redness(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1", "Fail2", "Fail3"],
-            second_test_failures=["Fail1", "Fail2", "Fail3"],
-            clean_test_failures=_lots_of_failing_tests)
-
-        # Unfortunately there are cases where the clean build will randomly fail enough tests to hit the failure limit.
-        # With that in mind, we can't actually know that this patch is good or bad until we see a clean run that doesn't
-        # exceed the failure limit.
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=True)
-
-    def test_first_and_second_failure_limit(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=_lots_of_failing_tests,
-            second_test_failures=_lots_of_failing_tests,
-            clean_test_failures=[])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.FAIL, expect_clean_tests_to_run=True, expected_failure_status_id=1)
-
-    def test_first_and_clean_failure_limit(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=_lots_of_failing_tests,
-            second_test_failures=[],
-            clean_test_failures=_lots_of_failing_tests)
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=True)
-
-    def test_first_second_and_clean_failure_limit(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=_lots_of_failing_tests,
-            second_test_failures=_lots_of_failing_tests,
-            clean_test_failures=_lots_of_failing_tests)
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=True)
-
-    def test_red_tree_patch_rejection(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1", "Fail2"],
-            second_test_failures=["Fail1", "Fail2"],
-            clean_test_failures=["Fail1"])
-
-        # failure_status_id should be of the test with patch (1), not the test without patch (2).
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.FAIL, expect_clean_tests_to_run=True, expected_failure_status_id=1)
-
-    def test_two_flaky_tests(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1"],
-            second_test_failures=["Fail2"],
-            clean_test_failures=["Fail1", "Fail2"])
-
-        # FIXME: This should pass, but as of right now, it defers.
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expected_reported_flaky_tests=["Fail1", "Fail2"])
-
-    def test_one_flaky_test(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1"],
-            second_test_failures=[],
-            clean_test_failures=[])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.PASS, expected_reported_flaky_tests=["Fail1"])
-
-    def test_very_flaky_patch(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1", "Fail2", "Fail3", "Fail4", "Fail5"],
-            second_test_failures=["Fail6", "Fail7", "Fail8", "Fail9", "Fail10"],
-            clean_test_failures=[])
-
-        # FIXME: This should actually fail, but right now it defers
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expected_reported_flaky_tests=["Fail1", "Fail2", "Fail3", "Fail4", "Fail5", "Fail6", "Fail7", "Fail8", "Fail9", "Fail10"])
-
-    def test_very_flaky_patch_with_some_tree_redness(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["PreExistingFail1", "PreExistingFail2", "Fail1", "Fail2", "Fail3", "Fail4", "Fail5"],
-            second_test_failures=["PreExistingFail1", "PreExistingFail2", "Fail6", "Fail7", "Fail8", "Fail9", "Fail10"],
-            clean_test_failures=["PreExistingFail1", "PreExistingFail2"])
-
-        # FIXME: This should actually fail, but right now it defers
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=True, expected_reported_flaky_tests=["Fail1", "Fail2", "Fail3", "Fail4", "Fail5", "Fail6", "Fail7", "Fail8", "Fail9", "Fail10"])
-
-    def test_different_test_failures(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1", "Fail2", "Fail3", "Fail4", "Fail5", "Fail6"],
-            second_test_failures=["Fail1", "Fail2", "Fail3", "Fail4", "Fail5"],
-            clean_test_failures=[])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.FAIL, expect_clean_tests_to_run=True, expected_reported_flaky_tests=["Fail6"], expected_failure_status_id=1)
-
-    def test_different_test_failures_with_some_tree_redness(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["PreExistingFail1", "PreExistingFail2", "Fail1", "Fail2", "Fail3", "Fail4", "Fail5", "Fail6"],
-            second_test_failures=["PreExistingFail1", "PreExistingFail2", "Fail1", "Fail2", "Fail3", "Fail4", "Fail5"],
-            clean_test_failures=["PreExistingFail1", "PreExistingFail2"])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.FAIL, expect_clean_tests_to_run=True, expected_reported_flaky_tests=["Fail6"], expected_failure_status_id=1)
-
-    def test_different_test_failures_with_some_tree_redness_and_some_fixes(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["PreExistingFail1", "Fail1", "Fail2", "Fail3", "Fail4", "Fail5", "Fail6"],
-            second_test_failures=["PreExistingFail1", "Fail1", "Fail2", "Fail3", "Fail4", "Fail5"],
-            clean_test_failures=["PreExistingFail1", "PreExistingFail2"])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.FAIL, expect_clean_tests_to_run=True, expected_reported_flaky_tests=["Fail6"], expected_failure_status_id=1)
-
-    def test_mildly_flaky_patch(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1"],
-            second_test_failures=["Fail2"],
-            clean_test_failures=[])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=False, expected_reported_flaky_tests=["Fail1", "Fail2"])
-
-    def test_mildly_flaky_patch_with_some_tree_redness(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["PreExistingFail1", "PreExistingFail2", "Fail1"],
-            second_test_failures=["PreExistingFail1", "PreExistingFail2", "Fail2"],
-            clean_test_failures=["PreExistingFail1", "PreExistingFail2"])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=True, expected_reported_flaky_tests=["Fail1", "Fail2"])
-
-    def test_mildly_flaky_patch_with_some_tree_redness_and_flakiness(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["PreExistingFail1", "PreExistingFail2", "Fail1"],
-            second_test_failures=["PreExistingFail1", "PreExistingFail2"],
-            clean_test_failures=["PreExistingFail1", "PreExistingFail2", "Fail2"])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.DEFER, expect_clean_tests_to_run=True, expected_reported_flaky_tests=["Fail1"])
-
-    def test_tree_more_red_than_patch(self):
-        commit_queue = MockSimpleTestPlanCommitQueue(
-            first_test_failures=["Fail1", "Fail2", "Fail3"],
-            second_test_failures=["Fail1", "Fail2", "Fail3"],
-            clean_test_failures=["Fail1", "Fail2", "Fail3", "Fail4"])
-
-        self._run_and_expect_patch_analysis_result(commit_queue, PatchAnalysisResult.PASS, expect_clean_tests_to_run=True)
-
-    def _expect_validate(self, patch, is_valid):
-        class MockDelegate(object):
-            def refetch_patch(self, patch):
-                return patch
-
-        task = CommitQueueTask(MockDelegate(), patch)
-        self.assertEqual(task.validate(), is_valid)
-
-    def _mock_patch(self, attachment_dict={}, bug_dict={'bug_status': 'NEW'}, committer="fake"):
-        bug = bugzilla.Bug(bug_dict, None)
-        patch = bugzilla.Attachment(attachment_dict, bug)
-        patch._committer = committer
-        return patch
-
-    def test_validate(self):
-        self._expect_validate(self._mock_patch(), True)
-        self._expect_validate(self._mock_patch({'is_obsolete': True}), False)
-        self._expect_validate(self._mock_patch(bug_dict={'bug_status': 'CLOSED'}), False)
-        self._expect_validate(self._mock_patch(committer=None), False)
-        self._expect_validate(self._mock_patch({'review': '-'}), False)
index 0f44db6..50c6a4f 100644 (file)
@@ -37,13 +37,11 @@ import traceback
 
 from optparse import make_option
 
-from webkitpy.common.config.committervalidator import CommitterValidator
 from webkitpy.common.config.ports import DeprecatedPort
 from webkitpy.common.net.bugzilla import Attachment
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.common.unicode_compatibility import BytesIO
 from webkitpy.tool.bot.botinfo import BotInfo
-from webkitpy.tool.bot.commitqueuetask import CommitQueueTask, CommitQueueTaskDelegate
 from webkitpy.tool.bot.flakytestreporter import FlakyTestReporter
 from webkitpy.tool.bot.layouttestresultsreader import LayoutTestResultsReader
 from webkitpy.tool.bot.patchanalysistask import UnableToApplyPatch, PatchIsNotValid
@@ -290,123 +288,6 @@ class PatchProcessingQueue(AbstractPatchQueue):
             self._tool.bugs.add_attachment_to_bug(patch.bug_id(), results_archive_file, description, filename="layout-test-results.zip", comment_text=comment_text)
 
 
-class CommitQueue(PatchProcessingQueue, StepSequenceErrorHandler, CommitQueueTaskDelegate):
-    def __init__(self, commit_queue_task_class=CommitQueueTask):
-        self._commit_queue_task_class = commit_queue_task_class
-        PatchProcessingQueue.__init__(self)
-
-    name = "commit-queue"
-    port_name = "mac"
-
-    # AbstractPatchQueue methods
-
-    def begin_work_queue(self):
-        PatchProcessingQueue.begin_work_queue(self)
-        self.committer_validator = CommitterValidator(self._tool)
-        self._layout_test_results_reader = LayoutTestResultsReader(self._tool, self._port.results_directory(), self._log_directory())
-
-    def next_work_item(self):
-        return self._next_patch()
-
-    def process_work_item(self, patch):
-        self._cc_watchers(patch.bug_id())
-        task = self._commit_queue_task_class(self, patch)
-        try:
-            if task.run():
-                self._did_pass(patch)
-                return True
-            self._unlock_patch(patch)
-            return False
-        except PatchIsNotValid as error:
-            self._did_error(patch, "%s did not process patch. Reason: %s" % (self.name, error.failure_message))
-            return False
-        except ScriptError as e:
-            if self._can_access_bug(patch.bug_id()):
-                validator = CommitterValidator(self._tool)
-                validator.reject_patch_from_commit_queue(patch.id(), self._error_message_for_bug(task, patch, e))
-            results_archive = task.results_archive_from_patch_test_run(patch)
-            if results_archive:
-                self._upload_results_archive_for_patch(patch, results_archive)
-            self._did_fail(patch)
-            return False
-
-    def _failing_tests_message(self, task, patch):
-        results = task.results_from_patch_test_run(patch)
-
-        if not results:
-            return None
-
-        if results.did_exceed_test_failure_limit():
-            return "Number of test failures exceeded the failure limit."
-        return "New failing tests:\n%s" % "\n".join(results.failing_tests())
-
-    def _error_message_for_bug(self, task, patch, script_error):
-        message = self._failing_tests_message(task, patch)
-        if not message:
-            message = script_error.message_with_output(output_limit=5000)
-        results_link = self._tool.status_server.results_url_for_status(task.failure_status_id)
-        return "%s\nFull output: %s" % (message, results_link)
-
-    def handle_unexpected_error(self, patch, message):
-        self.committer_validator.reject_patch_from_commit_queue(patch.id(), message)
-
-    # CommitQueueTaskDelegate methods
-
-    def run_command(self, command):
-        self.run_webkit_patch(command + [self._deprecated_port.flag()])
-
-    def command_passed(self, message, patch):
-        self._update_status(message, patch=patch)
-
-    def command_failed(self, message, script_error, patch):
-        failure_log = self._log_from_script_error_for_upload(script_error)
-        return self._update_status(message, patch=patch, results_file=failure_log)
-
-    def expected_failures(self):
-        return self._expected_failures
-
-    def test_results(self):
-        return self._layout_test_results_reader.results()
-
-    def archive_last_test_results(self, patch):
-        return self._layout_test_results_reader.archive(patch)
-
-    def refetch_patch(self, patch):
-        return self._tool.bugs.fetch_attachment(patch.id())
-
-    def report_flaky_tests(self, patch, flaky_test_results, results_archive=None):
-        reporter = FlakyTestReporter(self._tool, self.name)
-        reporter.report_flaky_tests(patch, flaky_test_results, results_archive)
-
-    def did_pass_testing_ews(self, patch):
-        # Only Mac and Mac WK2 run tests
-        # FIXME: We shouldn't have to hard-code it here.
-        patch_status = self._tool.status_server.patch_status
-        return patch_status("mac-ews", patch.id()) == self._pass_status or patch_status("mac-wk2-ews", patch.id()) == self._pass_status
-
-    # StepSequenceErrorHandler methods
-
-    @classmethod
-    def handle_script_error(cls, tool, state, script_error):
-        # Hitting this error handler should be pretty rare.  It does occur,
-        # however, when a patch no longer applies to top-of-tree in the final
-        # land step.
-        _log.error(script_error.message_with_output(output_limit=5000))
-
-    @classmethod
-    def handle_checkout_needs_update(cls, tool, state, options, error):
-        message = "Tests passed, but commit failed (checkout out of date).  Updating, then landing without building or re-running tests."
-        tool.status_server.update_status(cls.name, message, state["patch"])
-        # The only time when we find out that out checkout needs update is
-        # when we were ready to actually pull the trigger and land the patch.
-        # Rather than spinning in the master process, we retry without
-        # building or testing, which is much faster.
-        options.build = False
-        options.test = False
-        options.update = True
-        raise TryAgain()
-
-
 class AbstractReviewQueue(PatchProcessingQueue, StepSequenceErrorHandler):
     """This is the base-class for the EWS queues and the style-queue."""
     def __init__(self, options=None):
index 1d745d3..6b427c4 100644 (file)
@@ -46,20 +46,6 @@ from webkitpy.common.net.statusserver_mock import MockStatusServer
 from webkitpy.tool.mocktool import MockTool, MockOptions
 
 
-class TestCommitQueue(CommitQueue):
-    def __init__(self, tool=None):
-        CommitQueue.__init__(self)
-        if tool:
-            self.bind_to_tool(tool)
-        self._options = MockOptions(confirm=False, parent_command="commit-queue", port=None)
-
-    def begin_work_queue(self):
-        output_capture = OutputCapture()
-        output_capture.capture_output()
-        CommitQueue.begin_work_queue(self)
-        output_capture.restore_output()
-
-
 class TestQueue(AbstractPatchQueue):
     name = "test-queue"
 
@@ -167,281 +153,6 @@ class NeedsUpdateSequence(StepSequence):
         raise CheckoutNeedsUpdate([], 1, "", None)
 
 
-class AlwaysCommitQueueTool(object):
-    def __init__(self):
-        self.status_server = MockStatusServer()
-
-    def command_by_name(self, name):
-        return CommitQueue
-
-
-class SecondThoughtsCommitQueue(TestCommitQueue):
-    def __init__(self, tool=None):
-        self._reject_patch = False
-        TestCommitQueue.__init__(self, tool)
-
-    def run_command(self, command):
-        # We want to reject the patch after the first validation,
-        # so wait to reject it until after some other command has run.
-        self._reject_patch = True
-        return CommitQueue.run_command(self, command)
-
-    def refetch_patch(self, patch):
-        if not self._reject_patch:
-            return self._tool.bugs.fetch_attachment(patch.id())
-
-        attachment_dictionary = {
-            "id": patch.id(),
-            "bug_id": patch.bug_id(),
-            "name": "Rejected",
-            "is_obsolete": True,
-            "is_patch": False,
-            "review": "-",
-            "reviewer_email": "foo@bar.com",
-            "commit-queue": "-",
-            "committer_email": "foo@bar.com",
-            "attacher_email": "Contributer1",
-        }
-        return Attachment(attachment_dictionary, None)
-
-
-class CommitQueueTest(QueuesTest):
-    def _mock_test_result(self, testname):
-        return test_results.TestResult(testname, [test_failures.FailureTextMismatch()])
-
-    def test_commit_queue(self):
-        tool = MockTool()
-        tool.filesystem.write_text_file('/tmp/layout-test-results/full_results.json', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
-        tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
-        expected_logs = {
-            "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
-            "process_work_item": """Running: webkit-patch clean --port=mac
-MOCK: update_status: commit-queue Cleaned working directory
-Running: webkit-patch update --port=mac
-MOCK: update_status: commit-queue Updated working directory
-Running: webkit-patch apply-attachment --no-update --non-interactive 10000 --port=mac
-MOCK: update_status: commit-queue Applied patch
-Running: webkit-patch validate-changelog --check-oops --non-interactive 10000 --port=mac
-MOCK: update_status: commit-queue ChangeLog validated
-Running: webkit-patch build --no-clean --no-update --build-style=release --port=mac
-MOCK: update_status: commit-queue Built patch
-Running: webkit-patch build-and-test --no-clean --no-update --test --non-interactive --build-style=release --port=mac
-MOCK: update_status: commit-queue Passed tests
-Running: webkit-patch land-attachment --force-clean --non-interactive --parent-command=commit-queue 10000 --port=mac
-MOCK: update_status: commit-queue Landed patch
-MOCK: update_status: commit-queue Pass
-MOCK: release_work_item: commit-queue 10000
-""",
-            "handle_script_error": "ScriptError error message\n\nMOCK output\n",
-            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
-        }
-        self.assert_queue_outputs(CommitQueue(), tool=tool, expected_logs=expected_logs)
-
-    def test_commit_queue_failure(self):
-        expected_logs = {
-            "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
-            "process_work_item": """MOCK: update_status: commit-queue Cleaned working directory
-MOCK: update_status: commit-queue Updated working directory
-MOCK: update_status: commit-queue Patch does not apply
-MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMOCK script error
-Full output: http://dummy_url'
-MOCK: update_status: commit-queue Fail
-MOCK: release_work_item: commit-queue 10000
-""",
-            "handle_script_error": "ScriptError error message\n\nMOCK output\n",
-            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
-        }
-        queue = CommitQueue()
-
-        def mock_run_webkit_patch(command):
-            if command[0] == 'clean' or command[0] == 'update':
-                # We want cleaning to succeed so we can error out on a step
-                # that causes the commit-queue to reject the patch.
-                return
-            raise ScriptError('MOCK script error')
-
-        queue.run_webkit_patch = mock_run_webkit_patch
-        self.assert_queue_outputs(queue, expected_logs=expected_logs)
-
-    def test_commit_queue_failure_with_failing_tests(self):
-        expected_logs = {
-            "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
-            "process_work_item": """MOCK: update_status: commit-queue Cleaned working directory
-MOCK: update_status: commit-queue Updated working directory
-MOCK: update_status: commit-queue Patch does not apply
-MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nNew failing tests:
-mock_test_name.html
-Full output: http://dummy_url'
-MOCK: update_status: commit-queue Fail
-MOCK: release_work_item: commit-queue 10000
-""",
-            "handle_script_error": "ScriptError error message\n\nMOCK output\n",
-            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
-        }
-
-        class MockCommitQueueTask(CommitQueueTask):
-            def results_from_patch_test_run(self, patch):
-                return LayoutTestResults([test_results.TestResult("mock_test_name.html", failures=[test_failures.FailureTextMismatch()])], did_exceed_test_failure_limit=False)
-
-        queue = CommitQueue(MockCommitQueueTask)
-
-        def mock_run_webkit_patch(command):
-            if command[0] == 'clean' or command[0] == 'update':
-                # We want cleaning to succeed so we can error out on a step
-                # that causes the commit-queue to reject the patch.
-                return
-            raise ScriptError('MOCK script error')
-
-        queue.run_webkit_patch = mock_run_webkit_patch
-        self.assert_queue_outputs(queue, expected_logs=expected_logs)
-
-    def test_revert(self):
-        tool = MockTool()
-        tool.filesystem.write_text_file('/tmp/layout-test-results/full_results.json', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
-        tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
-        tool.buildbot.light_tree_on_fire()
-        expected_logs = {
-            "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
-            "process_work_item": """Running: webkit-patch clean --port=%(port)s
-MOCK: update_status: commit-queue Cleaned working directory
-Running: webkit-patch update --port=%(port)s
-MOCK: update_status: commit-queue Updated working directory
-Running: webkit-patch apply-attachment --no-update --non-interactive 10000 --port=%(port)s
-MOCK: update_status: commit-queue Applied patch
-Running: webkit-patch validate-changelog --check-oops --non-interactive 10000 --port=%(port)s
-MOCK: update_status: commit-queue ChangeLog validated
-Running: webkit-patch build --no-clean --no-update --build-style=release --port=%(port)s
-MOCK: update_status: commit-queue Built patch
-Running: webkit-patch build-and-test --no-clean --no-update --test --non-interactive --build-style=release --port=%(port)s
-MOCK: update_status: commit-queue Passed tests
-Running: webkit-patch land-attachment --force-clean --non-interactive --parent-command=commit-queue 10000 --port=%(port)s
-MOCK: update_status: commit-queue Landed patch
-MOCK: update_status: commit-queue Pass
-MOCK: release_work_item: commit-queue 10000
-""" % {"port": "mac"},
-            "handle_script_error": "ScriptError error message\n\nMOCK output\n",
-            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
-        }
-        self.assert_queue_outputs(CommitQueue(), tool=tool, expected_logs=expected_logs)
-
-    def test_revert_lands(self):
-        tool = MockTool()
-        tool.buildbot.light_tree_on_fire()
-        revert_patch = tool.bugs.fetch_attachment(10005)  # _patch6, a revert patch.
-        assert(revert_patch.is_revert())
-        expected_logs = {
-            "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
-            "process_work_item": """Running: webkit-patch clean --port=%(port)s
-MOCK: update_status: commit-queue Cleaned working directory
-Running: webkit-patch update --port=%(port)s
-MOCK: update_status: commit-queue Updated working directory
-Running: webkit-patch apply-attachment --no-update --non-interactive 10005 --port=%(port)s
-MOCK: update_status: commit-queue Applied patch
-Running: webkit-patch validate-changelog --check-oops --non-interactive 10005 --port=%(port)s
-MOCK: update_status: commit-queue ChangeLog validated
-Running: webkit-patch land-attachment --force-clean --non-interactive --parent-command=commit-queue 10005 --port=%(port)s
-MOCK: update_status: commit-queue Landed patch
-MOCK: update_status: commit-queue Pass
-MOCK: release_work_item: commit-queue 10005
-""" % {"port": "mac"},
-            "handle_script_error": "ScriptError error message\n\nMOCK output\n",
-            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10005' with comment 'Rejecting attachment 10005 from commit-queue.\n\nMock error message'\n",
-        }
-        self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=revert_patch, expected_logs=expected_logs)
-
-    def test_non_valid_patch(self):
-        tool = MockTool()
-        patch = tool.bugs.fetch_attachment(10007)  # _patch8, resolved bug, without review flag, not marked obsolete (maybe already landed)
-        expected_logs = {
-            "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
-            "process_work_item": """MOCK: update_status: commit-queue Error: commit-queue did not process patch. Reason: Bug is already closed.
-MOCK: release_work_item: commit-queue 10007
-""",
-        }
-        self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=patch, expected_logs=expected_logs)
-
-    def test_auto_retry(self):
-        queue = CommitQueue()
-        options = Mock()
-        options.parent_command = "commit-queue"
-        tool = AlwaysCommitQueueTool()
-        sequence = NeedsUpdateSequence(None)
-
-        expected_logs = """Commit failed because the checkout is out of date. Please update and try again.
-MOCK: update_status: commit-queue Tests passed, but commit failed (checkout out of date).  Updating, then landing without building or re-running tests.
-"""
-        state = {'patch': None}
-        OutputCapture().assert_outputs(self, sequence.run_and_handle_errors, [tool, options, state], expected_exception=TryAgain, expected_logs=expected_logs)
-
-        self.assertTrue(options.update)
-        self.assertFalse(options.build)
-        self.assertFalse(options.test)
-
-    def test_manual_reject_during_processing(self):
-        queue = SecondThoughtsCommitQueue(MockTool())
-        queue.begin_work_queue()
-        queue._tool.filesystem.write_text_file('/tmp/layout-test-results/full_results.json', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
-        queue._tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
-        queue._options = Mock()
-        queue._options.port = None
-        expected_logs = """Running: webkit-patch clean --port=mac
-MOCK: update_status: commit-queue Cleaned working directory
-MOCK: update_status: commit-queue Error: commit-queue did not process patch. Reason: Patch is obsolete.
-MOCK: release_work_item: commit-queue 10000
-"""
-        self.maxDiff = None
-        OutputCapture().assert_outputs(self, queue.process_work_item, [QueuesTest.mock_work_item], expected_logs=expected_logs)
-
-    def test_report_flaky_tests(self):
-        queue = TestCommitQueue(MockTool())
-        expected_logs = """MOCK bug comment: bug_id=50002, cc=None, see_also=None
---- Begin comment ---
-The commit-queue just saw foo/bar.html flake (text diff) while processing attachment 10000 on bug 50000.
-Port: MockPort  Platform: MockPlatform 1.0
---- End comment ---
-
-MOCK add_attachment_to_bug: bug_id=50002, description=Failure diff from bot filename=failure.diff mimetype=None
-MOCK bug comment: bug_id=50002, cc=None, see_also=None
---- Begin comment ---
-The commit-queue just saw bar/baz.html flake (text diff) while processing attachment 10000 on bug 50000.
-Port: MockPort  Platform: MockPlatform 1.0
---- End comment ---
-
-bar/baz-diffs.txt does not exist in results archive, uploading entire archive.
-MOCK add_attachment_to_bug: bug_id=50002, description=Archive of layout-test-results from bot filename=layout-test-results.zip mimetype=None
-MOCK bug comment: bug_id=50000, cc=None, see_also=None
---- Begin comment ---
-The commit-queue encountered the following flaky tests while processing attachment 10000:
-
-foo/bar.html bug 50002 (author: abarth@webkit.org)
-bar/baz.html bug 50002 (author: abarth@webkit.org)
-The commit-queue is continuing to process your patch.
---- End comment ---
-
-"""
-        test_names = ["foo/bar.html", "bar/baz.html"]
-        test_results = [self._mock_test_result(name) for name in test_names]
-
-        class MockZipFile(object):
-            def __init__(self):
-                self.fp = StringIO()
-
-            def read(self, path):
-                return ""
-
-            def namelist(self):
-                # This is intentionally missing one diffs.txt to exercise the "upload the whole zip" codepath.
-                return ['foo/bar-diffs.txt']
-
-        OutputCapture().assert_outputs(self, queue.report_flaky_tests, [QueuesTest.mock_work_item, test_results, MockZipFile()], expected_logs=expected_logs)
-
-    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))
-
-
 class StyleQueueTest(QueuesTest):
     def test_style_queue_with_style_exception(self):
         expected_logs = {
index e77e5c0..b3e4c6a 100644 (file)
@@ -37,7 +37,7 @@ from webkitpy.common.checkout.diff_parser import DiffParser
 _log = logging.getLogger(__name__)
 
 
-# This is closely related to the ValidateReviewer step and the CommitterValidator class.
+# This is closely related to the ValidateReviewer step.
 # We may want to unify more of this code in one place.
 class ValidateChangeLogs(AbstractStep):
     @classmethod
index 38be8f0..e836386 100644 (file)
@@ -36,7 +36,6 @@ from webkitpy.tool.steps.options import Options
 _log = logging.getLogger(__name__)
 
 
-# FIXME: Some of this logic should probably be unified with CommitterValidator?
 class ValidateReviewer(AbstractStep):
     @classmethod
     def options(cls):