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

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: Created 7 years, 3 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 test_support_input_directory = os.path.join(input_directory, 'test_support')
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 13 matching lines...) Expand all
79 return path 80 return path
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, executive): 86 def __init__(self, reset_results, executive):
86 self.reset_results = reset_results 87 self.reset_results = reset_results
87 self.executive = executive 88 self.executive = executive
88 _, self.interface_dependencies_filename = provider.newtempfile() 89 _, self.interface_dependencies_filename = provider.newtempfile()
90 _, self.test_support_interface_dependencies_filename = provider.newtempf ile()
89 if reset_results: 91 if reset_results:
90 self.event_names_filename = os.path.join(reference_directory, 'Event Interfaces.in') 92 self.event_names_filename = os.path.join(reference_directory, 'Event Interfaces.in')
91 else: 93 else:
92 _, self.event_names_filename = provider.newtempfile() 94 _, self.event_names_filename = provider.newtempfile()
93 95
94 def run_command(self, cmd): 96 def run_command(self, cmd):
95 return self.executive.run_command(cmd) 97 return self.executive.run_command(cmd)
96 98
97 def generate_from_idl_pl(self, idl_file, output_directory): 99 def generate_from_idl_pl(self, idl_file, output_directory):
98 cmd = ['perl', '-w', 100 cmd = ['perl', '-w',
99 '-Ibindings/scripts', 101 '-Ibindings/scripts',
100 '-Icore/scripts', 102 '-Icore/scripts',
101 '-I../../JSON/out/lib/perl5', 103 '-I../../JSON/out/lib/perl5',
102 'bindings/scripts/deprecated_generate_bindings.pl', 104 'bindings/scripts/deprecated_generate_bindings.pl',
103 # idl include directories (path relative to generate-bindings.pl) 105 # idl include directories (path relative to generate-bindings.pl)
104 '--include', '.', 106 '--include', '.',
105 '--outputDir', output_directory, 107 '--outputDir', output_directory,
106 '--interfaceDependenciesFile', self.interface_dependencies_filena me, 108 '--interfaceDependenciesFile', self.interface_dependencies_filena me,
109 '--testSupportInterfaceDependenciesFile', self.test_support_inter face_dependencies_filename,
107 '--idlAttributesFile', 'bindings/scripts/IDLAttributes.txt', 110 '--idlAttributesFile', 'bindings/scripts/IDLAttributes.txt',
108 idl_file] 111 idl_file]
109 try: 112 try:
110 output = self.run_command(cmd) 113 output = self.run_command(cmd)
111 except ScriptError, e: 114 except ScriptError, e:
112 print e.output 115 print e.output
113 return e.exit_code 116 return e.exit_code
114 if output: 117 if output:
115 print output 118 print output
116 return 0 119 return 0
(...skipping 18 matching lines...) Expand all
135 138
136 def generate_interface_dependencies(self): 139 def generate_interface_dependencies(self):
137 idl_files_list_file, idl_files_list_filename = provider.newtempfile() 140 idl_files_list_file, idl_files_list_filename = provider.newtempfile()
138 idl_paths = [os.path.join(input_directory, input_file) 141 idl_paths = [os.path.join(input_directory, input_file)
139 for input_file in os.listdir(input_directory) 142 for input_file in os.listdir(input_directory)
140 if input_file.endswith('.idl')] 143 if input_file.endswith('.idl')]
141 idl_files_list_contents = ''.join(idl_path + '\n' 144 idl_files_list_contents = ''.join(idl_path + '\n'
142 for idl_path in idl_paths) 145 for idl_path in idl_paths)
143 os.write(idl_files_list_file, idl_files_list_contents) 146 os.write(idl_files_list_file, idl_files_list_contents)
144 147
148 test_support_idl_files_list_file, test_support_idl_files_list_filename = provider.newtempfile()
149 test_support_idl_paths = [os.path.join(test_support_input_directory, inp ut_file)
150 for input_file in os.listdir(test_support_input_directory)
151 if input_file.endswith('.idl')]
152 test_support_idl_files_list_contents = ''.join(test_support_idl_paths + '\n'
153 for test_support_idl_paths in test_sup port_idl_paths)
154 os.write(test_support_idl_files_list_file, test_support_idl_files_list_c ontents)
155
145 # Dummy files, required by compute_dependencies but not checked 156 # Dummy files, required by compute_dependencies but not checked
146 _, window_constructors_file = provider.newtempfile() 157 _, window_constructors_file = provider.newtempfile()
147 _, workerglobalscope_constructors_file = provider.newtempfile() 158 _, workerglobalscope_constructors_file = provider.newtempfile()
148 _, sharedworkerglobalscope_constructors_file = provider.newtempfile() 159 _, sharedworkerglobalscope_constructors_file = provider.newtempfile()
149 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile() 160 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile()
150 cmd = ['python', 161 cmd = ['python',
151 'bindings/scripts/compute_dependencies.py', 162 'bindings/scripts/compute_dependencies.py',
152 '--idl-files-list', idl_files_list_filename, 163 '--idl-files-list', idl_files_list_filename,
153 '--interface-dependencies-file', self.interface_dependencies_file name, 164 '--interface-dependencies-file', self.interface_dependencies_file name,
165 '--test-support-idl-files-list', test_support_idl_files_list_file name,
166 '--test-support-interface-dependencies-file', self.test_support_i nterface_dependencies_filename,
154 '--window-constructors-file', window_constructors_file, 167 '--window-constructors-file', window_constructors_file,
155 '--workerglobalscope-constructors-file', workerglobalscope_constr uctors_file, 168 '--workerglobalscope-constructors-file', workerglobalscope_constr uctors_file,
156 '--sharedworkerglobalscope-constructors-file', sharedworkerglobal scope_constructors_file, 169 '--sharedworkerglobalscope-constructors-file', sharedworkerglobal scope_constructors_file,
157 '--dedicatedworkerglobalscope-constructors-file', dedicatedworker globalscope_constructors_file, 170 '--dedicatedworkerglobalscope-constructors-file', dedicatedworker globalscope_constructors_file,
158 '--event-names-file', self.event_names_filename, 171 '--event-names-file', self.event_names_filename,
159 '--write-file-only-if-changed', '0'] 172 '--write-file-only-if-changed', '0']
160 173
161 if self.reset_results: 174 if self.reset_results:
162 print 'Reset results: EventInterfaces.in' 175 print 'Reset results: EventInterfaces.in'
163 try: 176 try:
(...skipping 28 matching lines...) Expand all
192 def identical_output_directory(self, work_directory): 205 def identical_output_directory(self, work_directory):
193 file_pairs = [(os.path.join(reference_directory, output_file), 206 file_pairs = [(os.path.join(reference_directory, output_file),
194 os.path.join(work_directory, output_file)) 207 os.path.join(work_directory, output_file))
195 for output_file in os.listdir(work_directory) 208 for output_file in os.listdir(work_directory)
196 # FIXME: add option to compiler to not generate tables 209 # FIXME: add option to compiler to not generate tables
197 if output_file != 'parsetab.py'] 210 if output_file != 'parsetab.py']
198 return all([self.identical_file(reference_filename, work_filename) 211 return all([self.identical_file(reference_filename, work_filename)
199 for (reference_filename, work_filename) in file_pairs]) 212 for (reference_filename, work_filename) in file_pairs])
200 213
201 def run_tests(self): 214 def run_tests(self):
202 def generate_and_check_output_pl(idl_filename): 215 def generate_and_check_output_pl(idl_filename, input_directory):
203 # Generate output into the reference directory if resetting 216 # Generate output into the reference directory if resetting
204 # results, or a temp directory if not. 217 # results, or a temp directory if not.
205 if self.reset_results: 218 if self.reset_results:
206 work_directory = reference_directory 219 work_directory = reference_directory
207 else: 220 else:
208 work_directory = provider.newtempdir() 221 work_directory = provider.newtempdir()
209 idl_path = os.path.join(input_directory, idl_filename) 222 idl_path = os.path.join(input_directory, idl_filename)
210 if self.generate_from_idl_pl(idl_path, work_directory): 223 if self.generate_from_idl_pl(idl_path, work_directory):
211 return False 224 return False
212 if self.reset_results: 225 if self.reset_results:
(...skipping 10 matching lines...) Expand all
223 if self.generate_from_idl_py(idl_path, work_directory): 236 if self.generate_from_idl_py(idl_path, work_directory):
224 return False 237 return False
225 # Detect changes 238 # Detect changes
226 return self.identical_output_directory(work_directory) 239 return self.identical_output_directory(work_directory)
227 240
228 if self.reset_results: 241 if self.reset_results:
229 passed = True 242 passed = True
230 else: 243 else:
231 passed = self.identical_file(reference_event_names_filename, 244 passed = self.identical_file(reference_event_names_filename,
232 self.event_names_filename) 245 self.event_names_filename)
233 passed &= all([generate_and_check_output_pl(input_file) 246 passed &= all([generate_and_check_output_pl(input_file, input_directory)
234 for input_file in os.listdir(input_directory) 247 for input_file in os.listdir(input_directory)
235 if input_file.endswith('.idl')]) 248 if input_file.endswith('.idl')])
249 passed &= all([generate_and_check_output_pl(input_file, test_support_inp ut_directory)
250 for input_file in os.listdir(test_support_input_directory )
251 if input_file.endswith('.idl')])
236 print 252 print
237 print 'Python:' 253 print 'Python:'
238 passed &= all([generate_and_check_output_py(input_file) 254 passed &= all([generate_and_check_output_py(input_file)
239 for input_file in os.listdir(input_directory) 255 for input_file in os.listdir(input_directory)
240 if input_file.endswith('.idl')]) 256 if input_file.endswith('.idl')])
241 return passed 257 return passed
242 258
243 def main(self): 259 def main(self):
244 current_scm = detect_scm_system(os.curdir) 260 current_scm = detect_scm_system(os.curdir)
245 os.chdir(os.path.join(current_scm.checkout_root, 'Source')) 261 os.chdir(os.path.join(current_scm.checkout_root, 'Source'))
246 262
247 if self.generate_interface_dependencies(): 263 if self.generate_interface_dependencies():
248 print 'Failed to generate interface dependencies file.' 264 print 'Failed to generate interface dependencies file.'
249 return -1 265 return -1
250 266
251 all_tests_passed = self.run_tests() 267 all_tests_passed = self.run_tests()
252 print 268 print
253 if all_tests_passed: 269 if all_tests_passed:
254 print 'All tests PASS!' 270 print 'All tests PASS!'
255 return 0 271 return 0
256 print 'Some tests FAIL! (To update the reference files, execute "run-bin dings-tests --reset-results")' 272 print 'Some tests FAIL! (To update the reference files, execute "run-bin dings-tests --reset-results")'
257 return -1 273 return -1
OLDNEW
« Source/bindings/scripts/compute_dependencies.py ('K') | « Source/core/core.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698