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

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/lint_test_expectations_unittest.py

Issue 963723002: Add JSON support to lint-test-expectations (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 FakePort(host, 'b', 'path-to-b'), 87 FakePort(host, 'b', 'path-to-b'),
88 FakePort(host, 'b-win', 'path-to- b'))) 88 FakePort(host, 'b-win', 'path-to- b')))
89 89
90 logging_stream = StringIO.StringIO() 90 logging_stream = StringIO.StringIO()
91 options = optparse.Values({'platform': None}) 91 options = optparse.Values({'platform': None})
92 logger, handler = lint_test_expectations.set_up_logging(logging_stream) 92 logger, handler = lint_test_expectations.set_up_logging(logging_stream)
93 try: 93 try:
94 res = lint_test_expectations.lint(host, options) 94 res = lint_test_expectations.lint(host, options)
95 finally: 95 finally:
96 lint_test_expectations.tear_down_logging(logger, handler) 96 lint_test_expectations.tear_down_logging(logger, handler)
97 self.assertEqual(res, 0) 97 self.assertEqual(res, [])
98 self.assertEqual(host.ports_parsed, ['a', 'b', 'b-win']) 98 self.assertEqual(host.ports_parsed, ['a', 'b', 'b-win'])
99 99
100 def test_lint_test_files(self): 100 def test_lint_test_files(self):
101 logging_stream = StringIO.StringIO() 101 logging_stream = StringIO.StringIO()
102 options = optparse.Values({'platform': 'test-mac-leopard'}) 102 options = optparse.Values({'platform': 'test-mac-leopard'})
103 host = MockHost() 103 host = MockHost()
104 104
105 # pylint appears to complain incorrectly about the method overrides pyli nt: disable=E0202,C0322 105 # pylint appears to complain incorrectly about the method overrides pyli nt: disable=E0202,C0322
106 # FIXME: incorrect complaints about spacing pylint: disable=C0322 106 # FIXME: incorrect complaints about spacing pylint: disable=C0322
107 host.port_factory.all_port_names = lambda platform=None: [platform] 107 host.port_factory.all_port_names = lambda platform=None: [platform]
108 108
109 logger, handler = lint_test_expectations.set_up_logging(logging_stream) 109 logger, handler = lint_test_expectations.set_up_logging(logging_stream)
110 try: 110 try:
111 res = lint_test_expectations.lint(host, options) 111 res = lint_test_expectations.lint(host, options)
112 self.assertEqual(res, 0) 112 self.assertEqual(res, [])
113 finally: 113 finally:
114 lint_test_expectations.tear_down_logging(logger, handler) 114 lint_test_expectations.tear_down_logging(logger, handler)
115 115
116 116
117 def test_lint_test_files__errors(self): 117 def test_lint_test_files__errors(self):
118 options = optparse.Values({'platform': 'test', 'debug_rwt_logging': Fals e}) 118 options = optparse.Values({'platform': 'test', 'debug_rwt_logging': Fals e})
119 host = MockHost() 119 host = MockHost()
120 120
121 # FIXME: incorrect complaints about spacing pylint: disable=C0322 121 # FIXME: incorrect complaints about spacing pylint: disable=C0322
122 port = host.port_factory.get(options.platform, options=options) 122 port = host.port_factory.get(options.platform, options=options)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 finally: 156 finally:
157 lint_test_expectations.tear_down_logging(logger, handler) 157 lint_test_expectations.tear_down_logging(logger, handler)
158 158
159 159
160 class MainTest(unittest.TestCase): 160 class MainTest(unittest.TestCase):
161 # unused args pylint: disable=W0613 161 # unused args pylint: disable=W0613
162 162
163 def setUp(self): 163 def setUp(self):
164 self.orig_lint_fn = lint_test_expectations.lint 164 self.orig_lint_fn = lint_test_expectations.lint
165 self.orig_check_fn = lint_test_expectations.check_virtual_test_suites 165 self.orig_check_fn = lint_test_expectations.check_virtual_test_suites
166 lint_test_expectations.check_virtual_test_suites = lambda host, options: False 166 lint_test_expectations.check_virtual_test_suites = lambda host, options: []
167 167
168 self.stdout = StringIO.StringIO() 168 self.stdout = StringIO.StringIO()
169 self.stderr = StringIO.StringIO() 169 self.stderr = StringIO.StringIO()
170 170
171 def tearDown(self): 171 def tearDown(self):
172 lint_test_expectations.lint = self.orig_lint_fn 172 lint_test_expectations.lint = self.orig_lint_fn
173 lint_test_expectations.check_virtual_test_suites = self.orig_check_fn 173 lint_test_expectations.check_virtual_test_suites = self.orig_check_fn
174 174
175 def test_success(self): 175 def test_success(self):
176 lint_test_expectations.lint = lambda host, options: False 176 lint_test_expectations.lint = lambda host, options: []
177 res = lint_test_expectations.main(['--platform', 'test'], self.stdout, s elf.stderr) 177 res = lint_test_expectations.main(['--platform', 'test'], self.stdout, s elf.stderr)
178 self.assertTrue('Lint succeeded' in self.stderr.getvalue()) 178 self.assertTrue('Lint succeeded' in self.stderr.getvalue())
179 self.assertEqual(res, 0) 179 self.assertEqual(res, 0)
180 180
181 def test_failure(self): 181 def test_failure(self):
182 lint_test_expectations.lint = lambda host, options: True 182 lint_test_expectations.lint = lambda host, options: ['test failure']
183 res = lint_test_expectations.main(['--platform', 'test'], self.stdout, s elf.stderr) 183 res = lint_test_expectations.main(['--platform', 'test'], self.stdout, s elf.stderr)
184 self.assertTrue('Lint failed' in self.stderr.getvalue()) 184 self.assertTrue('Lint failed' in self.stderr.getvalue())
185 self.assertEqual(res, 1) 185 self.assertEqual(res, 1)
186 186
187 def test_interrupt(self): 187 def test_interrupt(self):
188 def interrupting_lint(host, options): 188 def interrupting_lint(host, options):
189 raise KeyboardInterrupt 189 raise KeyboardInterrupt
190 190
191 lint_test_expectations.lint = interrupting_lint 191 lint_test_expectations.lint = interrupting_lint
192 res = lint_test_expectations.main([], self.stdout, self.stderr) 192 res = lint_test_expectations.main([], self.stdout, self.stderr)
193 self.assertEqual(res, lint_test_expectations.INTERRUPTED_EXIT_STATUS) 193 self.assertEqual(res, lint_test_expectations.INTERRUPTED_EXIT_STATUS)
194 194
195 def test_exception(self): 195 def test_exception(self):
196 def exception_raising_lint(host, options): 196 def exception_raising_lint(host, options):
197 assert False 197 assert False
198 lint_test_expectations.lint = exception_raising_lint 198 lint_test_expectations.lint = exception_raising_lint
199 res = lint_test_expectations.main([], self.stdout, self.stderr) 199 res = lint_test_expectations.main([], self.stdout, self.stderr)
200 self.assertEqual(res, lint_test_expectations.EXCEPTIONAL_EXIT_STATUS) 200 self.assertEqual(res, lint_test_expectations.EXCEPTIONAL_EXIT_STATUS)
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698