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

Side by Side Diff: tools/presubmit.py

Issue 2553633002: [test] Only run presubmit for changed status files (Closed)
Patch Set: Rebase Created 4 years 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 | « PRESUBMIT.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 #!/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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 keys = {} 454 keys = {}
455 for key, value in pairs: 455 for key, value in pairs:
456 if key in keys: 456 if key in keys:
457 print("%s: Error: duplicate key %s" % (filepath, key)) 457 print("%s: Error: duplicate key %s" % (filepath, key))
458 status["success"] = False 458 status["success"] = False
459 keys[key] = True 459 keys[key] = True
460 460
461 json.loads(contents, object_pairs_hook=check_pairs) 461 json.loads(contents, object_pairs_hook=check_pairs)
462 return status["success"] 462 return status["success"]
463 463
464 def CheckStatusFiles(workspace): 464
465 success = True 465 class StatusFilesProcessor(SourceFileProcessor):
466 suite_paths = utils.GetSuitePaths(join(workspace, "test")) 466 """Checks status files for incorrect syntax and duplicate keys."""
467 for root in suite_paths: 467
468 suite_path = join(workspace, "test", root) 468 def IsRelevant(self, name):
469 status_file_path = join(suite_path, root + ".status") 469 return name.endswith('.status')
470 suite = testsuite.TestSuite.LoadTestSuite(suite_path) 470
471 if suite and exists(status_file_path): 471 def GetPathsToSearch(self):
472 return ['test']
473
474 def ProcessFiles(self, files):
475 success = True
476 for status_file_path in files:
472 success &= statusfile.PresubmitCheck(status_file_path) 477 success &= statusfile.PresubmitCheck(status_file_path)
473 success &= _CheckStatusFileForDuplicateKeys(status_file_path) 478 success &= _CheckStatusFileForDuplicateKeys(status_file_path)
474 return success 479 return success
480
475 481
476 def GetOptions(): 482 def GetOptions():
477 result = optparse.OptionParser() 483 result = optparse.OptionParser()
478 result.add_option('--no-lint', help="Do not run cpplint", default=False, 484 result.add_option('--no-lint', help="Do not run cpplint", default=False,
479 action="store_true") 485 action="store_true")
480 return result 486 return result
481 487
482 488
483 def Main(): 489 def Main():
484 workspace = abspath(join(dirname(sys.argv[0]), '..')) 490 workspace = abspath(join(dirname(sys.argv[0]), '..'))
485 parser = GetOptions() 491 parser = GetOptions()
486 (options, args) = parser.parse_args() 492 (options, args) = parser.parse_args()
487 success = True 493 success = True
488 print "Running C++ lint check..." 494 print "Running C++ lint check..."
489 if not options.no_lint: 495 if not options.no_lint:
490 success &= CppLintProcessor().RunOnPath(workspace) 496 success &= CppLintProcessor().RunOnPath(workspace)
491 print "Running copyright header, trailing whitespaces and " \ 497 print "Running copyright header, trailing whitespaces and " \
492 "two empty lines between declarations check..." 498 "two empty lines between declarations check..."
493 success &= SourceProcessor().RunOnPath(workspace) 499 success &= SourceProcessor().RunOnPath(workspace)
494 success &= CheckStatusFiles(workspace) 500 print "Running status-files check..."
501 success &= StatusFilesProcessor().RunOnPath(workspace)
495 if success: 502 if success:
496 return 0 503 return 0
497 else: 504 else:
498 return 1 505 return 1
499 506
500 507
501 if __name__ == '__main__': 508 if __name__ == '__main__':
502 sys.exit(Main()) 509 sys.exit(Main())
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698