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

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py

Issue 20830003: Get rid of the distinction between modifiers and expectations. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: clean up a couple things Created 7 years, 5 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
1 # Copyright (C) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 def parse_exp(self, expectations, overrides=None, is_lint_mode=False): 79 def parse_exp(self, expectations, overrides=None, is_lint_mode=False):
80 expectations_dict = OrderedDict() 80 expectations_dict = OrderedDict()
81 expectations_dict['expectations'] = expectations 81 expectations_dict['expectations'] = expectations
82 if overrides: 82 if overrides:
83 expectations_dict['overrides'] = overrides 83 expectations_dict['overrides'] = overrides
84 self._port.expectations_dict = lambda: expectations_dict 84 self._port.expectations_dict = lambda: expectations_dict
85 expectations_to_lint = expectations_dict if is_lint_mode else None 85 expectations_to_lint = expectations_dict if is_lint_mode else None
86 self._exp = TestExpectations(self._port, self.get_basic_tests(), expecta tions_dict=expectations_to_lint, is_lint_mode=is_lint_mode) 86 self._exp = TestExpectations(self._port, self.get_basic_tests(), expecta tions_dict=expectations_to_lint, is_lint_mode=is_lint_mode)
87 87
88 def assert_exp_list(self, test, results):
89 self.assertEqual(self._exp.get_expectations(self.get_test(test)), set(re sults))
90
88 def assert_exp(self, test, result): 91 def assert_exp(self, test, result):
89 self.assertEqual(self._exp.get_expectations(self.get_test(test)), 92 self.assert_exp_list(test, [result])
90 set([result]))
91 93
92 def assert_bad_expectations(self, expectations, overrides=None): 94 def assert_bad_expectations(self, expectations, overrides=None):
93 self.assertRaises(ParseError, self.parse_exp, expectations, is_lint_mode =True, overrides=overrides) 95 self.assertRaises(ParseError, self.parse_exp, expectations, is_lint_mode =True, overrides=overrides)
94 96
95 97
96 class BasicTests(Base): 98 class BasicTests(Base):
97 def test_basic(self): 99 def test_basic(self):
98 self.parse_exp(self.get_basic_expectations()) 100 self.parse_exp(self.get_basic_expectations())
99 self.assert_exp('failures/expected/text.html', FAIL) 101 self.assert_exp('failures/expected/text.html', FAIL)
100 self.assert_exp('failures/expected/image_checksum.html', PASS) 102 self.assert_exp_list('failures/expected/image_checksum.html', [WONTFIX, SKIP])
101 self.assert_exp('passes/text.html', PASS) 103 self.assert_exp('passes/text.html', PASS)
102 self.assert_exp('failures/expected/image.html', PASS) 104 self.assert_exp('failures/expected/image.html', PASS)
103 105
104 106
105 class MiscTests(Base): 107 class MiscTests(Base):
106 def test_multiple_results(self): 108 def test_multiple_results(self):
107 self.parse_exp('Bug(x) failures/expected/text.html [ Crash Failure ]') 109 self.parse_exp('Bug(x) failures/expected/text.html [ Crash Failure ]')
108 self.assertEqual(self._exp.get_expectations( 110 self.assertEqual(self._exp.get_expectations(
109 self.get_test('failures/expected/text.html')), 111 self.get_test('failures/expected/text.html')),
110 set([FAIL, CRASH])) 112 set([FAIL, CRASH]))
111 113
112 def test_result_was_expected(self): 114 def test_result_was_expected(self):
113 # test basics 115 # test basics
114 self.assertEqual(TestExpectations.result_was_expected(PASS, set([PASS]), test_needs_rebaselining=False), True) 116 self.assertEqual(TestExpectations.result_was_expected(PASS, set([PASS]), test_needs_rebaselining=False), True)
115 self.assertEqual(TestExpectations.result_was_expected(FAIL, set([PASS]), test_needs_rebaselining=False), False) 117 self.assertEqual(TestExpectations.result_was_expected(FAIL, set([PASS]), test_needs_rebaselining=False), False)
116 118
117 # test handling of SKIPped tests and results 119 # test handling of SKIPped tests and results
118 self.assertEqual(TestExpectations.result_was_expected(SKIP, set([CRASH]) , test_needs_rebaselining=False), True) 120 self.assertEqual(TestExpectations.result_was_expected(SKIP, set([CRASH]) , test_needs_rebaselining=False), True)
119 121
120 # test handling of MISSING results and the REBASELINE modifier 122 # test handling of MISSING results and the REBASELINE specifier
121 self.assertEqual(TestExpectations.result_was_expected(MISSING, set([PASS ]), test_needs_rebaselining=True), True) 123 self.assertEqual(TestExpectations.result_was_expected(MISSING, set([PASS ]), test_needs_rebaselining=True), True)
122 self.assertEqual(TestExpectations.result_was_expected(MISSING, set([PASS ]), test_needs_rebaselining=False), False) 124 self.assertEqual(TestExpectations.result_was_expected(MISSING, set([PASS ]), test_needs_rebaselining=False), False)
123 125
124 self.assertTrue(TestExpectations.result_was_expected(PASS, set([NEEDS_RE BASELINE]), test_needs_rebaselining=False)) 126 self.assertTrue(TestExpectations.result_was_expected(PASS, set([NEEDS_RE BASELINE]), test_needs_rebaselining=False))
125 self.assertTrue(TestExpectations.result_was_expected(MISSING, set([NEEDS _REBASELINE]), test_needs_rebaselining=False)) 127 self.assertTrue(TestExpectations.result_was_expected(MISSING, set([NEEDS _REBASELINE]), test_needs_rebaselining=False))
126 self.assertTrue(TestExpectations.result_was_expected(TEXT, set([NEEDS_RE BASELINE]), test_needs_rebaselining=False)) 128 self.assertTrue(TestExpectations.result_was_expected(TEXT, set([NEEDS_RE BASELINE]), test_needs_rebaselining=False))
127 self.assertTrue(TestExpectations.result_was_expected(IMAGE, set([NEEDS_R EBASELINE]), test_needs_rebaselining=False)) 129 self.assertTrue(TestExpectations.result_was_expected(IMAGE, set([NEEDS_R EBASELINE]), test_needs_rebaselining=False))
128 self.assertTrue(TestExpectations.result_was_expected(IMAGE_PLUS_TEXT, se t([NEEDS_REBASELINE]), test_needs_rebaselining=False)) 130 self.assertTrue(TestExpectations.result_was_expected(IMAGE_PLUS_TEXT, se t([NEEDS_REBASELINE]), test_needs_rebaselining=False))
129 self.assertTrue(TestExpectations.result_was_expected(AUDIO, set([NEEDS_R EBASELINE]), test_needs_rebaselining=False)) 131 self.assertTrue(TestExpectations.result_was_expected(AUDIO, set([NEEDS_R EBASELINE]), test_needs_rebaselining=False))
130 self.assertFalse(TestExpectations.result_was_expected(TIMEOUT, set([NEED S_REBASELINE]), test_needs_rebaselining=False)) 132 self.assertFalse(TestExpectations.result_was_expected(TIMEOUT, set([NEED S_REBASELINE]), test_needs_rebaselining=False))
(...skipping 15 matching lines...) Expand all
146 def test_category_expectations(self): 148 def test_category_expectations(self):
147 # This test checks unknown tests are not present in the 149 # This test checks unknown tests are not present in the
148 # expectations and that known test part of a test category is 150 # expectations and that known test part of a test category is
149 # present in the expectations. 151 # present in the expectations.
150 exp_str = 'Bug(x) failures/expected [ WontFix ]' 152 exp_str = 'Bug(x) failures/expected [ WontFix ]'
151 self.parse_exp(exp_str) 153 self.parse_exp(exp_str)
152 test_name = 'failures/expected/unknown-test.html' 154 test_name = 'failures/expected/unknown-test.html'
153 unknown_test = self.get_test(test_name) 155 unknown_test = self.get_test(test_name)
154 self.assertRaises(KeyError, self._exp.get_expectations, 156 self.assertRaises(KeyError, self._exp.get_expectations,
155 unknown_test) 157 unknown_test)
156 self.assert_exp('failures/expected/crash.html', PASS) 158 self.assert_exp_list('failures/expected/crash.html', [WONTFIX, SKIP])
157
158 def test_get_modifiers(self):
159 self.parse_exp(self.get_basic_expectations())
160 self.assertEqual(self._exp.get_modifiers(
161 self.get_test('passes/text.html')), [])
162 159
163 def test_get_expectations_string(self): 160 def test_get_expectations_string(self):
164 self.parse_exp(self.get_basic_expectations()) 161 self.parse_exp(self.get_basic_expectations())
165 self.assertEqual(self._exp.get_expectations_string( 162 self.assertEqual(self._exp.get_expectations_string(
166 self.get_test('failures/expected/text.html')), 163 self.get_test('failures/expected/text.html')),
167 'FAIL') 164 'FAIL')
168 165
169 def test_expectation_to_string(self): 166 def test_expectation_to_string(self):
170 # Normal cases are handled by other tests. 167 # Normal cases are handled by other tests.
171 self.parse_exp(self.get_basic_expectations()) 168 self.parse_exp(self.get_basic_expectations())
(...skipping 11 matching lines...) Expand all
183 def test_parse_warning(self): 180 def test_parse_warning(self):
184 try: 181 try:
185 filesystem = self._port.host.filesystem 182 filesystem = self._port.host.filesystem
186 filesystem.write_text_file(filesystem.join(self._port.layout_tests_d ir(), 'disabled-test.html-disabled'), 'content') 183 filesystem.write_text_file(filesystem.join(self._port.layout_tests_d ir(), 'disabled-test.html-disabled'), 'content')
187 self.get_test('disabled-test.html-disabled'), 184 self.get_test('disabled-test.html-disabled'),
188 self.parse_exp("[ FOO ] failures/expected/text.html [ Failure ]\n" 185 self.parse_exp("[ FOO ] failures/expected/text.html [ Failure ]\n"
189 "Bug(rniwa) non-existent-test.html [ Failure ]\n" 186 "Bug(rniwa) non-existent-test.html [ Failure ]\n"
190 "Bug(rniwa) disabled-test.html-disabled [ ImageOnlyFailure ]", i s_lint_mode=True) 187 "Bug(rniwa) disabled-test.html-disabled [ ImageOnlyFailure ]", i s_lint_mode=True)
191 self.assertFalse(True, "ParseError wasn't raised") 188 self.assertFalse(True, "ParseError wasn't raised")
192 except ParseError, e: 189 except ParseError, e:
193 warnings = ("expectations:1 Unrecognized modifier 'foo' failures/exp ected/text.html\n" 190 warnings = ("expectations:1 Unrecognized specifier 'foo' failures/ex pected/text.html\n"
194 "expectations:2 Path does not exist. non-existent-test.h tml") 191 "expectations:2 Path does not exist. non-existent-test.h tml")
195 self.assertEqual(str(e), warnings) 192 self.assertEqual(str(e), warnings)
196 193
197 def test_parse_warnings_are_logged_if_not_in_lint_mode(self): 194 def test_parse_warnings_are_logged_if_not_in_lint_mode(self):
198 oc = OutputCapture() 195 oc = OutputCapture()
199 try: 196 try:
200 oc.capture_output() 197 oc.capture_output()
201 self.parse_exp('-- this should be a syntax error', is_lint_mode=Fals e) 198 self.parse_exp('-- this should be a syntax error', is_lint_mode=Fals e)
202 finally: 199 finally:
203 _, _, logs = oc.restore_output() 200 _, _, logs = oc.restore_output()
(...skipping 30 matching lines...) Expand all
234 def test_pixel_tests_flag(self): 231 def test_pixel_tests_flag(self):
235 def match(test, result, pixel_tests_enabled): 232 def match(test, result, pixel_tests_enabled):
236 return self._exp.matches_an_expected_result( 233 return self._exp.matches_an_expected_result(
237 self.get_test(test), result, pixel_tests_enabled) 234 self.get_test(test), result, pixel_tests_enabled)
238 235
239 self.parse_exp(self.get_basic_expectations()) 236 self.parse_exp(self.get_basic_expectations())
240 self.assertTrue(match('failures/expected/text.html', FAIL, True)) 237 self.assertTrue(match('failures/expected/text.html', FAIL, True))
241 self.assertTrue(match('failures/expected/text.html', FAIL, False)) 238 self.assertTrue(match('failures/expected/text.html', FAIL, False))
242 self.assertFalse(match('failures/expected/text.html', CRASH, True)) 239 self.assertFalse(match('failures/expected/text.html', CRASH, True))
243 self.assertFalse(match('failures/expected/text.html', CRASH, False)) 240 self.assertFalse(match('failures/expected/text.html', CRASH, False))
244 self.assertTrue(match('failures/expected/image_checksum.html', PASS, 241 self.assertTrue(match('failures/expected/image_checksum.html', PASS, Tru e))
245 True)) 242 self.assertTrue(match('failures/expected/image_checksum.html', PASS, Fal se))
246 self.assertTrue(match('failures/expected/image_checksum.html', PASS,
247 False))
248 self.assertTrue(match('failures/expected/crash.html', PASS, False)) 243 self.assertTrue(match('failures/expected/crash.html', PASS, False))
249 self.assertTrue(match('failures/expected/needsrebaseline.html', TEXT, Tr ue)) 244 self.assertTrue(match('failures/expected/needsrebaseline.html', TEXT, Tr ue))
250 self.assertFalse(match('failures/expected/needsrebaseline.html', CRASH, True)) 245 self.assertFalse(match('failures/expected/needsrebaseline.html', CRASH, True))
251 self.assertTrue(match('failures/expected/needsmanualrebaseline.html', TE XT, True)) 246 self.assertTrue(match('failures/expected/needsmanualrebaseline.html', TE XT, True))
252 self.assertFalse(match('failures/expected/needsmanualrebaseline.html', C RASH, True)) 247 self.assertFalse(match('failures/expected/needsmanualrebaseline.html', C RASH, True))
253 self.assertTrue(match('passes/text.html', PASS, False)) 248 self.assertTrue(match('passes/text.html', PASS, False))
254 249
255 def test_more_specific_override_resets_skip(self): 250 def test_more_specific_override_resets_skip(self):
256 self.parse_exp("Bug(x) failures/expected [ Skip ]\n" 251 self.parse_exp("Bug(x) failures/expected [ Skip ]\n"
257 "Bug(x) failures/expected/text.html [ ImageOnlyFailure ]\ n") 252 "Bug(x) failures/expected/text.html [ ImageOnlyFailure ]\ n")
258 self.assert_exp('failures/expected/text.html', IMAGE) 253 self.assert_exp('failures/expected/text.html', IMAGE)
259 self.assertFalse(self._port._filesystem.join(self._port.layout_tests_dir (), 254 self.assertFalse(self._port._filesystem.join(self._port.layout_tests_dir (),
260 'failures/expected/text.htm l') in 255 'failures/expected/text.htm l') in
261 self._exp.get_tests_with_result_type(SKIP)) 256 self._exp.get_tests_with_result_type(SKIP))
262 257
263 def test_bot_test_expectations(self): 258 def test_bot_test_expectations(self):
264 test_name = 'failures/expected/text.html' 259 test_name = 'failures/expected/text.html'
265 260
266 expectations_dict = OrderedDict() 261 expectations_dict = OrderedDict()
267 expectations_dict['expectations'] = "Bug(x) %s [ ImageOnlyFailure ]\n" % test_name 262 expectations_dict['expectations'] = "Bug(x) %s [ ImageOnlyFailure ]\n" % test_name
268 self._port.expectations_dict = lambda: expectations_dict 263 self._port.expectations_dict = lambda: expectations_dict
269 264
270 expectations = TestExpectations(self._port, self.get_basic_tests()) 265 expectations = TestExpectations(self._port, self.get_basic_tests())
271 self.assertEqual(expectations.get_expectations(self.get_test(test_name)) , set([IMAGE])) 266 self.assertEqual(expectations.get_expectations(self.get_test(test_name)) , set([IMAGE]))
272 self.assertEqual(expectations.get_modifiers(self.get_test(test_name)), [ ])
273 267
274 def bot_expectations(): 268 def bot_expectations():
275 return {test_name: ['PASS', 'IMAGE']} 269 return {test_name: ['PASS', 'IMAGE']}
276 self._port.bot_expectations = bot_expectations 270 self._port.bot_expectations = bot_expectations
277 self._port._options.ignore_flaky_tests = 'very-flaky' 271 self._port._options.ignore_flaky_tests = 'very-flaky'
278 272
279 expectations = TestExpectations(self._port, self.get_basic_tests()) 273 expectations = TestExpectations(self._port, self.get_basic_tests())
280 self.assertEqual(expectations.get_expectations(self.get_test(test_name)) , set([PASS, IMAGE])) 274 self.assertEqual(expectations.get_expectations(self.get_test(test_name)) , set([PASS, IMAGE]))
281 275
282 # The following line tests the actual behavior, which is not necessarily a usefull behavior.
283 # Existing modifiers from a test expectation file are overridden by the bot expectations.
284 self.assertEqual(expectations.get_modifiers(self.get_test(test_name)), [ ])
285
286 def test_bot_test_expectations_merge(self): 276 def test_bot_test_expectations_merge(self):
287 """Test that expectations are merged rather than overridden when using f laky option 'unexpected'.""" 277 """Test that expectations are merged rather than overridden when using f laky option 'unexpected'."""
288 test_name1 = 'failures/expected/text.html' 278 test_name1 = 'failures/expected/text.html'
289 test_name2 = 'passes/text.html' 279 test_name2 = 'passes/text.html'
290 280
291 expectations_dict = OrderedDict() 281 expectations_dict = OrderedDict()
292 expectations_dict['expectations'] = "Bug(x) %s [ ImageOnlyFailure ]\nBug (x) %s [ Slow ]\n" % (test_name1, test_name2) 282 expectations_dict['expectations'] = "Bug(x) %s [ ImageOnlyFailure ]\nBug (x) %s [ Slow ]\n" % (test_name1, test_name2)
293 self._port.expectations_dict = lambda: expectations_dict 283 self._port.expectations_dict = lambda: expectations_dict
294 284
295 expectations = TestExpectations(self._port, self.get_basic_tests()) 285 expectations = TestExpectations(self._port, self.get_basic_tests())
296 self.assertEqual(expectations.get_expectations(self.get_test(test_name1) ), set([IMAGE])) 286 self.assertEqual(expectations.get_expectations(self.get_test(test_name1) ), set([IMAGE]))
297 self.assertEqual(set(expectations.get_modifiers(self.get_test(test_name2 ))), set(['SLOW'])) 287 self.assertEqual(expectations.get_expectations(self.get_test(test_name2) ), set([SLOW]))
298 288
299 def bot_expectations(): 289 def bot_expectations():
300 return {test_name1: ['PASS', 'TIMEOUT'], test_name2: ['CRASH']} 290 return {test_name1: ['PASS', 'TIMEOUT'], test_name2: ['CRASH']}
301 self._port.bot_expectations = bot_expectations 291 self._port.bot_expectations = bot_expectations
302 self._port._options.ignore_flaky_tests = 'unexpected' 292 self._port._options.ignore_flaky_tests = 'unexpected'
303 293
304 expectations = TestExpectations(self._port, self.get_basic_tests()) 294 expectations = TestExpectations(self._port, self.get_basic_tests())
305 self.assertEqual(expectations.get_expectations(self.get_test(test_name1) ), set([PASS, IMAGE, TIMEOUT])) 295 self.assertEqual(expectations.get_expectations(self.get_test(test_name1) ), set([PASS, IMAGE, TIMEOUT]))
306 self.assertEqual(expectations.get_expectations(self.get_test(test_name2) ), set([PASS, CRASH])) 296 self.assertEqual(expectations.get_expectations(self.get_test(test_name2) ), set([CRASH, SLOW]))
307 self.assertEqual(set(expectations.get_modifiers(self.get_test(test_name2 ))), set(['SLOW']))
308 297
309 class SkippedTests(Base): 298 class SkippedTests(Base):
310 def check(self, expectations, overrides, skips, lint=False): 299 def check(self, expectations, overrides, skips, lint=False):
311 port = MockHost().port_factory.get('test-win-xp') 300 port = MockHost().port_factory.get('test-win-xp')
312 port._filesystem.write_text_file(port._filesystem.join(port.layout_tests _dir(), 'failures/expected/text.html'), 'foo') 301 port._filesystem.write_text_file(port._filesystem.join(port.layout_tests _dir(), 'failures/expected/text.html'), 'foo')
313 expectations_dict = OrderedDict() 302 expectations_dict = OrderedDict()
314 expectations_dict['expectations'] = expectations 303 expectations_dict['expectations'] = expectations
315 if overrides: 304 if overrides:
316 expectations_dict['overrides'] = overrides 305 expectations_dict['overrides'] = overrides
317 port.expectations_dict = lambda: expectations_dict 306 port.expectations_dict = lambda: expectations_dict
318 port.skipped_layout_tests = lambda tests: set(skips) 307 port.skipped_layout_tests = lambda tests: set(skips)
319 expectations_to_lint = expectations_dict if lint else None 308 expectations_to_lint = expectations_dict if lint else None
320 exp = TestExpectations(port, ['failures/expected/text.html'], expectatio ns_dict=expectations_to_lint, is_lint_mode=lint) 309 exp = TestExpectations(port, ['failures/expected/text.html'], expectatio ns_dict=expectations_to_lint, is_lint_mode=lint)
321 310 self.assertEqual(exp.get_expectations('failures/expected/text.html'), se t([WONTFIX, SKIP]))
322 # Check that the expectation is for SKIP : ... [ Pass ]
323 self.assertEqual(exp.get_modifiers('failures/expected/text.html'),
324 [TestExpectationParser.SKIP_MODIFIER, TestExpectationP arser.WONTFIX_MODIFIER])
325 self.assertEqual(exp.get_expectations('failures/expected/text.html'), se t([PASS]))
326 311
327 def test_skipped_tests_work(self): 312 def test_skipped_tests_work(self):
328 self.check(expectations='', overrides=None, skips=['failures/expected/te xt.html']) 313 self.check(expectations='', overrides=None, skips=['failures/expected/te xt.html'])
329 314
330 def test_duplicate_skipped_test_fails_lint(self): 315 def test_duplicate_skipped_test_fails_lint(self):
331 self.assertRaises(ParseError, self.check, expectations='Bug(x) failures/ expected/text.html [ Failure ]\n', overrides=None, skips=['failures/expected/tex t.html'], lint=True) 316 self.assertRaises(ParseError, self.check, expectations='Bug(x) failures/ expected/text.html [ Failure ]\n', overrides=None, skips=['failures/expected/tex t.html'], lint=True)
332 317
333 def test_skipped_file_overrides_expectations(self): 318 def test_skipped_file_overrides_expectations(self):
334 self.check(expectations='Bug(x) failures/expected/text.html [ Failure ]\ n', overrides=None, 319 self.check(expectations='Bug(x) failures/expected/text.html [ Failure ]\ n', overrides=None,
335 skips=['failures/expected/text.html']) 320 skips=['failures/expected/text.html'])
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 352
368 class ExpectationSyntaxTests(Base): 353 class ExpectationSyntaxTests(Base):
369 def test_unrecognized_expectation(self): 354 def test_unrecognized_expectation(self):
370 self.assert_bad_expectations('Bug(test) failures/expected/text.html [ Un known ]') 355 self.assert_bad_expectations('Bug(test) failures/expected/text.html [ Un known ]')
371 356
372 def test_macro(self): 357 def test_macro(self):
373 exp_str = 'Bug(test) [ Win ] failures/expected/text.html [ Failure ]' 358 exp_str = 'Bug(test) [ Win ] failures/expected/text.html [ Failure ]'
374 self.parse_exp(exp_str) 359 self.parse_exp(exp_str)
375 self.assert_exp('failures/expected/text.html', FAIL) 360 self.assert_exp('failures/expected/text.html', FAIL)
376 361
377 def assert_tokenize_exp(self, line, bugs=None, modifiers=None, expectations= None, warnings=None, comment=None, name='foo.html'): 362 def assert_tokenize_exp(self, line, bugs=None, specifiers=None, expectations =None, warnings=None, comment=None, name='foo.html'):
378 bugs = bugs or [] 363 bugs = bugs or []
379 modifiers = modifiers or [] 364 specifiers = specifiers or []
380 expectations = expectations or [] 365 expectations = expectations or []
381 warnings = warnings or [] 366 warnings = warnings or []
382 filename = 'TestExpectations' 367 filename = 'TestExpectations'
383 line_number = '1' 368 line_number = '1'
384 expectation_line = TestExpectationParser._tokenize_line(filename, line, line_number) 369 expectation_line = TestExpectationParser._tokenize_line(filename, line, line_number)
385 self.assertEqual(expectation_line.warnings, warnings) 370 self.assertEqual(expectation_line.warnings, warnings)
386 self.assertEqual(expectation_line.name, name) 371 self.assertEqual(expectation_line.name, name)
387 self.assertEqual(expectation_line.filename, filename) 372 self.assertEqual(expectation_line.filename, filename)
388 self.assertEqual(expectation_line.line_numbers, line_number) 373 self.assertEqual(expectation_line.line_numbers, line_number)
389 if not warnings: 374 if not warnings:
390 self.assertEqual(expectation_line.modifiers, modifiers) 375 self.assertEqual(expectation_line.specifiers, specifiers)
391 self.assertEqual(expectation_line.expectations, expectations) 376 self.assertEqual(expectation_line.expectations, expectations)
392 377
393 def test_comments(self): 378 def test_comments(self):
394 self.assert_tokenize_exp("# comment", name=None, comment="# comment") 379 self.assert_tokenize_exp("# comment", name=None, comment="# comment")
395 self.assert_tokenize_exp("foo.html [ Pass ] # comment", comment="# comme nt", expectations=['PASS'], modifiers=[]) 380 self.assert_tokenize_exp("foo.html [ Pass ] # comment", comment="# comme nt", expectations=['PASS'], specifiers=[])
396 381
397 def test_config_modifiers(self): 382 def test_config_specifiers(self):
398 self.assert_tokenize_exp('[ Mac ] foo.html [ Failure ] ', modifiers=['MA C'], expectations=['FAIL']) 383 self.assert_tokenize_exp('[ Mac ] foo.html [ Failure ] ', specifiers=['M AC'], expectations=['FAIL'])
399 384
400 def test_unknown_config(self): 385 def test_unknown_config(self):
401 self.assert_tokenize_exp('[ Foo ] foo.html [ Pass ]', modifiers=['Foo'], expectations=['PASS']) 386 self.assert_tokenize_exp('[ Foo ] foo.html [ Pass ]', specifiers=['Foo'] , expectations=['PASS'])
402 387
403 def test_unknown_expectation(self): 388 def test_unknown_expectation(self):
404 self.assert_tokenize_exp('foo.html [ Audio ]', warnings=['Unrecognized e xpectation "Audio"']) 389 self.assert_tokenize_exp('foo.html [ Audio ]', warnings=['Unrecognized e xpectation "Audio"'])
405 390
406 def test_skip(self): 391 def test_skip(self):
407 self.assert_tokenize_exp('foo.html [ Skip ]', modifiers=['SKIP'], expect ations=['PASS']) 392 self.assert_tokenize_exp('foo.html [ Skip ]', specifiers=[], expectation s=['SKIP'])
408 393
409 def test_slow(self): 394 def test_slow(self):
410 self.assert_tokenize_exp('foo.html [ Slow ]', modifiers=['SLOW'], expect ations=['PASS']) 395 self.assert_tokenize_exp('foo.html [ Slow ]', specifiers=[], expectation s=['SLOW'])
411 396
412 def test_wontfix(self): 397 def test_wontfix(self):
413 self.assert_tokenize_exp('foo.html [ WontFix ]', modifiers=['WONTFIX', ' SKIP'], expectations=['PASS']) 398 self.assert_tokenize_exp('foo.html [ WontFix ]', specifiers=[], expectat ions=['WONTFIX', 'SKIP'])
414 self.assert_tokenize_exp('foo.html [ WontFix ImageOnlyFailure ]', modifi ers=['WONTFIX'], expectations=['IMAGE']) 399 self.assert_tokenize_exp('foo.html [ WontFix ImageOnlyFailure ]', specif iers=[], expectations=['WONTFIX', 'SKIP'],
415 self.assert_tokenize_exp('foo.html [ WontFix Pass Failure ]', modifiers= ['WONTFIX'], expectations=['PASS', 'FAIL']) 400 warnings=['A test marked Skip or WontFix must not have other expecta tions.'])
416 401
417 def test_blank_line(self): 402 def test_blank_line(self):
418 self.assert_tokenize_exp('', name=None) 403 self.assert_tokenize_exp('', name=None)
419 404
420 def test_warnings(self): 405 def test_warnings(self):
421 self.assert_tokenize_exp('[ Mac ]', warnings=['Did not find a test name. ', 'Missing expectations.'], name=None) 406 self.assert_tokenize_exp('[ Mac ]', warnings=['Did not find a test name. ', 'Missing expectations.'], name=None)
422 self.assert_tokenize_exp('[ [', warnings=['unexpected "["', 'Missing exp ectations.'], name=None) 407 self.assert_tokenize_exp('[ [', warnings=['unexpected "["', 'Missing exp ectations.'], name=None)
423 self.assert_tokenize_exp('crbug.com/12345 ]', warnings=['unexpected "]"' , 'Missing expectations.'], name=None) 408 self.assert_tokenize_exp('crbug.com/12345 ]', warnings=['unexpected "]"' , 'Missing expectations.'], name=None)
424 409
425 self.assert_tokenize_exp('foo.html crbug.com/12345 ]', warnings=['"crbug .com/12345" is not at the start of the line.', 'Missing expectations.']) 410 self.assert_tokenize_exp('foo.html crbug.com/12345 ]', warnings=['"crbug .com/12345" is not at the start of the line.', 'Missing expectations.'])
(...skipping 13 matching lines...) Expand all
439 424
440 def test_missing_bugid(self): 425 def test_missing_bugid(self):
441 self.parse_exp('failures/expected/text.html [ Failure ]') 426 self.parse_exp('failures/expected/text.html [ Failure ]')
442 self.assertFalse(self._exp.has_warnings()) 427 self.assertFalse(self._exp.has_warnings())
443 428
444 self._port.warn_if_bug_missing_in_test_expectations = lambda: True 429 self._port.warn_if_bug_missing_in_test_expectations = lambda: True
445 430
446 self.parse_exp('failures/expected/text.html [ Failure ]') 431 self.parse_exp('failures/expected/text.html [ Failure ]')
447 line = self._exp._model.get_expectation_line('failures/expected/text.htm l') 432 line = self._exp._model.get_expectation_line('failures/expected/text.htm l')
448 self.assertFalse(line.is_invalid()) 433 self.assertFalse(line.is_invalid())
449 self.assertEqual(line.warnings, ['Test lacks BUG modifier.']) 434 self.assertEqual(line.warnings, ['Test lacks BUG specifier.'])
450 435
451 def test_skip_and_wontfix(self): 436 def test_skip_and_wontfix(self):
452 # Skip is not allowed to have other expectations as well, because those 437 # Skip is not allowed to have other expectations as well, because those
453 # expectations won't be exercised and may become stale . 438 # expectations won't be exercised and may become stale .
454 self.parse_exp('failures/expected/text.html [ Failure Skip ]') 439 self.parse_exp('failures/expected/text.html [ Failure Skip ]')
455 self.assertTrue(self._exp.has_warnings()) 440 self.assertTrue(self._exp.has_warnings())
456 441
457 self.parse_exp('failures/expected/text.html [ Crash WontFix ]') 442 self.parse_exp('failures/expected/text.html [ Crash WontFix ]')
458 self.assertFalse(self._exp.has_warnings()) 443 self.assertTrue(self._exp.has_warnings())
459 444
460 self.parse_exp('failures/expected/text.html [ Pass WontFix ]') 445 self.parse_exp('failures/expected/text.html [ Pass WontFix ]')
461 self.assertFalse(self._exp.has_warnings()) 446 self.assertTrue(self._exp.has_warnings())
462 447
463 def test_slow_and_timeout(self): 448 def test_slow_and_timeout(self):
464 # A test cannot be SLOW and expected to TIMEOUT. 449 # A test cannot be SLOW and expected to TIMEOUT.
465 self.assertRaises(ParseError, self.parse_exp, 450 self.assertRaises(ParseError, self.parse_exp,
466 'Bug(test) failures/expected/timeout.html [ Slow Timeout ]', is_lint _mode=True) 451 'Bug(test) failures/expected/timeout.html [ Slow Timeout ]', is_lint _mode=True)
467 452
468 def test_rebaseline(self): 453 def test_rebaseline(self):
469 # Can't lint a file w/ 'REBASELINE' in it. 454 # Can't lint a file w/ 'REBASELINE' in it.
470 self.assertRaises(ParseError, self.parse_exp, 455 self.assertRaises(ParseError, self.parse_exp,
471 'Bug(test) failures/expected/text.html [ Failure Rebaseline ]', 456 'Bug(test) failures/expected/text.html [ Failure Rebaseline ]',
(...skipping 23 matching lines...) Expand all
495 class PrecedenceTests(Base): 480 class PrecedenceTests(Base):
496 def test_file_over_directory(self): 481 def test_file_over_directory(self):
497 # This tests handling precedence of specific lines over directories 482 # This tests handling precedence of specific lines over directories
498 # and tests expectations covering entire directories. 483 # and tests expectations covering entire directories.
499 exp_str = """ 484 exp_str = """
500 Bug(x) failures/expected/text.html [ Failure ] 485 Bug(x) failures/expected/text.html [ Failure ]
501 Bug(y) failures/expected [ WontFix ] 486 Bug(y) failures/expected [ WontFix ]
502 """ 487 """
503 self.parse_exp(exp_str) 488 self.parse_exp(exp_str)
504 self.assert_exp('failures/expected/text.html', FAIL) 489 self.assert_exp('failures/expected/text.html', FAIL)
505 self.assert_exp('failures/expected/crash.html', PASS) 490 self.assert_exp_list('failures/expected/crash.html', [WONTFIX, SKIP])
506 491
507 exp_str = """ 492 exp_str = """
508 Bug(x) failures/expected [ WontFix ] 493 Bug(x) failures/expected [ WontFix ]
509 Bug(y) failures/expected/text.html [ Failure ] 494 Bug(y) failures/expected/text.html [ Failure ]
510 """ 495 """
511 self.parse_exp(exp_str) 496 self.parse_exp(exp_str)
512 self.assert_exp('failures/expected/text.html', FAIL) 497 self.assert_exp('failures/expected/text.html', FAIL)
513 self.assert_exp('failures/expected/crash.html', PASS) 498 self.assert_exp_list('failures/expected/crash.html', [WONTFIX, SKIP])
514 499
515 def test_ambiguous(self): 500 def test_ambiguous(self):
516 self.assert_bad_expectations("Bug(test) [ Release ] passes/text.html [ P ass ]\n" 501 self.assert_bad_expectations("Bug(test) [ Release ] passes/text.html [ P ass ]\n"
517 "Bug(test) [ Win ] passes/text.html [ Failu re ]\n") 502 "Bug(test) [ Win ] passes/text.html [ Failu re ]\n")
518 503
519 def test_more_modifiers(self): 504 def test_more_specifiers(self):
520 self.assert_bad_expectations("Bug(test) [ Release ] passes/text.html [ P ass ]\n" 505 self.assert_bad_expectations("Bug(test) [ Release ] passes/text.html [ P ass ]\n"
521 "Bug(test) [ Win Release ] passes/text.html [ Failure ]\n") 506 "Bug(test) [ Win Release ] passes/text.html [ Failure ]\n")
522 507
523 def test_order_in_file(self): 508 def test_order_in_file(self):
524 self.assert_bad_expectations("Bug(test) [ Win Release ] : passes/text.ht ml [ Failure ]\n" 509 self.assert_bad_expectations("Bug(test) [ Win Release ] : passes/text.ht ml [ Failure ]\n"
525 "Bug(test) [ Release ] : passes/text.html [ Pass ]\n") 510 "Bug(test) [ Release ] : passes/text.html [ Pass ]\n")
526 511
527 def test_macro_overrides(self): 512 def test_macro_overrides(self):
528 self.assert_bad_expectations("Bug(test) [ Win ] passes/text.html [ Pass ]\n" 513 self.assert_bad_expectations("Bug(test) [ Win ] passes/text.html [ Pass ]\n"
529 "Bug(test) [ XP ] passes/text.html [ Failur e ]\n") 514 "Bug(test) [ XP ] passes/text.html [ Failur e ]\n")
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 671
687 actual_expectations = expectations.remove_configuration_from_test('failu res/expected/foo.html', test_config) 672 actual_expectations = expectations.remove_configuration_from_test('failu res/expected/foo.html', test_config)
688 actual_expectations = expectations.remove_configuration_from_test('failu res/expected/foo.html', host.port_factory.get('test-win-win7', None).test_config uration()) 673 actual_expectations = expectations.remove_configuration_from_test('failu res/expected/foo.html', host.port_factory.get('test-win-win7', None).test_config uration())
689 674
690 self.assertEqual("""Bug(x) [ Win Debug ] failures/expected/foo.html [ Fa ilure Timeout ] 675 self.assertEqual("""Bug(x) [ Win Debug ] failures/expected/foo.html [ Fa ilure Timeout ]
691 Bug(y) [ Mac ] failures/expected/foo.html [ Crash ] 676 Bug(y) [ Mac ] failures/expected/foo.html [ Crash ]
692 """, actual_expectations) 677 """, actual_expectations)
693 678
694 679
695 class RebaseliningTest(Base): 680 class RebaseliningTest(Base):
696 """Test rebaselining-specific functionality."""
697 def assertRemove(self, input_expectations, input_overrides, tests, expected_ expectations, expected_overrides):
698 self.parse_exp(input_expectations, is_lint_mode=False, overrides=input_o verrides)
699 actual_expectations = self._exp.remove_rebaselined_tests(tests, 'expecta tions')
700 self.assertEqual(expected_expectations, actual_expectations)
701 actual_overrides = self._exp.remove_rebaselined_tests(tests, 'overrides' )
702 self.assertEqual(expected_overrides, actual_overrides)
703
704 def test_remove(self):
705 self.assertRemove('Bug(x) failures/expected/text.html [ Failure Rebaseli ne ]\n'
706 'Bug(y) failures/expected/image.html [ ImageOnlyFailur e Rebaseline ]\n'
707 'Bug(z) failures/expected/crash.html [ Crash ]\n',
708 'Bug(x0) failures/expected/image.html [ Crash ]\n',
709 ['failures/expected/text.html'],
710 'Bug(y) failures/expected/image.html [ ImageOnlyFailur e Rebaseline ]\n'
711 'Bug(z) failures/expected/crash.html [ Crash ]\n',
712 'Bug(x0) failures/expected/image.html [ Crash ]\n')
713
714 # Ensure that we don't modify unrelated lines, even if we could rewrite them.
715 # i.e., the second line doesn't get rewritten to "Bug(y) failures/expect ed/skip.html"
716 self.assertRemove('Bug(x) failures/expected/text.html [ Failure Rebaseli ne ]\n'
717 'Bug(Y) failures/expected/image.html [ Skip ]\n'
718 'Bug(z) failures/expected/crash.html\n',
719 '',
720 ['failures/expected/text.html'],
721 'Bug(Y) failures/expected/image.html [ Skip ]\n'
722 'Bug(z) failures/expected/crash.html\n',
723 '')
724
725 def test_get_rebaselining_failures(self): 681 def test_get_rebaselining_failures(self):
726 # Make sure we find a test as needing a rebaseline even if it is not mar ked as a failure. 682 # Make sure we find a test as needing a rebaseline even if it is not mar ked as a failure.
727 self.parse_exp('Bug(x) failures/expected/text.html [ Rebaseline ]\n') 683 self.parse_exp('Bug(x) failures/expected/text.html [ Rebaseline ]\n')
728 self.assertEqual(len(self._exp.get_rebaselining_failures()), 1) 684 self.assertEqual(len(self._exp.get_rebaselining_failures()), 1)
729 685
730 self.parse_exp(self.get_basic_expectations()) 686 self.parse_exp(self.get_basic_expectations())
731 self.assertEqual(len(self._exp.get_rebaselining_failures()), 0) 687 self.assertEqual(len(self._exp.get_rebaselining_failures()), 0)
732 688
733 689
734 class TestExpectationsParserTests(unittest.TestCase): 690 class TestExpectationsParserTests(unittest.TestCase):
735 def __init__(self, testFunc): 691 def __init__(self, testFunc):
736 host = MockHost() 692 host = MockHost()
737 test_port = host.port_factory.get('test-win-xp', None) 693 test_port = host.port_factory.get('test-win-xp', None)
738 self._converter = TestConfigurationConverter(test_port.all_test_configur ations(), test_port.configuration_specifier_macros()) 694 self._converter = TestConfigurationConverter(test_port.all_test_configur ations(), test_port.configuration_specifier_macros())
739 unittest.TestCase.__init__(self, testFunc) 695 unittest.TestCase.__init__(self, testFunc)
740 self._parser = TestExpectationParser(host.port_factory.get('test-win-xp' , None), [], allow_rebaseline_modifier=False) 696 self._parser = TestExpectationParser(host.port_factory.get('test-win-xp' , None), [], allow_rebaseline=False)
741 697
742 def test_expectation_line_for_test(self): 698 def test_expectation_line_for_test(self):
743 # This is kind of a silly test, but it at least ensures that we don't th row an error. 699 # This is kind of a silly test, but it at least ensures that we don't th row an error.
744 test_name = 'foo/test.html' 700 test_name = 'foo/test.html'
745 expectations = set(["PASS", "IMAGE"]) 701 expectations = set(["PASS", "IMAGE"])
746 702
747 expectation_line = TestExpectationLine() 703 expectation_line = TestExpectationLine()
748 expectation_line.original_string = test_name 704 expectation_line.original_string = test_name
749 expectation_line.name = test_name 705 expectation_line.name = test_name
750 expectation_line.filename = '<Bot TestExpectations>' 706 expectation_line.filename = '<Bot TestExpectations>'
(...skipping 15 matching lines...) Expand all
766 return TestExpectationParser._tokenize_line('path', line, 0) 722 return TestExpectationParser._tokenize_line('path', line, 0)
767 723
768 def assert_round_trip(self, in_string, expected_string=None): 724 def assert_round_trip(self, in_string, expected_string=None):
769 expectation = self._tokenize(in_string) 725 expectation = self._tokenize(in_string)
770 if expected_string is None: 726 if expected_string is None:
771 expected_string = in_string 727 expected_string = in_string
772 self.assertEqual(expected_string, expectation.to_string(self._converter) ) 728 self.assertEqual(expected_string, expectation.to_string(self._converter) )
773 729
774 def assert_list_round_trip(self, in_string, expected_string=None): 730 def assert_list_round_trip(self, in_string, expected_string=None):
775 host = MockHost() 731 host = MockHost()
776 parser = TestExpectationParser(host.port_factory.get('test-win-xp', None ), [], allow_rebaseline_modifier=False) 732 parser = TestExpectationParser(host.port_factory.get('test-win-xp', None ), [], allow_rebaseline=False)
777 expectations = parser.parse('path', in_string) 733 expectations = parser.parse('path', in_string)
778 if expected_string is None: 734 if expected_string is None:
779 expected_string = in_string 735 expected_string = in_string
780 self.assertEqual(expected_string, TestExpectations.list_to_string(expect ations, self._converter)) 736 self.assertEqual(expected_string, TestExpectations.list_to_string(expect ations, self._converter))
781 737
782 def test_unparsed_to_string(self): 738 def test_unparsed_to_string(self):
783 expectation = TestExpectationLine() 739 expectation = TestExpectationLine()
784 740
785 self.assertEqual(expectation.to_string(self._converter), '') 741 self.assertEqual(expectation.to_string(self._converter), '')
786 expectation.comment = ' Qux.' 742 expectation.comment = ' Qux.'
787 self.assertEqual(expectation.to_string(self._converter), '# Qux.') 743 self.assertEqual(expectation.to_string(self._converter), '# Qux.')
788 expectation.name = 'bar' 744 expectation.name = 'bar'
789 self.assertEqual(expectation.to_string(self._converter), 'bar # Qux.') 745 self.assertEqual(expectation.to_string(self._converter), 'bar # Qux.')
790 expectation.modifiers = ['foo'] 746 expectation.specifiers = ['foo']
791 # FIXME: case should be preserved here but we can't until we drop the ol d syntax. 747 # FIXME: case should be preserved here but we can't until we drop the ol d syntax.
792 self.assertEqual(expectation.to_string(self._converter), '[ FOO ] bar # Qux.') 748 self.assertEqual(expectation.to_string(self._converter), '[ FOO ] bar # Qux.')
793 expectation.expectations = ['bAz'] 749 expectation.expectations = ['bAz']
794 self.assertEqual(expectation.to_string(self._converter), '[ FOO ] bar [ BAZ ] # Qux.') 750 self.assertEqual(expectation.to_string(self._converter), '[ FOO ] bar [ BAZ ] # Qux.')
795 expectation.expectations = ['bAz1', 'baZ2'] 751 expectation.expectations = ['bAz1', 'baZ2']
796 self.assertEqual(expectation.to_string(self._converter), '[ FOO ] bar [ BAZ1 BAZ2 ] # Qux.') 752 self.assertEqual(expectation.to_string(self._converter), '[ FOO ] bar [ BAZ1 BAZ2 ] # Qux.')
797 expectation.modifiers = ['foo1', 'foO2'] 753 expectation.specifiers = ['foo1', 'foO2']
798 self.assertEqual(expectation.to_string(self._converter), '[ FOO1 FOO2 ] bar [ BAZ1 BAZ2 ] # Qux.') 754 self.assertEqual(expectation.to_string(self._converter), '[ FOO1 FOO2 ] bar [ BAZ1 BAZ2 ] # Qux.')
799 expectation.warnings.append('Oh the horror.') 755 expectation.warnings.append('Oh the horror.')
800 self.assertEqual(expectation.to_string(self._converter), '') 756 self.assertEqual(expectation.to_string(self._converter), '')
801 expectation.original_string = 'Yes it is!' 757 expectation.original_string = 'Yes it is!'
802 self.assertEqual(expectation.to_string(self._converter), 'Yes it is!') 758 self.assertEqual(expectation.to_string(self._converter), 'Yes it is!')
803 759
804 def test_unparsed_list_to_string(self): 760 def test_unparsed_list_to_string(self):
805 expectation = TestExpectationLine() 761 expectation = TestExpectationLine()
806 expectation.comment = 'Qux.' 762 expectation.comment = 'Qux.'
807 expectation.name = 'bar' 763 expectation.name = 'bar'
808 expectation.modifiers = ['foo'] 764 expectation.specifiers = ['foo']
809 expectation.expectations = ['bAz1', 'baZ2'] 765 expectation.expectations = ['bAz1', 'baZ2']
810 # FIXME: case should be preserved here but we can't until we drop the ol d syntax. 766 # FIXME: case should be preserved here but we can't until we drop the ol d syntax.
811 self.assertEqual(TestExpectations.list_to_string([expectation]), '[ FOO ] bar [ BAZ1 BAZ2 ] #Qux.') 767 self.assertEqual(TestExpectations.list_to_string([expectation]), '[ FOO ] bar [ BAZ1 BAZ2 ] #Qux.')
812 768
813 def test_parsed_to_string(self): 769 def test_parsed_to_string(self):
814 expectation_line = TestExpectationLine() 770 expectation_line = TestExpectationLine()
815 expectation_line.bugs = ['Bug(x)'] 771 expectation_line.bugs = ['Bug(x)']
816 expectation_line.name = 'test/name/for/realz.html' 772 expectation_line.name = 'test/name/for/realz.html'
817 expectation_line.parsed_expectations = set([IMAGE]) 773 expectation_line.parsed_expectations = set([IMAGE])
818 self.assertEqual(expectation_line.to_string(self._converter), None) 774 self.assertEqual(expectation_line.to_string(self._converter), None)
819 expectation_line.matching_configurations = set([TestConfiguration('xp', 'x86', 'release')]) 775 expectation_line.matching_configurations = set([TestConfiguration('xp', 'x86', 'release')])
820 self.assertEqual(expectation_line.to_string(self._converter), 'Bug(x) [ XP Release ] test/name/for/realz.html [ ImageOnlyFailure ]') 776 self.assertEqual(expectation_line.to_string(self._converter), 'Bug(x) [ XP Release ] test/name/for/realz.html [ ImageOnlyFailure ]')
821 expectation_line.matching_configurations = set([TestConfiguration('xp', 'x86', 'release'), TestConfiguration('xp', 'x86', 'debug')]) 777 expectation_line.matching_configurations = set([TestConfiguration('xp', 'x86', 'release'), TestConfiguration('xp', 'x86', 'debug')])
822 self.assertEqual(expectation_line.to_string(self._converter), 'Bug(x) [ XP ] test/name/for/realz.html [ ImageOnlyFailure ]') 778 self.assertEqual(expectation_line.to_string(self._converter), 'Bug(x) [ XP ] test/name/for/realz.html [ ImageOnlyFailure ]')
823 779
824 def test_serialize_parsed_expectations(self): 780 def test_serialize_parsed_expectations(self):
825 expectation_line = TestExpectationLine() 781 expectation_line = TestExpectationLine()
826 expectation_line.parsed_expectations = set([]) 782 expectation_line.parsed_expectations = set([])
827 parsed_expectation_to_string = dict([[parsed_expectation, expectation_st ring] for expectation_string, parsed_expectation in TestExpectations.EXPECTATION S.items()]) 783 parsed_expectation_to_string = dict([[parsed_expectation, expectation_st ring] for expectation_string, parsed_expectation in TestExpectations.EXPECTATION S.items()])
828 self.assertEqual(expectation_line._serialize_parsed_expectations(parsed_ expectation_to_string), '') 784 self.assertEqual(expectation_line._serialize_parsed_expectations(parsed_ expectation_to_string), '')
829 expectation_line.parsed_expectations = set([FAIL]) 785 expectation_line.parsed_expectations = set([FAIL])
830 self.assertEqual(expectation_line._serialize_parsed_expectations(parsed_ expectation_to_string), 'fail') 786 self.assertEqual(expectation_line._serialize_parsed_expectations(parsed_ expectation_to_string), 'fail')
831 expectation_line.parsed_expectations = set([PASS, IMAGE]) 787 expectation_line.parsed_expectations = set([PASS, IMAGE])
832 self.assertEqual(expectation_line._serialize_parsed_expectations(parsed_ expectation_to_string), 'pass image') 788 self.assertEqual(expectation_line._serialize_parsed_expectations(parsed_ expectation_to_string), 'pass image')
833 expectation_line.parsed_expectations = set([FAIL, PASS]) 789 expectation_line.parsed_expectations = set([FAIL, PASS])
834 self.assertEqual(expectation_line._serialize_parsed_expectations(parsed_ expectation_to_string), 'pass fail') 790 self.assertEqual(expectation_line._serialize_parsed_expectations(parsed_ expectation_to_string), 'pass fail')
835 791
836 def test_serialize_parsed_modifier_string(self): 792 def test_serialize_parsed_specifier_string(self):
837 expectation_line = TestExpectationLine() 793 expectation_line = TestExpectationLine()
838 expectation_line.bugs = ['garden-o-matic'] 794 expectation_line.bugs = ['garden-o-matic']
839 expectation_line.parsed_modifiers = ['the', 'for'] 795 expectation_line.parsed_specifiers = ['the', 'for']
840 self.assertEqual(expectation_line._serialize_parsed_modifiers(self._conv erter, []), 'for the') 796 self.assertEqual(expectation_line._serialize_parsed_specifiers(self._con verter, []), 'for the')
841 self.assertEqual(expectation_line._serialize_parsed_modifiers(self._conv erter, ['win']), 'for the win') 797 self.assertEqual(expectation_line._serialize_parsed_specifiers(self._con verter, ['win']), 'for the win')
842 expectation_line.bugs = [] 798 expectation_line.bugs = []
843 expectation_line.parsed_modifiers = [] 799 expectation_line.parsed_specifiers = []
844 self.assertEqual(expectation_line._serialize_parsed_modifiers(self._conv erter, []), '') 800 self.assertEqual(expectation_line._serialize_parsed_specifiers(self._con verter, []), '')
845 self.assertEqual(expectation_line._serialize_parsed_modifiers(self._conv erter, ['win']), 'win') 801 self.assertEqual(expectation_line._serialize_parsed_specifiers(self._con verter, ['win']), 'win')
846 802
847 def test_format_line(self): 803 def test_format_line(self):
848 self.assertEqual(TestExpectationLine._format_line([], ['MODIFIERS'], 'na me', ['EXPECTATIONS'], 'comment'), '[ MODIFIERS ] name [ EXPECTATIONS ] #comment ') 804 self.assertEqual(TestExpectationLine._format_line([], ['MODIFIERS'], 'na me', ['EXPECTATIONS'], 'comment'), '[ MODIFIERS ] name [ EXPECTATIONS ] #comment ')
849 self.assertEqual(TestExpectationLine._format_line([], ['MODIFIERS'], 'na me', ['EXPECTATIONS'], None), '[ MODIFIERS ] name [ EXPECTATIONS ]') 805 self.assertEqual(TestExpectationLine._format_line([], ['MODIFIERS'], 'na me', ['EXPECTATIONS'], None), '[ MODIFIERS ] name [ EXPECTATIONS ]')
850 806
851 def test_string_roundtrip(self): 807 def test_string_roundtrip(self):
852 self.assert_round_trip('') 808 self.assert_round_trip('')
853 self.assert_round_trip('[') 809 self.assert_round_trip('[')
854 self.assert_round_trip('FOO [') 810 self.assert_round_trip('FOO [')
855 self.assert_round_trip('FOO ] bar') 811 self.assert_round_trip('FOO ] bar')
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 859
904 def disabled_test_string_whitespace_stripping(self): 860 def disabled_test_string_whitespace_stripping(self):
905 # FIXME: Re-enable this test once we rework the code to no longer suppor t the old syntax. 861 # FIXME: Re-enable this test once we rework the code to no longer suppor t the old syntax.
906 self.assert_round_trip('\n', '') 862 self.assert_round_trip('\n', '')
907 self.assert_round_trip(' [ FOO ] bar [ BAZ ]', '[ FOO ] bar [ BAZ ]') 863 self.assert_round_trip(' [ FOO ] bar [ BAZ ]', '[ FOO ] bar [ BAZ ]')
908 self.assert_round_trip('[ FOO ] bar [ BAZ ]', '[ FOO ] bar [ BAZ ]') 864 self.assert_round_trip('[ FOO ] bar [ BAZ ]', '[ FOO ] bar [ BAZ ]')
909 self.assert_round_trip('[ FOO ] bar [ BAZ ] # Qux.', '[ FOO ] bar [ BAZ ] # Qux.') 865 self.assert_round_trip('[ FOO ] bar [ BAZ ] # Qux.', '[ FOO ] bar [ BAZ ] # Qux.')
910 self.assert_round_trip('[ FOO ] bar [ BAZ ] # Qux.', '[ FOO ] ba r [ BAZ ] # Qux.') 866 self.assert_round_trip('[ FOO ] bar [ BAZ ] # Qux.', '[ FOO ] ba r [ BAZ ] # Qux.')
911 self.assert_round_trip('[ FOO ] bar [ BAZ ] # Qux.', '[ FOO ] bar [ BAZ ] # Qux.') 867 self.assert_round_trip('[ FOO ] bar [ BAZ ] # Qux.', '[ FOO ] bar [ BAZ ] # Qux.')
912 self.assert_round_trip('[ FOO ] bar [ BAZ ] # Qux.', '[ FO O ] bar [ BAZ ] # Qux.') 868 self.assert_round_trip('[ FOO ] bar [ BAZ ] # Qux.', '[ FO O ] bar [ BAZ ] # Qux.')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698