| OLD | NEW |
| 1 # Copyright (C) 2012 Google Inc. All rights reserved. | 1 # Copyright (C) 2012 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 import StringIO | 29 import StringIO |
| 30 import optparse | 30 import optparse |
| 31 import unittest | 31 import unittest |
| 32 | 32 |
| 33 from webkitpy.common.host_mock import MockHost | 33 from webkitpy.common.host_mock import MockHost |
| 34 from webkitpy.layout_tests import lint_test_expectations | 34 from webkitpy.layout_tests import lint_test_expectations |
| 35 | 35 |
| 36 | 36 |
| 37 class FakePort(object): | 37 class FakePort(object): |
| 38 |
| 38 def __init__(self, host, name, path): | 39 def __init__(self, host, name, path): |
| 39 self.host = host | 40 self.host = host |
| 40 self.name = name | 41 self.name = name |
| 41 self.path = path | 42 self.path = path |
| 42 | 43 |
| 43 def test_configuration(self): | 44 def test_configuration(self): |
| 44 return None | 45 return None |
| 45 | 46 |
| 46 def expectations_dict(self): | 47 def expectations_dict(self): |
| 47 self.host.ports_parsed.append(self.name) | 48 self.host.ports_parsed.append(self.name) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 | 59 |
| 59 def configuration_specifier_macros(self): | 60 def configuration_specifier_macros(self): |
| 60 return [] | 61 return [] |
| 61 | 62 |
| 62 def get_option(self, _, val): | 63 def get_option(self, _, val): |
| 63 return val | 64 return val |
| 64 | 65 |
| 65 def path_to_generic_test_expectations_file(self): | 66 def path_to_generic_test_expectations_file(self): |
| 66 return '' | 67 return '' |
| 67 | 68 |
| 69 |
| 68 class FakeFactory(object): | 70 class FakeFactory(object): |
| 71 |
| 69 def __init__(self, host, ports): | 72 def __init__(self, host, ports): |
| 70 self.host = host | 73 self.host = host |
| 71 self.ports = {} | 74 self.ports = {} |
| 72 for port in ports: | 75 for port in ports: |
| 73 self.ports[port.name] = port | 76 self.ports[port.name] = port |
| 74 | 77 |
| 75 def get(self, port_name='a', *args, **kwargs): # pylint: disable=W0613,E020
2 | 78 def get(self, port_name='a', *args, **kwargs): # pylint: disable=W0613,E020
2 |
| 76 return self.ports[port_name] | 79 return self.ports[port_name] |
| 77 | 80 |
| 78 def all_port_names(self, platform=None): # pylint: disable=W0613,E0202 | 81 def all_port_names(self, platform=None): # pylint: disable=W0613,E0202 |
| 79 return sorted(self.ports.keys()) | 82 return sorted(self.ports.keys()) |
| 80 | 83 |
| 81 | 84 |
| 82 class LintTest(unittest.TestCase): | 85 class LintTest(unittest.TestCase): |
| 86 |
| 83 def test_all_configurations(self): | 87 def test_all_configurations(self): |
| 84 host = MockHost() | 88 host = MockHost() |
| 85 host.ports_parsed = [] | 89 host.ports_parsed = [] |
| 86 host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'), | 90 host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'), |
| 87 FakePort(host, 'b', 'path-to-b'), | 91 FakePort(host, 'b', 'path-to-b'), |
| 88 FakePort(host, 'b-win', 'path-to-
b'))) | 92 FakePort(host, 'b-win', 'path-to-
b'))) |
| 89 | 93 |
| 90 logging_stream = StringIO.StringIO() | 94 logging_stream = StringIO.StringIO() |
| 91 options = optparse.Values({'platform': None}) | 95 options = optparse.Values({'platform': None}) |
| 92 logger, handler = lint_test_expectations.set_up_logging(logging_stream) | 96 logger, handler = lint_test_expectations.set_up_logging(logging_stream) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 106 # FIXME: incorrect complaints about spacing pylint: disable=C0322 | 110 # FIXME: incorrect complaints about spacing pylint: disable=C0322 |
| 107 host.port_factory.all_port_names = lambda platform=None: [platform] | 111 host.port_factory.all_port_names = lambda platform=None: [platform] |
| 108 | 112 |
| 109 logger, handler = lint_test_expectations.set_up_logging(logging_stream) | 113 logger, handler = lint_test_expectations.set_up_logging(logging_stream) |
| 110 try: | 114 try: |
| 111 res = lint_test_expectations.lint(host, options) | 115 res = lint_test_expectations.lint(host, options) |
| 112 self.assertEqual(res, 0) | 116 self.assertEqual(res, 0) |
| 113 finally: | 117 finally: |
| 114 lint_test_expectations.tear_down_logging(logger, handler) | 118 lint_test_expectations.tear_down_logging(logger, handler) |
| 115 | 119 |
| 116 | |
| 117 def test_lint_test_files__errors(self): | 120 def test_lint_test_files__errors(self): |
| 118 options = optparse.Values({'platform': 'test', 'debug_rwt_logging': Fals
e}) | 121 options = optparse.Values({'platform': 'test', 'debug_rwt_logging': Fals
e}) |
| 119 host = MockHost() | 122 host = MockHost() |
| 120 | 123 |
| 121 # FIXME: incorrect complaints about spacing pylint: disable=C0322 | 124 # FIXME: incorrect complaints about spacing pylint: disable=C0322 |
| 122 port = host.port_factory.get(options.platform, options=options) | 125 port = host.port_factory.get(options.platform, options=options) |
| 123 port.expectations_dict = lambda: {'foo': '-- syntax error1', 'bar': '--
syntax error2'} | 126 port.expectations_dict = lambda: {'foo': '-- syntax error1', 'bar': '--
syntax error2'} |
| 124 | 127 |
| 125 host.port_factory.get = lambda platform, options=None: port | 128 host.port_factory.get = lambda platform, options=None: port |
| 126 host.port_factory.all_port_names = lambda platform=None: [port.name()] | 129 host.port_factory.all_port_names = lambda platform=None: [port.name()] |
| 127 | 130 |
| 128 logging_stream = StringIO.StringIO() | 131 logging_stream = StringIO.StringIO() |
| 129 logger, handler = lint_test_expectations.set_up_logging(logging_stream) | 132 logger, handler = lint_test_expectations.set_up_logging(logging_stream) |
| 130 try: | 133 try: |
| 131 res = lint_test_expectations.lint(host, options) | 134 res = lint_test_expectations.lint(host, options) |
| 132 finally: | 135 finally: |
| 133 lint_test_expectations.tear_down_logging(logger, handler) | 136 lint_test_expectations.tear_down_logging(logger, handler) |
| 134 | 137 |
| 135 self.assertTrue(res) | 138 self.assertTrue(res) |
| 136 self.assertIn('foo:1', logging_stream.getvalue()) | 139 self.assertIn('foo:1', logging_stream.getvalue()) |
| 137 self.assertIn('bar:1', logging_stream.getvalue()) | 140 self.assertIn('bar:1', logging_stream.getvalue()) |
| 138 | 141 |
| 139 | 142 |
| 140 class CheckVirtualSuiteTest(unittest.TestCase): | 143 class CheckVirtualSuiteTest(unittest.TestCase): |
| 144 |
| 141 def test_check_virtual_test_suites(self): | 145 def test_check_virtual_test_suites(self): |
| 142 host = MockHost() | 146 host = MockHost() |
| 143 options = optparse.Values({'platform': 'test', 'debug_rwt_logging': Fals
e}) | 147 options = optparse.Values({'platform': 'test', 'debug_rwt_logging': Fals
e}) |
| 144 orig_get = host.port_factory.get | 148 orig_get = host.port_factory.get |
| 145 host.port_factory.get = lambda options: orig_get('test', options=options
) | 149 host.port_factory.get = lambda options: orig_get('test', options=options
) |
| 146 | 150 |
| 147 logging_stream = StringIO.StringIO() | 151 logging_stream = StringIO.StringIO() |
| 148 logger, handler = lint_test_expectations.set_up_logging(logging_stream) | 152 logger, handler = lint_test_expectations.set_up_logging(logging_stream) |
| 149 try: | 153 try: |
| 150 res = lint_test_expectations.check_virtual_test_suites(host, options
) | 154 res = lint_test_expectations.check_virtual_test_suites(host, options
) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 lint_test_expectations.lint = interrupting_lint | 195 lint_test_expectations.lint = interrupting_lint |
| 192 res = lint_test_expectations.main([], self.stdout, self.stderr) | 196 res = lint_test_expectations.main([], self.stdout, self.stderr) |
| 193 self.assertEqual(res, lint_test_expectations.INTERRUPTED_EXIT_STATUS) | 197 self.assertEqual(res, lint_test_expectations.INTERRUPTED_EXIT_STATUS) |
| 194 | 198 |
| 195 def test_exception(self): | 199 def test_exception(self): |
| 196 def exception_raising_lint(host, options): | 200 def exception_raising_lint(host, options): |
| 197 assert False | 201 assert False |
| 198 lint_test_expectations.lint = exception_raising_lint | 202 lint_test_expectations.lint = exception_raising_lint |
| 199 res = lint_test_expectations.main([], self.stdout, self.stderr) | 203 res = lint_test_expectations.main([], self.stdout, self.stderr) |
| 200 self.assertEqual(res, lint_test_expectations.EXCEPTIONAL_EXIT_STATUS) | 204 self.assertEqual(res, lint_test_expectations.EXCEPTIONAL_EXIT_STATUS) |
| OLD | NEW |