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

Side by Side Diff: Tools/Scripts/webkitpy/bindings/main.py

Issue 24053003: Support partial interface for test support idls (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: patch Created 7 years, 2 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 # Copyright (C) 2011 Google Inc. All rights reserved. 1 # Copyright (C) 2011 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions 4 # modification, are permitted provided that the following conditions
5 # are met: 5 # are met:
6 # 1. Redistributions of source code must retain the above copyright 6 # 1. Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright 8 # 2. Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the 9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution. 10 # documentation and/or other materials provided with the distribution.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 'TestNode.idl', 46 'TestNode.idl',
47 'TestObject.idl', 47 'TestObject.idl',
48 'TestOverloadedConstructors.idl', 48 'TestOverloadedConstructors.idl',
49 'TestPartialInterface.idl', 49 'TestPartialInterface.idl',
50 'TestSerializedScriptValueInterface.idl', 50 'TestSerializedScriptValueInterface.idl',
51 'TestTypedArray.idl', 51 'TestTypedArray.idl',
52 'TestTypedefs.idl', 52 'TestTypedefs.idl',
53 ]) 53 ])
54 54
55 input_directory = os.path.join('bindings', 'tests', 'idls') 55 input_directory = os.path.join('bindings', 'tests', 'idls')
56 support_input_directory = os.path.join('bindings', 'tests', 'idls', 'testing')
56 reference_directory = os.path.join('bindings', 'tests', 'results') 57 reference_directory = os.path.join('bindings', 'tests', 'results')
57 reference_event_names_filename = os.path.join(reference_directory, 'EventInterfa ces.in') 58 reference_event_names_filename = os.path.join(reference_directory, 'EventInterfa ces.in')
58 59
59 60
60 class ScopedTempFileProvider(object): 61 class ScopedTempFileProvider(object):
61 def __init__(self): 62 def __init__(self):
62 self.files = [] 63 self.files = []
63 self.directories = [] 64 self.directories = []
64 65
65 def __del__(self): 66 def __del__(self):
(...skipping 14 matching lines...) Expand all
80 81
81 provider = ScopedTempFileProvider() 82 provider = ScopedTempFileProvider()
82 83
83 84
84 class BindingsTests(object): 85 class BindingsTests(object):
85 def __init__(self, reset_results, test_python, executive): 86 def __init__(self, reset_results, test_python, executive):
86 self.reset_results = reset_results 87 self.reset_results = reset_results
87 self.test_python = test_python 88 self.test_python = test_python
88 self.executive = executive 89 self.executive = executive
89 _, self.interface_dependencies_filename = provider.newtempfile() 90 _, self.interface_dependencies_filename = provider.newtempfile()
91 _, self.derived_sources_list_filename = provider.newtempfile()
90 if reset_results: 92 if reset_results:
91 self.event_names_filename = os.path.join(reference_directory, 'Event Interfaces.in') 93 self.event_names_filename = os.path.join(reference_directory, 'Event Interfaces.in')
92 else: 94 else:
93 _, self.event_names_filename = provider.newtempfile() 95 _, self.event_names_filename = provider.newtempfile()
94 96
95 def run_command(self, cmd): 97 def run_command(self, cmd):
96 return self.executive.run_command(cmd) 98 return self.executive.run_command(cmd)
97 99
98 def generate_from_idl_pl(self, idl_file, output_directory): 100 def generate_from_idl_pl(self, idl_file, output_directory):
99 cmd = ['perl', '-w', 101 cmd = ['perl', '-w',
(...skipping 28 matching lines...) Expand all
128 try: 130 try:
129 output = self.run_command(cmd) 131 output = self.run_command(cmd)
130 except ScriptError, e: 132 except ScriptError, e:
131 print e.output 133 print e.output
132 return e.exit_code 134 return e.exit_code
133 if output: 135 if output:
134 print output 136 print output
135 return 0 137 return 0
136 138
137 def generate_interface_dependencies(self): 139 def generate_interface_dependencies(self):
138 idl_files_list_file, idl_files_list_filename = provider.newtempfile() 140 idl_files_list_file, main_idl_files_list_filename = provider.newtempfile ()
139 idl_paths = [os.path.join(input_directory, input_file) 141 idl_paths = [os.path.join(input_directory, input_file)
140 for input_file in os.listdir(input_directory) 142 for input_file in os.listdir(input_directory)
141 if input_file.endswith('.idl')] 143 if input_file.endswith('.idl')]
142 idl_files_list_contents = ''.join(idl_path + '\n' 144 idl_files_list_contents = ''.join(idl_path + '\n'
143 for idl_path in idl_paths) 145 for idl_path in idl_paths)
144 os.write(idl_files_list_file, idl_files_list_contents) 146 os.write(idl_files_list_file, idl_files_list_contents)
147 support_idl_files_list_file, support_idl_files_list_filename = provider. newtempfile()
148 idl_paths = [os.path.join(support_input_directory, input_file)
Nils Barth (inactive) 2013/10/08 02:11:18 Could you call this 'support_idl_paths'? (Prefer s
kihong 2013/10/10 04:33:57 Done.
149 for input_file in os.listdir(support_input_directory)
150 if input_file.endswith('.idl')]
151 idl_files_list_contents = ''.join(idl_path + '\n'
Nils Barth (inactive) 2013/10/08 02:11:18 ...and this 'support_idl_files_list_contents'?
kihong 2013/10/10 04:33:57 Done.
152 for idl_path in idl_paths)
153 os.write(support_idl_files_list_file, idl_files_list_contents)
145 154
146 # Dummy files, required by compute_dependencies but not checked 155 # Dummy files, required by compute_dependencies but not checked
147 _, window_constructors_file = provider.newtempfile() 156 _, window_constructors_file = provider.newtempfile()
148 _, workerglobalscope_constructors_file = provider.newtempfile() 157 _, workerglobalscope_constructors_file = provider.newtempfile()
149 _, sharedworkerglobalscope_constructors_file = provider.newtempfile() 158 _, sharedworkerglobalscope_constructors_file = provider.newtempfile()
150 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile() 159 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile()
151 cmd = ['python', 160 cmd = ['python',
152 'bindings/scripts/compute_dependencies.py', 161 'bindings/scripts/compute_dependencies.py',
153 '--idl-files-list', idl_files_list_filename, 162 '--main-idl-files-list', main_idl_files_list_filename,
163 '--support-idl-files-list', support_idl_files_list_filename,
154 '--interface-dependencies-file', self.interface_dependencies_file name, 164 '--interface-dependencies-file', self.interface_dependencies_file name,
165 '--bindings-derived-sources-file', self.derived_sources_list_file name,
155 '--window-constructors-file', window_constructors_file, 166 '--window-constructors-file', window_constructors_file,
156 '--workerglobalscope-constructors-file', workerglobalscope_constr uctors_file, 167 '--workerglobalscope-constructors-file', workerglobalscope_constr uctors_file,
157 '--sharedworkerglobalscope-constructors-file', sharedworkerglobal scope_constructors_file, 168 '--sharedworkerglobalscope-constructors-file', sharedworkerglobal scope_constructors_file,
158 '--dedicatedworkerglobalscope-constructors-file', dedicatedworker globalscope_constructors_file, 169 '--dedicatedworkerglobalscope-constructors-file', dedicatedworker globalscope_constructors_file,
159 '--event-names-file', self.event_names_filename, 170 '--event-names-file', self.event_names_filename,
160 '--write-file-only-if-changed', '0'] 171 '--write-file-only-if-changed', '0']
161 172
162 if self.reset_results: 173 if self.reset_results:
163 print 'Reset results: EventInterfaces.in' 174 print 'Reset results: EventInterfaces.in'
164 try: 175 try:
(...skipping 28 matching lines...) Expand all
193 def identical_output_directory(self, work_directory): 204 def identical_output_directory(self, work_directory):
194 file_pairs = [(os.path.join(reference_directory, output_file), 205 file_pairs = [(os.path.join(reference_directory, output_file),
195 os.path.join(work_directory, output_file)) 206 os.path.join(work_directory, output_file))
196 for output_file in os.listdir(work_directory) 207 for output_file in os.listdir(work_directory)
197 # FIXME: add option to compiler to not generate tables 208 # FIXME: add option to compiler to not generate tables
198 if output_file != 'parsetab.py'] 209 if output_file != 'parsetab.py']
199 return all([self.identical_file(reference_filename, work_filename) 210 return all([self.identical_file(reference_filename, work_filename)
200 for (reference_filename, work_filename) in file_pairs]) 211 for (reference_filename, work_filename) in file_pairs])
201 212
202 def run_tests(self): 213 def run_tests(self):
203 def generate_and_check_output_pl(idl_filename): 214 def generate_and_check_output_pl(idl_filename, directory):
204 # Generate output into the reference directory if resetting 215 # Generate output into the reference directory if resetting
205 # results, or a temp directory if not. 216 # results, or a temp directory if not.
206 if self.reset_results: 217 if self.reset_results:
207 work_directory = reference_directory 218 work_directory = reference_directory
208 else: 219 else:
209 work_directory = provider.newtempdir() 220 work_directory = provider.newtempdir()
210 idl_path = os.path.join(input_directory, idl_filename) 221 idl_path = os.path.join(directory, idl_filename)
211 if self.generate_from_idl_pl(idl_path, work_directory): 222 if self.generate_from_idl_pl(idl_path, work_directory):
212 return False 223 return False
213 if self.reset_results: 224 if self.reset_results:
214 print 'Reset results: %s' % input_file 225 print 'Reset results: %s' % input_file
215 return True 226 return True
216 return self.identical_output_directory(work_directory) 227 return self.identical_output_directory(work_directory)
217 228
218 def generate_and_check_output_py(idl_filename): 229 def generate_and_check_output_py(idl_filename):
219 if idl_filename in SKIP_PYTHON: 230 if idl_filename in SKIP_PYTHON:
220 print 'SKIP: %s' % idl_filename 231 print 'SKIP: %s' % idl_filename
221 return True 232 return True
222 work_directory = provider.newtempdir() 233 work_directory = provider.newtempdir()
223 idl_path = os.path.join(input_directory, idl_filename) 234 idl_path = os.path.join(input_directory, idl_filename)
224 if self.generate_from_idl_py(idl_path, work_directory): 235 if self.generate_from_idl_py(idl_path, work_directory):
225 return False 236 return False
226 # Detect changes 237 # Detect changes
227 return self.identical_output_directory(work_directory) 238 return self.identical_output_directory(work_directory)
228 239
229 if self.reset_results: 240 if self.reset_results:
230 passed = True 241 passed = True
231 else: 242 else:
232 passed = self.identical_file(reference_event_names_filename, 243 passed = self.identical_file(reference_event_names_filename,
233 self.event_names_filename) 244 self.event_names_filename)
234 passed &= all([generate_and_check_output_pl(input_file) 245 for directory in [input_directory, support_input_directory]:
235 for input_file in os.listdir(input_directory) 246 passed &= all([generate_and_check_output_pl(input_file, directory)
236 if input_file.endswith('.idl')]) 247 for input_file in os.listdir(directory)
248 if input_file.endswith('.idl')])
237 print 249 print
238 if self.test_python: 250 if self.test_python:
239 print 'Python:' 251 print 'Python:'
240 passed &= all([generate_and_check_output_py(input_file) 252 passed &= all([generate_and_check_output_py(input_file)
241 for input_file in os.listdir(input_directory) 253 for input_file in os.listdir(input_directory)
242 if input_file.endswith('.idl')]) 254 if input_file.endswith('.idl')])
243 return passed 255 return passed
244 256
245 def main(self): 257 def main(self):
246 current_scm = detect_scm_system(os.curdir) 258 current_scm = detect_scm_system(os.curdir)
247 os.chdir(os.path.join(current_scm.checkout_root, 'Source')) 259 os.chdir(os.path.join(current_scm.checkout_root, 'Source'))
248 260
249 if self.generate_interface_dependencies(): 261 if self.generate_interface_dependencies():
250 print 'Failed to generate interface dependencies file.' 262 print 'Failed to generate interface dependencies file.'
251 return -1 263 return -1
252 264
253 all_tests_passed = self.run_tests() 265 all_tests_passed = self.run_tests()
254 print 266 print
255 if all_tests_passed: 267 if all_tests_passed:
256 print 'All tests PASS!' 268 print 'All tests PASS!'
257 return 0 269 return 0
258 print 'Some tests FAIL! (To update the reference files, execute "run-bin dings-tests --reset-results")' 270 print 'Some tests FAIL! (To update the reference files, execute "run-bin dings-tests --reset-results")'
259 return -1 271 return -1
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698