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

Side by Side Diff: tools/clang/scripts/run_tool.py

Issue 2609473002: Renaming blink method names inside gmock's EXPECT_CALL macro invocation. (Closed)
Patch Set: Using PPCallbacks::RecordExpectCallMacroInvocation. Created 3 years, 11 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 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 """Wrapper script to help run clang tools across Chromium code. 5 """Wrapper script to help run clang tools across Chromium code.
6 6
7 How to use run_tool.py: 7 How to use run_tool.py:
8 If you want to run a clang tool across all Chromium code: 8 If you want to run a clang tool across all Chromium code:
9 run_tool.py <tool> <path/to/compiledb> 9 run_tool.py <tool> <path/to/compiledb>
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 """ 115 """
116 args = [toolname, '-p', build_directory, filename] 116 args = [toolname, '-p', build_directory, filename]
117 if (tool_args): 117 if (tool_args):
118 args.extend(tool_args) 118 args.extend(tool_args)
119 command = subprocess.Popen( 119 command = subprocess.Popen(
120 args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 120 args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
121 stdout_text, stderr_text = command.communicate() 121 stdout_text, stderr_text = command.communicate()
122 if command.returncode != 0: 122 if command.returncode != 0:
123 return {'status': False, 'filename': filename, 'stderr_text': stderr_text} 123 return {'status': False, 'filename': filename, 'stderr_text': stderr_text}
124 else: 124 else:
125 return {'status': True, 'filename': filename, 'stdout_text': stdout_text} 125 return {'status': True, 'filename': filename, 'stdout_text': stdout_text,
126 'stderr_text': stderr_text}
126 127
127 128
128 class _CompilerDispatcher(object): 129 class _CompilerDispatcher(object):
129 """Multiprocessing controller for running clang tools in parallel.""" 130 """Multiprocessing controller for running clang tools in parallel."""
130 131
131 def __init__(self, toolname, tool_args, build_directory, filenames): 132 def __init__(self, toolname, tool_args, build_directory, filenames):
132 """Initializer method. 133 """Initializer method.
133 134
134 Args: 135 Args:
135 toolname: Path to the tool to execute. 136 toolname: Path to the tool to execute.
(...skipping 25 matching lines...) Expand all
161 162
162 def __ProcessResult(self, result): 163 def __ProcessResult(self, result):
163 """Handles result processing. 164 """Handles result processing.
164 165
165 Args: 166 Args:
166 result: The result dictionary returned by _ExecuteTool. 167 result: The result dictionary returned by _ExecuteTool.
167 """ 168 """
168 if result['status']: 169 if result['status']:
169 self.__success_count += 1 170 self.__success_count += 1
170 sys.stdout.write(result['stdout_text']) 171 sys.stdout.write(result['stdout_text'])
172 sys.stderr.write(result['stderr_text'])
Łukasz Anforowicz 2017/01/07 01:16:29 This is useful. I am too lazy to do this in a sep
171 else: 173 else:
172 self.__failed_count += 1 174 self.__failed_count += 1
173 sys.stderr.write('\nFailed to process %s\n' % result['filename']) 175 sys.stderr.write('\nFailed to process %s\n' % result['filename'])
174 sys.stderr.write(result['stderr_text']) 176 sys.stderr.write(result['stderr_text'])
175 sys.stderr.write('\n') 177 sys.stderr.write('\n')
176 done_count = self.__success_count + self.__failed_count 178 done_count = self.__success_count + self.__failed_count
177 percentage = (float(done_count) / len(self.__filenames)) * 100 179 percentage = (float(done_count) / len(self.__filenames)) * 100
178 sys.stderr.write( 180 sys.stderr.write(
179 'Processed %d files with %s tool (%d failures) [%.2f%%]\r' % 181 'Processed %d files with %s tool (%d failures) [%.2f%%]\r' %
180 (done_count, self.__toolname, self.__failed_count, percentage)) 182 (done_count, self.__toolname, self.__failed_count, percentage))
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 224
223 dispatcher = _CompilerDispatcher(args.tool, args.tool_args, 225 dispatcher = _CompilerDispatcher(args.tool, args.tool_args,
224 args.compile_database, 226 args.compile_database,
225 source_filenames) 227 source_filenames)
226 dispatcher.Run() 228 dispatcher.Run()
227 return -dispatcher.failed_count 229 return -dispatcher.failed_count
228 230
229 231
230 if __name__ == '__main__': 232 if __name__ == '__main__':
231 sys.exit(main()) 233 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698