Title: [96263] trunk/Tools
Revision
96263
Author
[email protected]
Date
2011-09-28 14:58:34 -0700 (Wed, 28 Sep 2011)

Log Message

watchlist: Add a way to load the watchlist from config.
https://bugs.webkit.org/show_bug.cgi?id=68991

Reviewed by Eric Seidel.

* Scripts/webkitpy/common/config/watchlist: Added.
* Scripts/webkitpy/common/watchlist/watchlistloader.py: Added.
Support for loading the watch list.
* Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py: Added.
Tests for the loading.
* Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py:
Adjusted to use the common base class.
* Scripts/webkitpy/common/webkitunittest.py: Added.
Made a common base class for functionality used in more than one.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (96262 => 96263)


--- trunk/Tools/ChangeLog	2011-09-28 21:30:04 UTC (rev 96262)
+++ trunk/Tools/ChangeLog	2011-09-28 21:58:34 UTC (rev 96263)
@@ -1,5 +1,22 @@
 2011-09-28  David Levin  <[email protected]>
 
+        watchlist: Add a way to load the watchlist from config.
+        https://bugs.webkit.org/show_bug.cgi?id=68991
+
+        Reviewed by Eric Seidel.
+
+        * Scripts/webkitpy/common/config/watchlist: Added.
+        * Scripts/webkitpy/common/watchlist/watchlistloader.py: Added.
+        Support for loading the watch list.
+        * Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py: Added.
+        Tests for the loading.
+        * Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py:
+        Adjusted to use the common base class.
+        * Scripts/webkitpy/common/webkitunittest.py: Added.
+        Made a common base class for functionality used in more than one.
+
+2011-09-28  David Levin  <[email protected]>
+
         Attempt fix for Leopard python unit test run.
 
         * Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py:

Added: trunk/Tools/Scripts/webkitpy/common/config/watchlist (0 => 96263)


--- trunk/Tools/Scripts/webkitpy/common/config/watchlist	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/config/watchlist	2011-09-28 21:58:34 UTC (rev 96263)
@@ -0,0 +1,10 @@
+{
+    "DEFINITIONS": {
+        "WatchListScript": {
+            "filename": (r"Tools/Scripts/webkitpy/common/watchlist/.*"),
+        },
+    },
+    "CC_RULES": {
+        "WatchListScript": [ "[email protected]", ],
+    },
+}

Added: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader.py (0 => 96263)


--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader.py	2011-09-28 21:58:34 UTC (rev 96263)
@@ -0,0 +1,43 @@
+# Copyright (C) 2011 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.common.watchlist.watchlistparser import WatchListParser
+
+
+class WatchListLoader(object):
+    def __init__(self, filesystem):
+        self._filesystem = filesystem
+
+    def load(self):
+        config_path = self._filesystem.dirname(self._filesystem.path_to_module('webkitpy.common.config'))
+        watch_list_full_path = self._filesystem.join(config_path, 'watchlist')
+        if not self._filesystem.exists(watch_list_full_path):
+            raise Exception('Watch list file (%s) not found.' % watch_list_full_path)
+
+        watch_list_contents = self._filesystem.read_text_file(watch_list_full_path)
+        return WatchListParser().parse(watch_list_contents)
Property changes on: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader.py
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py (0 => 96263)


--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py	2011-09-28 21:58:34 UTC (rev 96263)
@@ -0,0 +1,44 @@
+# Copyright (C) 2011 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.
+
+'''Unit tests for watchlistloader.py.'''
+
+from webkitpy.common import webkitunittest
+from webkitpy.common.system import filesystem_mock
+from webkitpy.common.system import filesystem
+from webkitpy.common.watchlist.watchlistloader import WatchListLoader
+
+
+class WatchListLoaderTest(webkitunittest.TestCase):
+    def test_watch_list_not_found(self):
+        loader = WatchListLoader(filesystem_mock.MockFileSystem())
+        self.assertRaisesRegexp(r'Watch list file \(.*/watchlist\) not found\.', loader.load)
+
+    def test_watch_list_load(self):
+        # Test parsing of the checked-in watch list.
+        WatchListLoader(filesystem.FileSystem()).load()
Property changes on: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py (96262 => 96263)


--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py	2011-09-28 21:30:04 UTC (rev 96262)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py	2011-09-28 21:58:34 UTC (rev 96263)
@@ -28,26 +28,15 @@
 
 '''Unit tests for watchlistparser.py.'''
 
-import re
-import unittest
+from webkitpy.common import webkitunittest
 from webkitpy.common.watchlist.watchlistparser import WatchListParser
 
 
-class WatchListParserTest(unittest.TestCase):
+class WatchListParserTest(webkitunittest.TestCase):
     def setUp(self):
-        # For versions of Python before 2.7.
-        if not 'assertRaisesRegexp' in dir(self):
-            self.assertRaisesRegexp = self._verifyException
+        webkitunittest.TestCase.setUp(self)
         self._watch_list_parser = WatchListParser()
 
-    def _verifyException(self, regex_message, callable, *args):
-        try:
-            callable(*args)
-            self.assertTrue(False, 'No assert raised.')
-        except Exception, exception:
-            self.assertTrue(re.match(regex_message, exception.__str__()),
-                            'Expected regex "%s"\nGot "%s"' % (regex_message, exception.__str__()))
-
     def test_bad_section(self):
         watch_list_with_bad_section = ('{"FOO": {}}')
         self.assertRaisesRegexp('Unknown section "FOO" in watch list.',
@@ -69,8 +58,8 @@
             '     },'
             '}')
 
-        self._verifyException(r'Invalid character "\|" in definition "WatchList1\|A"\.',
-                              self._watch_list_parser.parse, watch_list_with_bad_definition)
+        self.assertRaisesRegexp(r'Invalid character "\|" in definition "WatchList1\|A"\.',
+                                self._watch_list_parser.parse, watch_list_with_bad_definition)
 
     def test_bad_match_type(self):
         watch_list_with_bad_match_type = (
@@ -82,8 +71,8 @@
             '     },'
             '}')
 
-        self._verifyException('Unknown pattern type "nothing_matches_this" in definition "WatchList1".',
-                              self._watch_list_parser.parse, watch_list_with_bad_match_type)
+        self.assertRaisesRegexp('Unknown pattern type "nothing_matches_this" in definition "WatchList1".',
+                                self._watch_list_parser.parse, watch_list_with_bad_match_type)
 
     def test_match_type_typo(self):
         watch_list_with_bad_match_type = (
@@ -95,6 +84,6 @@
             '     },'
             '}')
 
-        self._verifyException(r'Unknown pattern type "iflename" in definition "WatchList1"\.\s*'
-                              + r'Perhaps it should be filename\.',
-                              self._watch_list_parser.parse, watch_list_with_bad_match_type)
+        self.assertRaisesRegexp(r'Unknown pattern type "iflename" in definition "WatchList1"\.\s*'
+                                + r'Perhaps it should be filename\.',
+                                self._watch_list_parser.parse, watch_list_with_bad_match_type)

Added: trunk/Tools/Scripts/webkitpy/common/webkitunittest.py (0 => 96263)


--- trunk/Tools/Scripts/webkitpy/common/webkitunittest.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/webkitunittest.py	2011-09-28 21:58:34 UTC (rev 96263)
@@ -0,0 +1,47 @@
+# Copyright (C) 2011 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.
+
+'''Basic unit test functionality.'''
+
+import re
+import unittest
+
+
+class TestCase(unittest.TestCase):
+    def setUp(self):
+        # For versions of Python before 2.7.
+        if not 'assertRaisesRegexp' in dir(self):
+            self.assertRaisesRegexp = self._assertRaisesRegexp
+
+    def _assertRaisesRegexp(self, regex_message, callable, *args):
+        try:
+            callable(*args)
+            self.assertTrue(False, 'No assert raised.')
+        except Exception, exception:
+            self.assertTrue(re.match(regex_message, exception.__str__()),
+                            'Expected regex "%s"\nGot "%s"' % (regex_message, exception.__str__()))
Property changes on: trunk/Tools/Scripts/webkitpy/common/webkitunittest.py
___________________________________________________________________

Added: svn:eol-style

_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to