| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Makes sure that files include headers from allowed directories. | 6 """Makes sure that files include headers from allowed directories. |
| 7 | 7 |
| 8 Checks DEPS files in the source tree for rules, and applies those rules to | 8 Checks DEPS files in the source tree for rules, and applies those rules to |
| 9 "#include" commands in source files. Any source file including something not | 9 "#include" commands in source files. Any source file including something not |
| 10 permitted by the DEPS files will fail. | 10 permitted by the DEPS files will fail. |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 277 |
| 278 def ShouldCheckFile(file_name): | 278 def ShouldCheckFile(file_name): |
| 279 """Returns True if the given file is a type we want to check.""" | 279 """Returns True if the given file is a type we want to check.""" |
| 280 checked_extensions = [ | 280 checked_extensions = [ |
| 281 '.h', | 281 '.h', |
| 282 '.cc', | 282 '.cc', |
| 283 '.m', | 283 '.m', |
| 284 '.mm', | 284 '.mm', |
| 285 ] | 285 ] |
| 286 basename, extension = os.path.splitext(file_name) | 286 basename, extension = os.path.splitext(file_name) |
| 287 return extension in checked_extensions | 287 return extension in checked_extensions or basename.find('test') != -1 |
| 288 | 288 |
| 289 | 289 |
| 290 def CheckLine(rules, line): | 290 def CheckLine(rules, line): |
| 291 """Checks the given file with the given rule set. If the line is an #include | 291 """Checks the given file with the given rule set. If the line is an #include |
| 292 directive and is illegal, a string describing the error will be returned. | 292 directive and is illegal, a string describing the error will be returned. |
| 293 Otherwise, None will be returned.""" | 293 Otherwise, None will be returned.""" |
| 294 found_item = EXTRACT_INCLUDE_PATH.match(line) | 294 found_item = EXTRACT_INCLUDE_PATH.match(line) |
| 295 if not found_item: | 295 if not found_item: |
| 296 return None # Not a match | 296 return None # Not a match |
| 297 | 297 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 if '__main__' == __name__: | 488 if '__main__' == __name__: |
| 489 option_parser = optparse.OptionParser() | 489 option_parser = optparse.OptionParser() |
| 490 option_parser.add_option("", "--root", default="", dest="base_directory", | 490 option_parser.add_option("", "--root", default="", dest="base_directory", |
| 491 help='Specifies the repository root. This defaults ' | 491 help='Specifies the repository root. This defaults ' |
| 492 'to "../../.." relative to the script file, which ' | 492 'to "../../.." relative to the script file, which ' |
| 493 'will normally be the repository root.') | 493 'will normally be the repository root.') |
| 494 option_parser.add_option("-v", "--verbose", action="store_true", | 494 option_parser.add_option("-v", "--verbose", action="store_true", |
| 495 default=False, help="Print debug logging") | 495 default=False, help="Print debug logging") |
| 496 options, args = option_parser.parse_args() | 496 options, args = option_parser.parse_args() |
| 497 main(options, args) | 497 main(options, args) |
| OLD | NEW |