Isolate Early Warning System definitions into a JSON
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Apr 2013 01:41:38 +0000 (01:41 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Apr 2013 01:41:38 +0000 (01:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114558

Reviewed by Benjamin Poulain.

Added ews.json to common/config, and made tool/commands/__init__.py call
AbstractEarlyWarningSystem.load_ews_classes to instantiate classes based on ews.json.

Reland the patch since the EWS failure was a false positive.

* Scripts/webkitpy/common/config/ews.json: Extracted from earlywarningsystem.py.
* Scripts/webkitpy/tool/commands/__init__.py:
* Scripts/webkitpy/tool/commands/earlywarningsystem.py:
(AbstractEarlyWarningSystem):
(AbstractEarlyWarningSystem.__init__):
(AbstractEarlyWarningSystem.load_ews_classes): Added. Loads ews.json.
* Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:
(EarlyWarningSystemTest._default_expected_logs):
(_test_ews):
(test_ewses):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/common/config/ews.json [new file with mode: 0644]
Tools/Scripts/webkitpy/tool/commands/__init__.py
Tools/Scripts/webkitpy/tool/commands/earlywarningsystem.py
Tools/Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py

index de36f8014caa2abe6e19ece79252872bc8c14bb3..836407f45c72f294e1c8661c8c66d2e5ead18010 100644 (file)
@@ -1,3 +1,26 @@
+2013-04-16  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Isolate Early Warning System definitions into a JSON
+        https://bugs.webkit.org/show_bug.cgi?id=114558
+
+        Reviewed by Benjamin Poulain.
+
+        Added ews.json to common/config, and made tool/commands/__init__.py call
+        AbstractEarlyWarningSystem.load_ews_classes to instantiate classes based on ews.json.
+
+        Reland the patch since the EWS failure was a false positive.
+
+        * Scripts/webkitpy/common/config/ews.json: Extracted from earlywarningsystem.py.
+        * Scripts/webkitpy/tool/commands/__init__.py:
+        * Scripts/webkitpy/tool/commands/earlywarningsystem.py:
+        (AbstractEarlyWarningSystem):
+        (AbstractEarlyWarningSystem.__init__):
+        (AbstractEarlyWarningSystem.load_ews_classes): Added. Loads ews.json.
+        * Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:
+        (EarlyWarningSystemTest._default_expected_logs):
+        (_test_ews):
+        (test_ewses):
+
 2013-04-16  Sam Weinig  <sam@webkit.org>
 
         Fix fallout after r148545.
diff --git a/Tools/Scripts/webkitpy/common/config/ews.json b/Tools/Scripts/webkitpy/common/config/ews.json
new file mode 100644 (file)
index 0000000..480c403
--- /dev/null
@@ -0,0 +1,52 @@
+{
+    "GTK EWS": {
+        "port": "gtk",
+        "watchers": [
+            "xan.lopez@gmail.com"
+        ]
+    },
+    "GTK WK2 EWS": {
+        "port": "gtk-wk2",
+        "watchers": [
+            "xan.lopez@gmail.com"
+        ]
+    },
+    "EFL EWS": {
+        "port": "efl",
+        "watchers": [
+            "leandro@profusion.mobi",
+            "antognolli@profusion.mobi",
+            "lucas.demarchi@profusion.mobi",
+            "gyuyoung.kim@samsung.com"
+        ]
+    },
+    "Qt EWS": {
+        "port": "qt",
+        "watchers": [
+            "webkit-ews@sed.inf.u-szeged.hu"
+        ]
+    },
+    "Qt WK2 EWS": {
+        "port": "qt",
+        "watchers": [
+            "webkit-ews@sed.inf.u-szeged.hu"
+        ]
+    },
+    "Win EWS": {
+        "port": "win"
+    },
+    "Mac EWS": {
+        "port": "mac",
+        "watchers": [
+            "rniwa@webkit.org"
+        ],
+        "runTests": true
+    },
+    "Mac WK2 EWS": {
+        "port": "mac-wk2",
+        "watchers": [
+            "rniwa@webkit.org"
+        ],
+        "runTests": true
+    }
+}
\ No newline at end of file
index 3e2f2ae1c13e73964f951137f498ef22b6c67763..b382b46394ab6fbae11f7761b1cdefd8bafcc482 100644 (file)
@@ -7,7 +7,7 @@ from webkitpy.tool.commands.bugfortest import BugForTest
 from webkitpy.tool.commands.bugsearch import BugSearch
 from webkitpy.tool.commands.chromechannels import ChromeChannels
 from webkitpy.tool.commands.download import *
-from webkitpy.tool.commands.earlywarningsystem import *
+from webkitpy.tool.commands.earlywarningsystem import AbstractEarlyWarningSystem
 from webkitpy.tool.commands.findusers import FindUsers
 from webkitpy.tool.commands.gardenomatic import GardenOMatic
 from webkitpy.tool.commands.newcommitbot import NewCommitBot
@@ -21,3 +21,5 @@ from webkitpy.tool.commands.rebaselineserver import RebaselineServer
 from webkitpy.tool.commands.sheriffbot import *
 from webkitpy.tool.commands.upload import *
 from webkitpy.tool.commands.suggestnominations import *
+
+AbstractEarlyWarningSystem.load_ews_classes()
index b27bc1cbec9a8e3a692b84637c4ef3069c408485..b5e285c64a3dd86389b223441f459409bdf3b39c 100644 (file)
 # (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 json
 import logging
 from optparse import make_option
 
 from webkitpy.common.config.committers import CommitterList
 from webkitpy.common.config.ports import DeprecatedPort
+from webkitpy.common.system.filesystem import FileSystem
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.tool.bot.earlywarningsystemtask import EarlyWarningSystemTask, EarlyWarningSystemTaskDelegate
 from webkitpy.tool.bot.expectedfailures import ExpectedFailures
@@ -45,10 +47,10 @@ _log = logging.getLogger(__name__)
 class AbstractEarlyWarningSystem(AbstractReviewQueue, EarlyWarningSystemTaskDelegate):
     _build_style = "release"
     # FIXME: Switch _default_run_tests from opt-in to opt-out once more bots are ready to run tests.
-    _default_run_tests = False
+    run_tests = False
 
     def __init__(self):
-        options = [make_option("--run-tests", action="store_true", dest="run_tests", default=self._default_run_tests, help="Run the Layout tests for each patch")]
+        options = [make_option("--run-tests", action="store_true", dest="run_tests", default=self.run_tests, help="Run the Layout tests for each patch")]
         AbstractReviewQueue.__init__(self, options=options)
 
     def begin_work_queue(self):
@@ -135,67 +137,21 @@ class AbstractEarlyWarningSystem(AbstractReviewQueue, EarlyWarningSystemTaskDele
         # FIXME: Why does this not exit(1) like the superclass does?
         _log.error(script_error.message_with_output())
 
+    @classmethod
+    def load_ews_classes(cls):
+        filesystem = FileSystem()
+        json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'ews.json')
+        try:
+            ewses = json.loads(filesystem.read_text_file(json_path))
+        except ValueError:
+            return None
 
-class GtkEWS(AbstractEarlyWarningSystem):
-    name = "gtk-ews"
-    port_name = "gtk"
-    watchers = AbstractEarlyWarningSystem.watchers + [
-        "xan.lopez@gmail.com",
-    ]
-
-
-class GtkWK2EWS(AbstractEarlyWarningSystem):
-    name = "gtk-wk2-ews"
-    port_name = "gtk-wk2"
-    watchers = AbstractEarlyWarningSystem.watchers + [
-        "xan.lopez@gmail.com",
-    ]
-
-
-class EflEWS(AbstractEarlyWarningSystem):
-    name = "efl-ews"
-    port_name = "efl"
-    watchers = AbstractEarlyWarningSystem.watchers + [
-        "leandro@profusion.mobi",
-        "antognolli@profusion.mobi",
-        "lucas.demarchi@profusion.mobi",
-        "gyuyoung.kim@samsung.com",
-    ]
-
-
-class QtEWS(AbstractEarlyWarningSystem):
-    name = "qt-ews"
-    port_name = "qt"
-    watchers = AbstractEarlyWarningSystem.watchers + [
-        "webkit-ews@sed.inf.u-szeged.hu",
-    ]
-
-
-class QtWK2EWS(AbstractEarlyWarningSystem):
-    name = "qt-wk2-ews"
-    port_name = "qt"
-    watchers = AbstractEarlyWarningSystem.watchers + [
-        "webkit-ews@sed.inf.u-szeged.hu",
-    ]
-
-
-class WinEWS(AbstractEarlyWarningSystem):
-    name = "win-ews"
-    port_name = "win"
-
-class MacEWS(AbstractEarlyWarningSystem):
-    name = "mac-ews"
-    port_name = "mac"
-    _default_run_tests = True
-    watchers = AbstractEarlyWarningSystem.watchers + [
-        "rniwa@webkit.org",
-    ]
-
-
-class MacWK2EWS(AbstractEarlyWarningSystem):
-    name = "mac-wk2-ews"
-    port_name = "mac-wk2"
-    _default_run_tests = True
-    watchers = AbstractEarlyWarningSystem.watchers + [
-        "rniwa@webkit.org",
-    ]
+        classes = []
+        for name, config in ewses.iteritems():
+            classes.append(type(str(name.replace(' ', '')), (AbstractEarlyWarningSystem,), {
+                'name': config['port'] + '-ews',
+                'port_name': config['port'],
+                'watchers': config.get('watchers', []),
+                'run_tests': config.get('runTests', cls.run_tests),
+            }))
+        return classes
index d8c602a875b45621e6f0f35433c7602ec500f1c3..78dae3ba920992f800f6a4c5042a485cf43eb508 100644 (file)
@@ -56,7 +56,7 @@ class EarlyWarningSystemTest(QueuesTest):
             "name": ews.name,
             "port": ews.port_name,
         }
-        if ews._default_run_tests:
+        if ews.run_tests:
             run_tests_line = "Running: webkit-patch --status-host=example.com build-and-test --no-clean --no-update --test --non-interactive --port=%(port)s\n" % string_replacements
         else:
             run_tests_line = ""
@@ -80,13 +80,12 @@ MOCK: release_work_item: %(name)s 10000
         ews.bind_to_tool(MockTool())
         options = Mock()
         options.port = None
-        options.run_tests = ews._default_run_tests
+        options.run_tests = ews.run_tests
         self.assert_queue_outputs(ews, expected_logs=self._default_expected_logs(ews), options=options)
 
     def test_ewses(self):
-        self._test_ews(MacEWS())
-        self._test_ews(MacWK2EWS())
-        self._test_ews(QtEWS())
-        self._test_ews(QtWK2EWS())
-        self._test_ews(GtkEWS())
-        self._test_ews(EflEWS())
+        classes = AbstractEarlyWarningSystem.load_ews_classes()
+        self.assertTrue(classes)
+        self.maxDiff = None
+        for ews_class in classes:
+            self._test_ews(ews_class())