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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 suite_paths = utils.GetSuitePaths(join(workspace, "test")) | 466 suite_paths = utils.GetSuitePaths(join(workspace, "test")) |
467 for root in suite_paths: | 467 for root in suite_paths: |
468 suite_path = join(workspace, "test", root) | 468 suite_path = join(workspace, "test", root) |
469 status_file_path = join(suite_path, root + ".status") | 469 status_file_path = join(suite_path, root + ".status") |
470 suite = testsuite.TestSuite.LoadTestSuite(suite_path) | 470 suite = testsuite.TestSuite.LoadTestSuite(suite_path) |
471 if suite and exists(status_file_path): | 471 if suite and exists(status_file_path): |
472 success &= statusfile.PresubmitCheck(status_file_path) | 472 success &= statusfile.PresubmitCheck(status_file_path) |
473 success &= _CheckStatusFileForDuplicateKeys(status_file_path) | 473 success &= _CheckStatusFileForDuplicateKeys(status_file_path) |
474 return success | 474 return success |
475 | 475 |
476 def CheckAuthorizedAuthor(input_api, output_api): | |
477 """For non-googler/chromites committers, verify the author's email address is | |
478 in AUTHORS. | |
479 """ | |
480 # TODO(maruel): Add it to input_api? | |
481 import fnmatch | |
482 | |
483 author = input_api.change.author_email | |
484 if not author: | |
485 input_api.logging.info('No author, skipping AUTHOR check') | |
486 return [] | |
487 authors_path = input_api.os_path.join( | |
488 input_api.PresubmitLocalPath(), 'AUTHORS') | |
489 valid_authors = ( | |
490 input_api.re.match(r'[^#]+\s+\<(.+?)\>\s*$', line) | |
491 for line in open(authors_path)) | |
492 valid_authors = [item.group(1).lower() for item in valid_authors if item] | |
493 if not any(fnmatch.fnmatch(author.lower(), valid) for valid in valid_authors): | |
494 input_api.logging.info('Valid authors are %s', ', '.join(valid_authors)) | |
495 return [output_api.PresubmitPromptWarning( | |
496 ('%s is not in AUTHORS file. If you are a new contributor, please visit' | |
497 '\n' | |
498 'http://www.chromium.org/developers/contributing-code and read the ' | |
499 '"Legal" section\n' | |
500 'If you are a chromite, verify the contributor signed the CLA.') % | |
501 author)] | |
502 return [] | |
503 | |
504 def GetOptions(): | 476 def GetOptions(): |
505 result = optparse.OptionParser() | 477 result = optparse.OptionParser() |
506 result.add_option('--no-lint', help="Do not run cpplint", default=False, | 478 result.add_option('--no-lint', help="Do not run cpplint", default=False, |
507 action="store_true") | 479 action="store_true") |
508 return result | 480 return result |
509 | 481 |
510 | 482 |
511 def Main(): | 483 def Main(): |
512 workspace = abspath(join(dirname(sys.argv[0]), '..')) | 484 workspace = abspath(join(dirname(sys.argv[0]), '..')) |
513 parser = GetOptions() | 485 parser = GetOptions() |
514 (options, args) = parser.parse_args() | 486 (options, args) = parser.parse_args() |
515 success = True | 487 success = True |
516 print "Running C++ lint check..." | 488 print "Running C++ lint check..." |
517 if not options.no_lint: | 489 if not options.no_lint: |
518 success &= CppLintProcessor().RunOnPath(workspace) | 490 success &= CppLintProcessor().RunOnPath(workspace) |
519 print "Running copyright header, trailing whitespaces and " \ | 491 print "Running copyright header, trailing whitespaces and " \ |
520 "two empty lines between declarations check..." | 492 "two empty lines between declarations check..." |
521 success &= SourceProcessor().RunOnPath(workspace) | 493 success &= SourceProcessor().RunOnPath(workspace) |
522 success &= CheckStatusFiles(workspace) | 494 success &= CheckStatusFiles(workspace) |
523 if success: | 495 if success: |
524 return 0 | 496 return 0 |
525 else: | 497 else: |
526 return 1 | 498 return 1 |
527 | 499 |
528 | 500 |
529 if __name__ == '__main__': | 501 if __name__ == '__main__': |
530 sys.exit(Main()) | 502 sys.exit(Main()) |
OLD | NEW |