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

Side by Side Diff: presubmit_canned_checks.py

Issue 1181103002: Parallelize pylint PRESUBMIT checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | presubmit_support.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Generic presubmit checks that can be reused by other presubmit checks.""" 5 """Generic presubmit checks that can be reused by other presubmit checks."""
6 6
7 import os as _os 7 import os as _os
8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) 8 _HERE = _os.path.dirname(_os.path.abspath(__file__))
9 9
10 # Justifications for each filter: 10 # Justifications for each filter:
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 description = '%s files' % len(files) 781 description = '%s files' % len(files)
782 782
783 return input_api.Command( 783 return input_api.Command(
784 name='Pylint (%s)' % description, 784 name='Pylint (%s)' % description,
785 cmd=[input_api.python_executable, 785 cmd=[input_api.python_executable,
786 input_api.os_path.join(_HERE, 'third_party', 'pylint.py'), 786 input_api.os_path.join(_HERE, 'third_party', 'pylint.py'),
787 '--args-on-stdin'], 787 '--args-on-stdin'],
788 kwargs={'env': env, 'stdin': '\n'.join(files + extra_args)}, 788 kwargs={'env': env, 'stdin': '\n'.join(files + extra_args)},
789 message=error_type) 789 message=error_type)
790 790
791 # Always run pylint and pass it all the py files at once. 791 # Always run pylint and pass it all the (sharded) py files at once. Passing py
792 # Passing py files one at time is slower and can produce 792 # files one at time is slower and can produce different results.
793 # different results. input_api.verbose used to be used 793 # input_api.verbose used to be used to enable this behaviour but differing
794 # to enable this behaviour but differing behaviour in 794 # behaviour in verbose mode is not desirable.
795 # verbose mode is not desirable. 795 #
796 # Leave this unreachable code in here so users can make 796 # We shard the pylint invocations by the number of CPUs, since they tend to
797 # a quick local edit to diagnose pylint issues more 797 # saturate a CPU entirely (but never more than 100%, thanks to the GIL).
798 # easily.
799 if True: 798 if True:
800 return [GetPylintCmd(files)] 799 # number of files to allow in one command
800 limit = max(len(files) / input_api.cpu_count, 1)
801 ret = []
802 while files:
803 ret.append(GetPylintCmd(files[:limit]))
804 files = files[limit:]
nednguyen 2015/06/12 18:06:14 If we shard the files arbitrarily, how does this a
805 return ret
801 else: 806 else:
807 # Leave this unreachable code in here so users can make a quick local edit
808 # to diagnose pylint issues more easily.
802 return map(lambda x: GetPylintCmd([x]), files) 809 return map(lambda x: GetPylintCmd([x]), files)
803 810
804 811
805 def RunPylint(input_api, *args, **kwargs): 812 def RunPylint(input_api, *args, **kwargs):
806 """Legacy presubmit function. 813 """Legacy presubmit function.
807 814
808 For better performance, get all tests and then pass to 815 For better performance, get all tests and then pass to
809 input_api.RunTests. 816 input_api.RunTests.
810 """ 817 """
811 return input_api.RunTests(GetPylint(input_api, *args, **kwargs), False) 818 return input_api.RunTests(GetPylint(input_api, *args, **kwargs), False)
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 for f in affected_files: 1136 for f in affected_files:
1130 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] 1137 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()]
1131 rc = gn.main(cmd) 1138 rc = gn.main(cmd)
1132 if rc == 2: 1139 if rc == 2:
1133 warnings.append(output_api.PresubmitPromptWarning( 1140 warnings.append(output_api.PresubmitPromptWarning(
1134 '%s requires formatting. Please run `gn format --in-place %s`.' % ( 1141 '%s requires formatting. Please run `gn format --in-place %s`.' % (
1135 f.AbsoluteLocalPath(), f.LocalPath()))) 1142 f.AbsoluteLocalPath(), f.LocalPath())))
1136 # It's just a warning, so ignore other types of failures assuming they'll be 1143 # It's just a warning, so ignore other types of failures assuming they'll be
1137 # caught elsewhere. 1144 # caught elsewhere.
1138 return warnings 1145 return warnings
OLDNEW
« no previous file with comments | « no previous file | presubmit_support.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698