Changeset 126135 in webkit
- Timestamp:
- Aug 20, 2012 10:56:44 PM (12 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r126133 r126135 1 2012-08-20 Ryosuke Niwa <rniwa@webkit.org> 2 3 Cleanup TestExpectationParser.parse 4 https://bugs.webkit.org/show_bug.cgi?id=94545 5 6 Reviewed by Dirk Pranke. 7 8 Refactor TestExpectations to simplify the code. 9 10 * Scripts/webkitpy/layout_tests/models/test_expectations.py: 11 (TestExpectationParser.parse): Merged _tokenize_list. 12 (TestExpectationParser._parse_line): Removed the call to _check_modifiers_against_expectations 13 since the check is now done in _parser_modifiers. 14 (TestExpectationParser._parse_modifiers): Merged _check_modifiers_against_expectations. 15 (TestExpectationParser._tokenize_line): Renamed from _tokenize. 16 (TestExpectationParser._split_space_separated): No longer calls lower() on all modifiers. 17 This is done on a local variable in _parse_modifiers, preserving the original case. 18 (TestExpectations.remove_rebaselined_tests.without_rebaseline_modifier): Check the existence 19 of 'rebaseline' against parsed modifiers. 20 * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py: 21 (TestExpectationParserTests._tokenize): 22 (TestExpectationParserTests.test_tokenize_valid_with_comment): Preserves case. 23 (TestExpectationParserTests.test_tokenize_valid_with_multiple_modifiers): Ditto. 24 (TestExpectationSerializerTests._tokenize): 25 (TestExpectationSerializerTests.assert_list_round_trip): Call parse since _tokenize_list has 26 been merged into parse. 27 * Scripts/webkitpy/tool/commands/queries_unittest.py: 28 (PrintExpectationsTest.test_csv): Preserves the case. 29 1 30 2012-08-20 Gustavo Noronha Silva <gns@gnome.org> 2 31 -
trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
r125115 r126135 207 207 208 208 def parse(self, filename, expectations_string): 209 expectations = TestExpectationParser._tokenize_list(filename, expectations_string) 210 for expectation_line in expectations: 211 self._parse_line(expectation_line) 212 return expectations 209 expectation_lines = [] 210 line_number = 0 211 for line in expectations_string.split("\n"): 212 line_number += 1 213 test_expectation = self._tokenize_line(filename, line, line_number) 214 self._parse_line(test_expectation) 215 expectation_lines.append(test_expectation) 216 return expectation_lines 213 217 214 218 def expectation_for_skipped_test(self, test_name): … … 232 236 return 233 237 234 self._check_modifiers_against_expectations(expectation_line)235 236 238 expectation_line.is_file = self._port.test_isfile(expectation_line.name) 237 239 if not expectation_line.is_file and self._check_path_does_not_exist(expectation_line): … … 252 254 has_bugid = False 253 255 parsed_specifiers = set() 254 for modifier in expectation_line.modifiers: 256 257 modifiers = [modifier.lower() for modifier in expectation_line.modifiers] 258 expectations = [expectation.lower() for expectation in expectation_line.expectations] 259 260 if self.SLOW_MODIFIER in modifiers and self.TIMEOUT_EXPECTATION in expectations: 261 expectation_line.warnings.append('A test can not be both SLOW and TIMEOUT. If it times out indefinitely, then it should be just TIMEOUT.') 262 263 for modifier in modifiers: 255 264 if modifier in TestExpectations.MODIFIERS: 256 265 expectation_line.parsed_modifiers.append(modifier) … … 269 278 expectation_line.warnings.append('Test lacks BUG modifier.') 270 279 271 if self._allow_rebaseline_modifier and self.REBASELINE_MODIFIER in expectation_line.modifiers:280 if self._allow_rebaseline_modifier and self.REBASELINE_MODIFIER in modifiers: 272 281 expectation_line.warnings.append('REBASELINE should only be used for running rebaseline.py. Cannot be checked in.') 273 282 … … 283 292 result.add(expectation) 284 293 expectation_line.parsed_expectations = result 285 286 def _check_modifiers_against_expectations(self, expectation_line):287 if self.SLOW_MODIFIER in expectation_line.modifiers and self.TIMEOUT_EXPECTATION in expectation_line.expectations:288 expectation_line.warnings.append('A test can not be both SLOW and TIMEOUT. If it times out indefinitely, then it should be just TIMEOUT.')289 294 290 295 def _check_path_does_not_exist(self, expectation_line): … … 325 330 326 331 @classmethod 327 def _tokenize (cls, filename, expectation_string, line_number):332 def _tokenize_line(cls, filename, expectation_string, line_number): 328 333 """Tokenizes a line from TestExpectations and returns an unparsed TestExpectationLine instance. 329 334 … … 365 370 366 371 @classmethod 367 def _tokenize_list(cls, filename, expectations_string):368 """Returns a list of TestExpectationLines, one for each line in expectations_string."""369 expectation_lines = []370 line_number = 0371 for line in expectations_string.split("\n"):372 line_number += 1373 expectation_lines.append(cls._tokenize(filename, line, line_number))374 return expectation_lines375 376 @classmethod377 372 def _split_space_separated(cls, space_separated_string): 378 373 """Splits a space-separated string into an array.""" 379 # FIXME: Lower-casing is necessary to support legacy code. Need to eliminate. 380 return [part.strip().lower() for part in space_separated_string.strip().split(' ')] 374 return [part.strip() for part in space_separated_string.strip().split(' ')] 381 375 382 376 … … 858 852 return not (not expectation.is_invalid() and 859 853 expectation.name in except_these_tests and 860 "rebaseline" in expectation.modifiers and854 'rebaseline' in expectation.parsed_modifiers and 861 855 filename == expectation.filename) 862 856 -
trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py
r125115 r126135 489 489 class TestExpectationParserTests(unittest.TestCase): 490 490 def _tokenize(self, line): 491 return TestExpectationParser._tokenize ('path', line, 0)491 return TestExpectationParser._tokenize_line('path', line, 0) 492 492 493 493 def test_tokenize_blank(self): … … 530 530 expectation = self._tokenize('FOO : bar = BAZ //Qux.') 531 531 self.assertEqual(expectation.comment, 'Qux.') 532 self.assertEqual(str(expectation.modifiers), '[\'foo\']')533 self.assertEqual(str(expectation.expectations), '[\'baz\']')532 self.assertEqual(str(expectation.modifiers), "['FOO']") 533 self.assertEqual(str(expectation.expectations), "['BAZ']") 534 534 self.assertEqual(len(expectation.warnings), 0) 535 535 … … 537 537 expectation = self._tokenize('FOO1 FOO2 : bar = BAZ //Qux.') 538 538 self.assertEqual(expectation.comment, 'Qux.') 539 self.assertEqual(str(expectation.modifiers), '[\'foo1\', \'foo2\']')540 self.assertEqual(str(expectation.expectations), '[\'baz\']')539 self.assertEqual(str(expectation.modifiers), "['FOO1', 'FOO2']") 540 self.assertEqual(str(expectation.expectations), "['BAZ']") 541 541 self.assertEqual(len(expectation.warnings), 0) 542 542 … … 561 561 562 562 def _tokenize(self, line): 563 return TestExpectationParser._tokenize ('path', line, 0)563 return TestExpectationParser._tokenize_line('path', line, 0) 564 564 565 565 def assert_round_trip(self, in_string, expected_string=None): … … 570 570 571 571 def assert_list_round_trip(self, in_string, expected_string=None): 572 expectations = TestExpectationParser._tokenize_list('path', in_string) 572 host = MockHost() 573 parser = TestExpectationParser(host.port_factory.get('test-win-xp', None), [], allow_rebaseline_modifier=False) 574 expectations = parser.parse('path', in_string) 573 575 if expected_string is None: 574 576 expected_string = in_string -
trunk/Tools/Scripts/webkitpy/tool/commands/queries_unittest.py
r121269 r126135 218 218 def test_csv(self): 219 219 self.run_test(['failures/expected/text.html', 'failures/expected/image.html'], 220 ('test-win-xp,failures/expected/image.html, wontfix,image\n'221 'test-win-xp,failures/expected/text.html, wontfix,text\n'),220 ('test-win-xp,failures/expected/image.html,WONTFIX,IMAGE\n' 221 'test-win-xp,failures/expected/text.html,WONTFIX,TEXT\n'), 222 222 csv=True) 223 223
Note: See TracChangeset
for help on using the changeset viewer.