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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

Issue 2667423006: blink: Remove include ordering checks, clang-format does this now. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 # -*- coding: utf-8; -*- 1 # -*- coding: utf-8; -*-
2 # 2 #
3 # Copyright (C) 2011 Google Inc. All rights reserved. 3 # Copyright (C) 2011 Google Inc. All rights reserved.
4 # Copyright (C) 2009 Torch Mobile Inc. 4 # Copyright (C) 2009 Torch Mobile Inc.
5 # Copyright (C) 2009 Apple Inc. All rights reserved. 5 # Copyright (C) 2009 Apple Inc. All rights reserved.
6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org)
7 # 7 #
8 # Redistribution and use in source and binary forms, with or without 8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are 9 # modification, are permitted provided that the following conditions are
10 # met: 10 # met:
(...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 def test_check_next_include_order__other_then_config(self): 2264 def test_check_next_include_order__other_then_config(self):
2265 self.assertEqual('Found other header before a header this file implement s.', 2265 self.assertEqual('Found other header before a header this file implement s.',
2266 self.include_state.check_next_include_order(cpp_style._ OTHER_HEADER, False, True)) 2266 self.include_state.check_next_include_order(cpp_style._ OTHER_HEADER, False, True))
2267 2267
2268 def test_check_next_include_order__config_then_other_then_likely(self): 2268 def test_check_next_include_order__config_then_other_then_likely(self):
2269 self.assertEqual('Found other header before a header this file implement s.', 2269 self.assertEqual('Found other header before a header this file implement s.',
2270 self.include_state.check_next_include_order(cpp_style._ OTHER_HEADER, False, True)) 2270 self.include_state.check_next_include_order(cpp_style._ OTHER_HEADER, False, True))
2271 self.assertEqual('Found header this file implements after other header.' , 2271 self.assertEqual('Found header this file implements after other header.' ,
2272 self.include_state.check_next_include_order(cpp_style._ PRIMARY_HEADER, False, True)) 2272 self.include_state.check_next_include_order(cpp_style._ PRIMARY_HEADER, False, True))
2273 2273
2274 def test_check_alphabetical_include_order(self):
2275 self.assert_language_rules_check('foo.h',
2276 '#include "a.h"\n'
2277 '#include "c.h"\n'
2278 '#include "b.h"\n',
2279 'Alphabetical sorting problem. [build/ include_order] [4]')
2280
2281 self.assert_language_rules_check('foo.h',
2282 '#include "a.h"\n'
2283 '#include "b.h"\n'
2284 '#include "c.h"\n',
2285 '')
2286
2287 self.assert_language_rules_check('foo.h',
2288 '#include <assert.h>\n'
2289 '#include "bar.h"\n',
2290 'Alphabetical sorting problem. [build/ include_order] [4]')
2291
2292 self.assert_language_rules_check('foo.h',
2293 '#include "bar.h"\n'
2294 '#include <assert.h>\n',
2295 '')
2296
2297 def test_check_alphabetical_include_order_errors_reported_for_both_lines(sel f):
2298 # If one of the two lines of out of order headers are filtered, the erro r should be
2299 # reported on the other line.
2300 self.assert_language_rules_check('foo.h',
2301 '#include "a.h"\n'
2302 '#include "c.h"\n'
2303 '#include "b.h"\n',
2304 'Alphabetical sorting problem. [build/ include_order] [4]',
2305 lines_to_check=[2])
2306
2307 self.assert_language_rules_check('foo.h',
2308 '#include "a.h"\n'
2309 '#include "c.h"\n'
2310 '#include "b.h"\n',
2311 'Alphabetical sorting problem. [build/ include_order] [4]',
2312 lines_to_check=[3])
2313
2314 # If no lines are filtered, the error should be reported only once.
2315 self.assert_language_rules_check('foo.h',
2316 '#include "a.h"\n'
2317 '#include "c.h"\n'
2318 '#include "b.h"\n',
2319 'Alphabetical sorting problem. [build/ include_order] [4]')
2320
2321 def test_check_line_break_after_own_header(self): 2274 def test_check_line_break_after_own_header(self):
2322 self.assert_language_rules_check('foo.cpp', 2275 self.assert_language_rules_check('foo.cpp',
2323 '#include "foo.h"\n' 2276 '#include "foo.h"\n'
2324 '#include "bar.h"\n', 2277 '#include "bar.h"\n',
2325 ('You should add a blank line after imp lementation file\'s own header.' 2278 ('You should add a blank line after imp lementation file\'s own header.'
2326 ' [build/include_order] [4]')) 2279 ' [build/include_order] [4]'))
2327 2280
2328 self.assert_language_rules_check('foo.cpp', 2281 self.assert_language_rules_check('foo.cpp',
2329 '#include "foo.h"\n' 2282 '#include "foo.h"\n'
2330 '\n' 2283 '\n'
2331 '#include "bar.h"\n', 2284 '#include "bar.h"\n',
2332 '') 2285 '')
2333 2286
2334 def test_check_preprocessor_in_include_section(self): 2287 def test_check_preprocessor_in_include_section(self):
2335 self.assert_language_rules_check('foo.cpp', 2288 self.assert_language_rules_check('foo.cpp',
2336 '#include "foo.h"\n' 2289 '#include "foo.h"\n'
2337 '\n' 2290 '\n'
2338 '#ifdef BAZ\n' 2291 '#ifdef BAZ\n'
2339 '#include "baz.h"\n' 2292 '#include "baz.h"\n'
2340 '#else\n' 2293 '#else\n'
2341 '#include "foobar.h"\n' 2294 '#include "foobar.h"\n'
2342 '#endif"\n' 2295 '#endif"\n'
2343 '#include "bar.h"\n', # No flag becaus e previous is in preprocessor section 2296 '#include "bar.h"\n', # No flag becaus e previous is in preprocessor section
2344 '') 2297 '')
2345 2298
2346 self.assert_language_rules_check('foo.cpp',
2347 '#include "foo.h"\n'
2348 '\n'
2349 '#ifdef BAZ\n'
2350 '#include "baz.h"\n'
2351 '#endif"\n'
2352 '#include "bar.h"\n'
2353 '#include "a.h"\n', # Should still fla g this.
2354 'Alphabetical sorting problem. [build/ include_order] [4]')
2355
2356 self.assert_language_rules_check('foo.cpp',
2357 '#include "foo.h"\n'
2358 '\n'
2359 '#ifdef BAZ\n'
2360 '#include "baz.h"\n'
2361 '#include "bar.h"\n' # Should still fl ag this
2362 '#endif"\n',
2363 'Alphabetical sorting problem. [build/ include_order] [4]')
2364
2365 self.assert_language_rules_check('foo.cpp',
2366 '#include "foo.h"\n'
2367 '\n'
2368 '#ifdef BAZ\n'
2369 '#include "baz.h"\n'
2370 '#endif"\n'
2371 '#ifdef FOOBAR\n'
2372 '#include "foobar.h"\n'
2373 '#endif"\n'
2374 '#include "bar.h"\n'
2375 '#include "a.h"\n', # Should still fla g this.
2376 'Alphabetical sorting problem. [build/ include_order] [4]')
2377
2378 # Check that after an already included error, the sorting rules still wo rk. 2299 # Check that after an already included error, the sorting rules still wo rk.
2379 self.assert_language_rules_check('foo.cpp', 2300 self.assert_language_rules_check('foo.cpp',
2380 '#include "foo.h"\n' 2301 '#include "foo.h"\n'
2381 '\n' 2302 '\n'
2382 '#include "foo.h"\n' 2303 '#include "foo.h"\n'
2383 '#include "g.h"\n', 2304 '#include "g.h"\n',
2384 '"foo.h" already included at foo.cpp:1 [build/include] [4]') 2305 '"foo.h" already included at foo.cpp:1 [build/include] [4]')
2385 2306
2386 def test_primary_header(self): 2307 def test_primary_header(self):
2387 # File with non-existing primary header should not produce errors. 2308 # File with non-existing primary header should not produce errors.
(...skipping 23 matching lines...) Expand all
2411 'alphabetically sorted. [build/includ e_order] [4]']) 2332 'alphabetically sorted. [build/includ e_order] [4]'])
2412 # Having include for existing primary header -> no error. 2333 # Having include for existing primary header -> no error.
2413 self.assert_language_rules_check('foo.cpp', 2334 self.assert_language_rules_check('foo.cpp',
2414 '#include "foo.h"\n' 2335 '#include "foo.h"\n'
2415 '\n' 2336 '\n'
2416 '#include "bar.h"\n', 2337 '#include "bar.h"\n',
2417 '') 2338 '')
2418 2339
2419 os.path.isfile = self.os_path_isfile_orig 2340 os.path.isfile = self.os_path_isfile_orig
2420 2341
2421 def test_public_primary_header(self):
2422 # System header is not considered a primary header.
2423 self.assert_language_rules_check('foo.cpp',
2424 '#include "config.h"\n'
2425 '#include <other/foo.h>\n'
2426 '\n'
2427 '#include "a.h"\n',
2428 'Alphabetical sorting problem. [build/ include_order] [4]')
2429
2430 # ...except that it starts with public/.
2431 self.assert_language_rules_check('foo.cpp',
2432 '#include <public/foo.h>\n'
2433 '\n'
2434 '#include "a.h"\n',
2435 '')
2436
2437 # Even if it starts with public/ its base part must match with the sourc e file name.
2438 self.assert_language_rules_check('foo.cpp',
2439 '#include "config.h"\n'
2440 '#include <public/foop.h>\n'
2441 '\n'
2442 '#include "a.h"\n',
2443 'Alphabetical sorting problem. [build/ include_order] [4]')
2444
2445 def test_check_wtf_includes(self): 2342 def test_check_wtf_includes(self):
2446 self.assert_language_rules_check('foo.cpp', 2343 self.assert_language_rules_check('foo.cpp',
2447 '#include "foo.h"\n' 2344 '#include "foo.h"\n'
2448 '\n' 2345 '\n'
2449 '#include <wtf/Assertions.h>\n', 2346 '#include <wtf/Assertions.h>\n',
2450 'wtf includes should be "wtf/file.h" in stead of <wtf/file.h>.' 2347 'wtf includes should be "wtf/file.h" in stead of <wtf/file.h>.'
2451 ' [build/include] [4]') 2348 ' [build/include] [4]')
2452 self.assert_language_rules_check('foo.cpp', 2349 self.assert_language_rules_check('foo.cpp',
2453 '#include "foo.h"\n' 2350 '#include "foo.h"\n'
2454 '\n' 2351 '\n'
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after
4256 def test_ne(self): 4153 def test_ne(self):
4257 """Test __ne__ inequality function.""" 4154 """Test __ne__ inequality function."""
4258 checker1 = self._checker() 4155 checker1 = self._checker()
4259 checker2 = self._checker() 4156 checker2 = self._checker()
4260 4157
4261 # != calls __ne__. 4158 # != calls __ne__.
4262 # By default, __ne__ always returns true on different objects. 4159 # By default, __ne__ always returns true on different objects.
4263 # Thus, just check the distinguishing case to verify that the 4160 # Thus, just check the distinguishing case to verify that the
4264 # code defines __ne__. 4161 # code defines __ne__.
4265 self.assertFalse(checker1 != checker2) 4162 self.assertFalse(checker1 != checker2)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698