Title: [96046] trunk/Tools
- Revision
- 96046
- Author
- le...@chromium.org
- Date
- 2011-09-26 17:03:07 -0700 (Mon, 26 Sep 2011)
Log Message
watchlist: Add parsing for definition section.
https://bugs.webkit.org/show_bug.cgi?id=68850
Reviewed by Adam Barth.
* Scripts/webkitpy/common/watchlist/watchlist.py:
* Scripts/webkitpy/common/watchlist/watchlistparser.py:
* Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py:
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (96045 => 96046)
--- trunk/Tools/ChangeLog 2011-09-26 23:53:42 UTC (rev 96045)
+++ trunk/Tools/ChangeLog 2011-09-27 00:03:07 UTC (rev 96046)
@@ -1,3 +1,14 @@
+2011-09-26 David Levin <le...@chromium.org>
+
+ watchlist: Add parsing for definition section.
+ https://bugs.webkit.org/show_bug.cgi?id=68850
+
+ Reviewed by Adam Barth.
+
+ * Scripts/webkitpy/common/watchlist/watchlist.py:
+ * Scripts/webkitpy/common/watchlist/watchlistparser.py:
+ * Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py:
+
2011-09-26 Simon Fraser <simon.fra...@apple.com>
Fix WebKitTestRunner builds for Cairo, Windows and Qt.
Modified: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlist.py (96045 => 96046)
--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlist.py 2011-09-26 23:53:42 UTC (rev 96045)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlist.py 2011-09-27 00:03:07 UTC (rev 96046)
@@ -29,4 +29,7 @@
class WatchList(object):
def __init__(self):
- pass
+ self._definitions = {}
+
+ def set_definitions(self, definitions):
+ self._definitions = definitions
Modified: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser.py (96045 => 96046)
--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser.py 2011-09-26 23:53:42 UTC (rev 96045)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser.py 2011-09-27 00:03:07 UTC (rev 96046)
@@ -26,25 +26,51 @@
# (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 re
from webkitpy.common.watchlist.watchlist import WatchList
+_DEFINITIONS = 'DEFINITIONS'
+_INVALID_DEFINITION_NAME_REGEX = r'\|'
+
def _eval_watch_list(watch_list_contents):
return eval(watch_list_contents, {'__builtins__': None}, None)
+_DEFINITION_MATCH_PARSER = {}
+
+def _parse_definition_section(definition_section, watch_list):
+ definitions = {}
+ for name in definition_section:
+ invalid_character = re.search(_INVALID_DEFINITION_NAME_REGEX, name)
+ if invalid_character:
+ raise Exception('Invalid character "%s" in definition "%s".' % (invalid_character.group(0), name))
+
+ definition = definition_section[name]
+ definitions[name] = []
+ for pattern_type in definition:
+ pattern_parser = _DEFINITION_MATCH_PARSER.get(pattern_type)
+ if not pattern_parser:
+ raise Exception('Invalid pattern type "%s" in definition "%s".' % (pattern_type, name))
+
+ pattern = pattern_parser(definition[pattern_type])
+ definitions[name].append(pattern)
+ watch_list.set_definitions(definitions)
+
+_SECTION_PARSERS = {_DEFINITIONS: _parse_definition_section, }
+
+
def parse_watch_list(watch_list_contents):
watch_list = WatchList()
# Change the watch list text into a dictionary.
dictionary = _eval_watch_list(watch_list_contents)
- parsers = {}
# Parse the top level sections in the watch list.
for section in dictionary:
- parser = parsers.get(section)
+ parser = _SECTION_PARSERS.get(section)
if not parser:
- raise Exception('Unknown section in watch list: %s' % section)
+ raise Exception('Unknown section "%s" in watch list.' % section)
parser(dictionary[section], watch_list)
return watch_list
Modified: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py (96045 => 96046)
--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py 2011-09-26 23:53:42 UTC (rev 96045)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py 2011-09-27 00:03:07 UTC (rev 96046)
@@ -49,4 +49,28 @@
def test_bad_section(self):
watch_list_with_bad_section = ('{"FOO": {}}')
- self.assertRaisesRegexp('Unknown section in watch list: FOO', parse_watch_list, watch_list_with_bad_section)
+ self.assertRaisesRegexp('Unknown section "FOO" in watch list.', parse_watch_list, watch_list_with_bad_section)
+
+ def test_bad_definition(self):
+ watch_list_with_bad_definition = (
+ '{'
+ ' "DEFINITIONS": {'
+ ' "WatchList1|A": {'
+ ' "filename": r".*\\MyFileName\\.cpp",'
+ ' },'
+ ' },'
+ '}')
+
+ self._verifyException('Invalid character "|" in definition "WatchList1|A".', parse_watch_list, watch_list_with_bad_definition)
+
+ def test_bad_match_type(self):
+ watch_list_with_bad_match_type = (
+ '{'
+ ' "DEFINITIONS": {'
+ ' "WatchList1": {'
+ ' "nothing_matches_this": r".*\\MyFileName\\.cpp",'
+ ' },'
+ ' },'
+ '}')
+
+ self._verifyException('Invalid pattern type "nothing_matches_this" in definition "WatchList1".', parse_watch_list, watch_list_with_bad_match_type)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes