| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 def FindFilesIn(self, path): | 299 def FindFilesIn(self, path): |
| 300 if os.path.exists(path+'/.git'): | 300 if os.path.exists(path+'/.git'): |
| 301 output = subprocess.Popen('git ls-files --full-name', | 301 output = subprocess.Popen('git ls-files --full-name', |
| 302 stdout=PIPE, cwd=path, shell=True) | 302 stdout=PIPE, cwd=path, shell=True) |
| 303 result = [] | 303 result = [] |
| 304 for file in output.stdout.read().split(): | 304 for file in output.stdout.read().split(): |
| 305 for dir_part in os.path.dirname(file).replace(os.sep, '/').split('/'): | 305 for dir_part in os.path.dirname(file).replace(os.sep, '/').split('/'): |
| 306 if self.IgnoreDir(dir_part): | 306 if self.IgnoreDir(dir_part): |
| 307 break | 307 break |
| 308 else: | 308 else: |
| 309 if self.IsRelevant(file) and not self.IgnoreFile(file): | 309 if (self.IsRelevant(file) and os.path.exists(file) |
| 310 and not self.IgnoreFile(file)): |
| 310 result.append(join(path, file)) | 311 result.append(join(path, file)) |
| 311 if output.wait() == 0: | 312 if output.wait() == 0: |
| 312 return result | 313 return result |
| 313 return super(SourceProcessor, self).FindFilesIn(path) | 314 return super(SourceProcessor, self).FindFilesIn(path) |
| 314 | 315 |
| 315 def IsRelevant(self, name): | 316 def IsRelevant(self, name): |
| 316 for ext in SourceProcessor.RELEVANT_EXTENSIONS: | 317 for ext in SourceProcessor.RELEVANT_EXTENSIONS: |
| 317 if name.endswith(ext): | 318 if name.endswith(ext): |
| 318 return True | 319 return True |
| 319 return False | 320 return False |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 contents = handle.read() | 410 contents = handle.read() |
| 410 if not self.ProcessContents(file, contents): | 411 if not self.ProcessContents(file, contents): |
| 411 success = False | 412 success = False |
| 412 violations += 1 | 413 violations += 1 |
| 413 finally: | 414 finally: |
| 414 handle.close() | 415 handle.close() |
| 415 print "Total violating files: %s" % violations | 416 print "Total violating files: %s" % violations |
| 416 return success | 417 return success |
| 417 | 418 |
| 418 | 419 |
| 420 def CheckGeneratedRuntimeTests(workspace): |
| 421 code = subprocess.call( |
| 422 [sys.executable, join(workspace, "tools", "generate-runtime-tests.py"), |
| 423 "check"]) |
| 424 return code == 0 |
| 425 |
| 426 |
| 419 def GetOptions(): | 427 def GetOptions(): |
| 420 result = optparse.OptionParser() | 428 result = optparse.OptionParser() |
| 421 result.add_option('--no-lint', help="Do not run cpplint", default=False, | 429 result.add_option('--no-lint', help="Do not run cpplint", default=False, |
| 422 action="store_true") | 430 action="store_true") |
| 423 return result | 431 return result |
| 424 | 432 |
| 425 | 433 |
| 426 def Main(): | 434 def Main(): |
| 427 workspace = abspath(join(dirname(sys.argv[0]), '..')) | 435 workspace = abspath(join(dirname(sys.argv[0]), '..')) |
| 428 parser = GetOptions() | 436 parser = GetOptions() |
| 429 (options, args) = parser.parse_args() | 437 (options, args) = parser.parse_args() |
| 430 success = True | 438 success = True |
| 431 print "Running C++ lint check..." | 439 print "Running C++ lint check..." |
| 432 if not options.no_lint: | 440 if not options.no_lint: |
| 433 success = CppLintProcessor().Run(workspace) and success | 441 success = CppLintProcessor().Run(workspace) and success |
| 434 print "Running copyright header, trailing whitespaces and " \ | 442 print "Running copyright header, trailing whitespaces and " \ |
| 435 "two empty lines between declarations check..." | 443 "two empty lines between declarations check..." |
| 436 success = SourceProcessor().Run(workspace) and success | 444 success = SourceProcessor().Run(workspace) and success |
| 445 success = CheckGeneratedRuntimeTests(workspace) and success |
| 437 if success: | 446 if success: |
| 438 return 0 | 447 return 0 |
| 439 else: | 448 else: |
| 440 return 1 | 449 return 1 |
| 441 | 450 |
| 442 | 451 |
| 443 if __name__ == '__main__': | 452 if __name__ == '__main__': |
| 444 sys.exit(Main()) | 453 sys.exit(Main()) |
| OLD | NEW |