| OLD | NEW |
| 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 15 matching lines...) Expand all Loading... |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import unittest | 29 import unittest |
| 30 | 30 |
| 31 from test_expectations import TestExpectationsChecker | 31 from test_expectations import TestExpectationsChecker |
| 32 from webkitpy.common.host_mock import MockHost | 32 from webkitpy.common.host_mock import MockHost |
| 33 | 33 |
| 34 | 34 |
| 35 class ErrorCollector(object): | 35 class ErrorCollector(object): |
| 36 |
| 36 """An error handler class for unit tests.""" | 37 """An error handler class for unit tests.""" |
| 37 | 38 |
| 38 def __init__(self): | 39 def __init__(self): |
| 39 self._errors = [] | 40 self._errors = [] |
| 40 self.turned_off_filtering = False | 41 self.turned_off_filtering = False |
| 41 | 42 |
| 42 def turn_off_line_filtering(self): | 43 def turn_off_line_filtering(self): |
| 43 self.turned_off_filtering = True | 44 self.turned_off_filtering = True |
| 44 | 45 |
| 45 def __call__(self, lineno, category, confidence, message): | 46 def __call__(self, lineno, category, confidence, message): |
| 46 self._errors.append('%s [%s] [%d]' % (message, category, confidence)) | 47 self._errors.append('%s [%s] [%d]' % (message, category, confidence)) |
| 47 return True | 48 return True |
| 48 | 49 |
| 49 def get_errors(self): | 50 def get_errors(self): |
| 50 return ''.join(self._errors) | 51 return ''.join(self._errors) |
| 51 | 52 |
| 52 def reset_errors(self): | 53 def reset_errors(self): |
| 53 self._errors = [] | 54 self._errors = [] |
| 54 self.turned_off_filtering = False | 55 self.turned_off_filtering = False |
| 55 | 56 |
| 56 | 57 |
| 57 class TestExpectationsTestCase(unittest.TestCase): | 58 class TestExpectationsTestCase(unittest.TestCase): |
| 59 |
| 58 """TestCase for test_expectations.py""" | 60 """TestCase for test_expectations.py""" |
| 59 | 61 |
| 60 def setUp(self): | 62 def setUp(self): |
| 61 self._error_collector = ErrorCollector() | 63 self._error_collector = ErrorCollector() |
| 62 self._test_file = 'passes/text.html' | 64 self._test_file = 'passes/text.html' |
| 63 | 65 |
| 64 def assert_lines_lint(self, lines, should_pass, expected_output=None): | 66 def assert_lines_lint(self, lines, should_pass, expected_output=None): |
| 65 self._error_collector.reset_errors() | 67 self._error_collector.reset_errors() |
| 66 | 68 |
| 67 host = MockHost() | 69 host = MockHost() |
| (...skipping 23 matching lines...) Expand all Loading... |
| 91 | 93 |
| 92 def test_valid_expectations(self): | 94 def test_valid_expectations(self): |
| 93 self.assert_lines_lint(["crbug.com/1234 [ Mac ] passes/text.html [ Pass
Failure ]"], should_pass=True) | 95 self.assert_lines_lint(["crbug.com/1234 [ Mac ] passes/text.html [ Pass
Failure ]"], should_pass=True) |
| 94 | 96 |
| 95 def test_invalid_expectations(self): | 97 def test_invalid_expectations(self): |
| 96 self.assert_lines_lint(["Bug(me) passes/text.html [ Give Up]"], should_p
ass=False) | 98 self.assert_lines_lint(["Bug(me) passes/text.html [ Give Up]"], should_p
ass=False) |
| 97 | 99 |
| 98 def test_tab(self): | 100 def test_tab(self): |
| 99 self.assert_lines_lint(["\twebkit.org/b/1 passes/text.html [ Pass ]"], s
hould_pass=False, | 101 self.assert_lines_lint(["\twebkit.org/b/1 passes/text.html [ Pass ]"], s
hould_pass=False, |
| 100 expected_output="Line contains tab character. [w
hitespace/tab] [5]") | 102 expected_output="Line contains tab character. [w
hitespace/tab] [5]") |
| OLD | NEW |