Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py

Issue 17639006: Remove committer list, bugzilla, watchlist code and transitive closure of stuff. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge on top of thakis' change in r153020 Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (C) 2011 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 '''Unit tests for watchlistparser.py.'''
30
31
32 import logging
33 import sys
34
35
36 from webkitpy.common import webkitunittest
37 from webkitpy.common.system.outputcapture import OutputCapture
38 from webkitpy.common.watchlist.watchlistparser import WatchListParser
39
40
41 class WatchListParserTest(webkitunittest.TestCase):
42 def setUp(self):
43 webkitunittest.TestCase.setUp(self)
44 self._watch_list_parser = WatchListParser()
45
46 def test_bad_section(self):
47 watch_list = ('{"FOO": {}}')
48 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
49 expected_logs='Unknown section "FOO" in w atch list.\n')
50
51 def test_section_typo(self):
52 watch_list = ('{"DEFINTIONS": {}}')
53 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
54 expected_logs='Unknown section "DEFINTION S" in watch list.'
55 + '\n\nPerhaps it should be DEFINITIONS.\ n')
56
57 def test_bad_definition(self):
58 watch_list = (
59 '{'
60 ' "DEFINITIONS": {'
61 ' "WatchList1|A": {'
62 ' "filename": r".*\\MyFileName\\.cpp",'
63 ' },'
64 ' },'
65 '}')
66
67 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
68 expected_logs='Invalid character "|" in d efinition "WatchList1|A".\n')
69
70 def test_bad_filename_regex(self):
71 watch_list = (
72 '{'
73 ' "DEFINITIONS": {'
74 ' "WatchList1": {'
75 ' "filename": r"*",'
76 ' "more": r"RefCounted",'
77 ' },'
78 ' },'
79 ' "CC_RULES": {'
80 ' "WatchList1": ["levin@chromium.org"],'
81 ' },'
82 '}')
83
84 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
85 expected_logs='The regex "*" is invalid d ue to "nothing to repeat".\n')
86
87 def test_bad_more_regex(self):
88 watch_list = (
89 '{'
90 ' "DEFINITIONS": {'
91 ' "WatchList1": {'
92 ' "filename": r"aFileName\\.cpp",'
93 ' "more": r"*",'
94 ' },'
95 ' },'
96 ' "CC_RULES": {'
97 ' "WatchList1": ["levin@chromium.org"],'
98 ' },'
99 '}')
100
101 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
102 expected_logs='The regex "*" is invalid d ue to "nothing to repeat".\n')
103
104 def test_bad_match_type(self):
105 watch_list = (
106 '{'
107 ' "DEFINITIONS": {'
108 ' "WatchList1": {'
109 ' "nothing_matches_this": r".*\\MyFileName\\.cpp",'
110 ' "filename": r".*\\MyFileName\\.cpp",'
111 ' },'
112 ' },'
113 ' "CC_RULES": {'
114 ' "WatchList1": ["levin@chromium.org"],'
115 ' },'
116 '}')
117
118 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
119 expected_logs='Unknown pattern type "noth ing_matches_this" in definition "WatchList1".\n')
120
121 def test_match_type_typo(self):
122 watch_list = (
123 '{'
124 ' "DEFINITIONS": {'
125 ' "WatchList1": {'
126 ' "iflename": r".*\\MyFileName\\.cpp",'
127 ' "more": r"RefCounted",'
128 ' },'
129 ' },'
130 ' "CC_RULES": {'
131 ' "WatchList1": ["levin@chromium.org"],'
132 ' },'
133 '}')
134
135 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
136 expected_logs='Unknown pattern type "ifle name" in definition "WatchList1".'
137 + '\n\nPerhaps it should be filename.\n')
138
139 def test_empty_definition(self):
140 watch_list = (
141 '{'
142 ' "DEFINITIONS": {'
143 ' "WatchList1": {'
144 ' },'
145 ' },'
146 ' "CC_RULES": {'
147 ' "WatchList1": ["levin@chromium.org"],'
148 ' },'
149 '}')
150
151 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
152 expected_logs='The definition "WatchList1 " has no patterns, so it should be deleted.\n')
153
154 def test_empty_cc_rule(self):
155 watch_list = (
156 '{'
157 ' "DEFINITIONS": {'
158 ' "WatchList1": {'
159 ' "filename": r".*\\MyFileName\\.cpp",'
160 ' },'
161 ' },'
162 ' "CC_RULES": {'
163 ' "WatchList1": [],'
164 ' },'
165 '}')
166
167 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
168 expected_logs='A rule for definition "Wat chList1" is empty, so it should be deleted.\n'
169 + 'The following definitions are not used and should be removed: WatchList1\n')
170
171 def test_cc_rule_with_invalid_email(self):
172 watch_list = (
173 '{'
174 ' "DEFINITIONS": {'
175 ' "WatchList1": {'
176 ' "filename": r".*\\MyFileName\\.cpp",'
177 ' },'
178 ' },'
179 ' "CC_RULES": {'
180 ' "WatchList1": ["levin+bad+email@chromium.org"],'
181 ' },'
182 '}')
183
184 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
185 expected_logs='The email alias levin+bad+ email@chromium.org which is'
186 + ' in the watchlist is not listed as a c ontributor in committers.py\n')
187
188 def test_cc_rule_with_secondary_email(self):
189 # FIXME: We should provide a mock of CommitterList so that we can test t his on fake data.
190 watch_list = (
191 '{'
192 ' "DEFINITIONS": {'
193 ' "WatchList1": {'
194 ' "filename": r".*\\MyFileName\\.cpp",'
195 ' },'
196 ' },'
197 ' "CC_RULES": {'
198 ' "WatchList1": ["ojan.autocc@gmail.com"],'
199 ' },'
200 '}')
201
202 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
203 expected_logs='')
204
205 def test_empty_message_rule(self):
206 watch_list = (
207 '{'
208 ' "DEFINITIONS": {'
209 ' "WatchList1": {'
210 ' "filename": r".*\\MyFileName\\.cpp",'
211 ' },'
212 ' },'
213 ' "MESSAGE_RULES": {'
214 ' "WatchList1": ['
215 ' ],'
216 ' },'
217 '}')
218
219 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
220 expected_logs='A rule for definition "Wat chList1" is empty, so it should be deleted.\n'
221 + 'The following definitions are not used and should be removed: WatchList1\n')
222
223 def test_unused_defintion(self):
224 watch_list = (
225 '{'
226 ' "DEFINITIONS": {'
227 ' "WatchList1": {'
228 ' "filename": r".*\\MyFileName\\.cpp",'
229 ' },'
230 ' },'
231 '}')
232
233 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
234 expected_logs='The following definitions are not used and should be removed: WatchList1\n')
235
236 def test_cc_rule_with_undefined_defintion(self):
237 watch_list = (
238 '{'
239 ' "CC_RULES": {'
240 ' "WatchList1": ["levin@chromium.org"]'
241 ' },'
242 '}')
243
244 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
245 expected_logs='In section "CC_RULES", the following definitions are not used and should be removed: WatchList1\n')
246
247 def test_message_rule_with_undefined_defintion(self):
248 watch_list = (
249 '{'
250 ' "MESSAGE_RULES": {'
251 ' "WatchList1": ["The message."]'
252 ' },'
253 '}')
254
255 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
256 expected_logs='In section "MESSAGE_RULES" , the following definitions are not used and should be removed: WatchList1\n')
257
258 def test_cc_rule_with_undefined_defintion_with_suggestion(self):
259 watch_list = (
260 '{'
261 ' "DEFINITIONS": {'
262 ' "WatchList1": {'
263 ' "filename": r".*\\MyFileName\\.cpp",'
264 ' },'
265 ' },'
266 ' "CC_RULES": {'
267 ' "WatchList": ["levin@chromium.org"]'
268 ' },'
269 ' "MESSAGE_RULES": {'
270 ' "WatchList1": ["levin@chromium.org"]'
271 ' },'
272 '}')
273
274 OutputCapture().assert_outputs(self, self._watch_list_parser.parse, args =[watch_list],
275 expected_logs='In section "CC_RULES", the following definitions are not used and should be removed: WatchList'
276 + '\n\nPerhaps it should be WatchList1.\n ')
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/common/watchlist/watchlistparser.py ('k') | Tools/Scripts/webkitpy/common/watchlist/watchlistrule.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698