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

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

Issue 2627003003: Add --idl-methods <filepath> parameter for skipping renaming of IDL methods. (Closed)
Patch Set: Addressed remaining CR feedback from dcheng@. 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
« no previous file with comments | « tools/clang/rewrite_to_chrome_style/tests/run_tool.args ('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 # 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 5
6 """Test harness for chromium clang tools.""" 6 """Test harness for chromium clang tools."""
7 7
8 import difflib 8 import difflib
9 import glob 9 import glob
10 import json 10 import json
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 try: 49 try:
50 # Stage the test files in the git index. If they aren't staged, then 50 # Stage the test files in the git index. If they aren't staged, then
51 # run_tool.py will skip them when applying replacements. 51 # run_tool.py will skip them when applying replacements.
52 args = ['add'] 52 args = ['add']
53 args.extend(actual_files) 53 args.extend(actual_files)
54 _RunGit(args) 54 _RunGit(args)
55 55
56 # Launch the following pipeline: 56 # Launch the following pipeline:
57 # run_tool.py ... | extract_edits.py | apply_edits.py ... 57 # run_tool.py ... | extract_edits.py | apply_edits.py ...
58 args = ['python', 58 args = ['python',
59 os.path.join(tools_clang_scripts_directory, 'run_tool.py'), 59 os.path.join(tools_clang_scripts_directory, 'run_tool.py')]
60 extra_run_tool_args_path = os.path.join(test_directory_for_tool,
61 "run_tool.args")
62 if os.path.exists(extra_run_tool_args_path):
63 with open(extra_run_tool_args_path, 'r') as extra_run_tool_args_file:
64 extra_run_tool_args = extra_run_tool_args_file.readlines()
65 args.extend([arg.strip() for arg in extra_run_tool_args])
66 args.extend([
60 tool_to_test, 67 tool_to_test,
61 test_directory_for_tool] 68 test_directory_for_tool])
69
62 args.extend(actual_files) 70 args.extend(actual_files)
63 run_tool = subprocess.Popen(args, stdout=subprocess.PIPE) 71 run_tool = subprocess.Popen(args, stdout=subprocess.PIPE)
64 72
65 args = ['python', 73 args = ['python',
66 os.path.join(tools_clang_scripts_directory, 'extract_edits.py')] 74 os.path.join(tools_clang_scripts_directory, 'extract_edits.py')]
67 extract_edits = subprocess.Popen(args, stdin=run_tool.stdout, 75 extract_edits = subprocess.Popen(args, stdin=run_tool.stdout,
68 stdout=subprocess.PIPE) 76 stdout=subprocess.PIPE)
69 77
70 args = ['python', 78 args = ['python',
71 os.path.join(tools_clang_scripts_directory, 'apply_edits.py'), 79 os.path.join(tools_clang_scripts_directory, 'apply_edits.py'),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return 1 143 return 1
136 144
137 # Set up the test environment. 145 # Set up the test environment.
138 for source, actual in zip(source_files, actual_files): 146 for source, actual in zip(source_files, actual_files):
139 shutil.copyfile(source, actual) 147 shutil.copyfile(source, actual)
140 # Generate a temporary compilation database to run the tool over. 148 # Generate a temporary compilation database to run the tool over.
141 with open(compile_database, 'w') as f: 149 with open(compile_database, 'w') as f:
142 f.write(_GenerateCompileCommands(actual_files, include_paths)) 150 f.write(_GenerateCompileCommands(actual_files, include_paths))
143 151
144 # Run the tool. 152 # Run the tool.
153 os.chdir(test_directory_for_tool)
145 exitcode = _RunToolAndApplyEdits(tools_clang_scripts_directory, tool_to_test, 154 exitcode = _RunToolAndApplyEdits(tools_clang_scripts_directory, tool_to_test,
146 test_directory_for_tool, actual_files) 155 test_directory_for_tool, actual_files)
147 if (exitcode != 0): 156 if (exitcode != 0):
148 return exitcode 157 return exitcode
149 158
150 # Compare actual-vs-expected results. 159 # Compare actual-vs-expected results.
151 passed = 0 160 passed = 0
152 failed = 0 161 failed = 0
153 for expected, actual in zip(expected_files, actual_files): 162 for expected, actual in zip(expected_files, actual_files):
154 print '[ RUN ] %s' % os.path.relpath(actual) 163 print '[ RUN ] %s' % os.path.relpath(actual)
(...skipping 22 matching lines...) Expand all
177 print '[==========] %s ran.' % _NumberOfTestsToString(len(source_files)) 186 print '[==========] %s ran.' % _NumberOfTestsToString(len(source_files))
178 if passed > 0: 187 if passed > 0:
179 print '[ PASSED ] %s.' % _NumberOfTestsToString(passed) 188 print '[ PASSED ] %s.' % _NumberOfTestsToString(passed)
180 if failed > 0: 189 if failed > 0:
181 print '[ FAILED ] %s.' % _NumberOfTestsToString(failed) 190 print '[ FAILED ] %s.' % _NumberOfTestsToString(failed)
182 return 1 191 return 1
183 192
184 193
185 if __name__ == '__main__': 194 if __name__ == '__main__':
186 sys.exit(main(sys.argv[1:])) 195 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « tools/clang/rewrite_to_chrome_style/tests/run_tool.args ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698