OLD | NEW |
---|---|
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 Loading... | |
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 testing_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 13 matching lines...) Expand all Loading... | |
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.binding_derived_sources_filename = provider.newtempfile() | |
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', |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 | 137 |
136 def generate_interface_dependencies(self): | 138 def generate_interface_dependencies(self): |
137 idl_files_list_file, idl_files_list_filename = provider.newtempfile() | 139 idl_files_list_file, idl_files_list_filename = provider.newtempfile() |
138 idl_paths = [os.path.join(input_directory, input_file) | 140 idl_paths = [os.path.join(input_directory, input_file) |
139 for input_file in os.listdir(input_directory) | 141 for input_file in os.listdir(input_directory) |
140 if input_file.endswith('.idl')] | 142 if input_file.endswith('.idl')] |
141 idl_files_list_contents = ''.join(idl_path + '\n' | 143 idl_files_list_contents = ''.join(idl_path + '\n' |
142 for idl_path in idl_paths) | 144 for idl_path in idl_paths) |
143 os.write(idl_files_list_file, idl_files_list_contents) | 145 os.write(idl_files_list_file, idl_files_list_contents) |
144 | 146 |
147 testing_idl_files_list_file, testing_idl_files_list_filename = provider. newtempfile() | |
148 testing_idl_paths = [os.path.join(testing_input_directory, input_file) | |
149 for input_file in os.listdir(testing_input_directory) | |
150 if input_file.endswith('.idl')] | |
151 idl_files_list_contents = ''.join(idl_path + '\n' | |
152 for idl_path in testing_idl_paths) | |
153 os.write(testing_idl_files_list_file, idl_files_list_contents) | |
154 | |
145 # Dummy files, required by compute_dependencies but not checked | 155 # Dummy files, required by compute_dependencies but not checked |
146 _, window_constructors_file = provider.newtempfile() | 156 _, window_constructors_file = provider.newtempfile() |
147 _, workerglobalscope_constructors_file = provider.newtempfile() | 157 _, workerglobalscope_constructors_file = provider.newtempfile() |
148 _, sharedworkerglobalscope_constructors_file = provider.newtempfile() | 158 _, sharedworkerglobalscope_constructors_file = provider.newtempfile() |
149 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile() | 159 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile() |
150 cmd = ['python', | 160 cmd = ['python', |
151 'bindings/scripts/compute_dependencies.py', | 161 'bindings/scripts/compute_dependencies.py', |
152 '--idl-files-list', idl_files_list_filename, | 162 '--idl-files-list', idl_files_list_filename, |
163 '--testing-idl-files-list', testing_idl_files_list_filename, | |
153 '--interface-dependencies-file', self.interface_dependencies_file name, | 164 '--interface-dependencies-file', self.interface_dependencies_file name, |
165 '--binding-derived-source-file', self.binding_derived_sources_fil ename, | |
154 '--window-constructors-file', window_constructors_file, | 166 '--window-constructors-file', window_constructors_file, |
155 '--workerglobalscope-constructors-file', workerglobalscope_constr uctors_file, | 167 '--workerglobalscope-constructors-file', workerglobalscope_constr uctors_file, |
156 '--sharedworkerglobalscope-constructors-file', sharedworkerglobal scope_constructors_file, | 168 '--sharedworkerglobalscope-constructors-file', sharedworkerglobal scope_constructors_file, |
157 '--dedicatedworkerglobalscope-constructors-file', dedicatedworker globalscope_constructors_file, | 169 '--dedicatedworkerglobalscope-constructors-file', dedicatedworker globalscope_constructors_file, |
158 '--event-names-file', self.event_names_filename, | 170 '--event-names-file', self.event_names_filename, |
159 '--write-file-only-if-changed', '0'] | 171 '--write-file-only-if-changed', '0'] |
160 | 172 |
161 if self.reset_results: | 173 if self.reset_results: |
162 print 'Reset results: EventInterfaces.in' | 174 print 'Reset results: EventInterfaces.in' |
163 try: | 175 try: |
(...skipping 28 matching lines...) Expand all Loading... | |
192 def identical_output_directory(self, work_directory): | 204 def identical_output_directory(self, work_directory): |
193 file_pairs = [(os.path.join(reference_directory, output_file), | 205 file_pairs = [(os.path.join(reference_directory, output_file), |
194 os.path.join(work_directory, output_file)) | 206 os.path.join(work_directory, output_file)) |
195 for output_file in os.listdir(work_directory) | 207 for output_file in os.listdir(work_directory) |
196 # FIXME: add option to compiler to not generate tables | 208 # FIXME: add option to compiler to not generate tables |
197 if output_file != 'parsetab.py'] | 209 if output_file != 'parsetab.py'] |
198 return all([self.identical_file(reference_filename, work_filename) | 210 return all([self.identical_file(reference_filename, work_filename) |
199 for (reference_filename, work_filename) in file_pairs]) | 211 for (reference_filename, work_filename) in file_pairs]) |
200 | 212 |
201 def run_tests(self): | 213 def run_tests(self): |
202 def generate_and_check_output_pl(idl_filename): | 214 def generate_and_check_output_pl(idl_filename, input_directory): |
203 # Generate output into the reference directory if resetting | 215 # Generate output into the reference directory if resetting |
204 # results, or a temp directory if not. | 216 # results, or a temp directory if not. |
205 if self.reset_results: | 217 if self.reset_results: |
206 work_directory = reference_directory | 218 work_directory = reference_directory |
207 else: | 219 else: |
208 work_directory = provider.newtempdir() | 220 work_directory = provider.newtempdir() |
209 idl_path = os.path.join(input_directory, idl_filename) | 221 idl_path = os.path.join(input_directory, idl_filename) |
210 if self.generate_from_idl_pl(idl_path, work_directory): | 222 if self.generate_from_idl_pl(idl_path, work_directory): |
211 return False | 223 return False |
212 if self.reset_results: | 224 if self.reset_results: |
(...skipping 10 matching lines...) Expand all Loading... | |
223 if self.generate_from_idl_py(idl_path, work_directory): | 235 if self.generate_from_idl_py(idl_path, work_directory): |
224 return False | 236 return False |
225 # Detect changes | 237 # Detect changes |
226 return self.identical_output_directory(work_directory) | 238 return self.identical_output_directory(work_directory) |
227 | 239 |
228 if self.reset_results: | 240 if self.reset_results: |
229 passed = True | 241 passed = True |
230 else: | 242 else: |
231 passed = self.identical_file(reference_event_names_filename, | 243 passed = self.identical_file(reference_event_names_filename, |
232 self.event_names_filename) | 244 self.event_names_filename) |
233 passed &= all([generate_and_check_output_pl(input_file) | 245 passed &= all([generate_and_check_output_pl(input_file, input_directory) |
Nils Barth (inactive)
2013/09/17 02:23:35
Could you make this a quick loop?
for directory in
kihong
2013/10/04 06:11:38
Done.
| |
234 for input_file in os.listdir(input_directory) | 246 for input_file in os.listdir(input_directory) |
235 if input_file.endswith('.idl')]) | 247 if input_file.endswith('.idl')]) |
248 passed &= all([generate_and_check_output_pl(input_file, testing_input_di rectory) | |
249 for input_file in os.listdir(testing_input_directory) | |
250 if input_file.endswith('.idl')]) | |
236 print | 251 print |
237 print 'Python:' | 252 print 'Python:' |
238 passed &= all([generate_and_check_output_py(input_file) | 253 passed &= all([generate_and_check_output_py(input_file) |
239 for input_file in os.listdir(input_directory) | 254 for input_file in os.listdir(input_directory) |
240 if input_file.endswith('.idl')]) | 255 if input_file.endswith('.idl')]) |
241 return passed | 256 return passed |
242 | 257 |
243 def main(self): | 258 def main(self): |
244 current_scm = detect_scm_system(os.curdir) | 259 current_scm = detect_scm_system(os.curdir) |
245 os.chdir(os.path.join(current_scm.checkout_root, 'Source')) | 260 os.chdir(os.path.join(current_scm.checkout_root, 'Source')) |
246 | 261 |
247 if self.generate_interface_dependencies(): | 262 if self.generate_interface_dependencies(): |
248 print 'Failed to generate interface dependencies file.' | 263 print 'Failed to generate interface dependencies file.' |
249 return -1 | 264 return -1 |
250 | 265 |
251 all_tests_passed = self.run_tests() | 266 all_tests_passed = self.run_tests() |
252 print | 267 print |
253 if all_tests_passed: | 268 if all_tests_passed: |
254 print 'All tests PASS!' | 269 print 'All tests PASS!' |
255 return 0 | 270 return 0 |
256 print 'Some tests FAIL! (To update the reference files, execute "run-bin dings-tests --reset-results")' | 271 print 'Some tests FAIL! (To update the reference files, execute "run-bin dings-tests --reset-results")' |
257 return -1 | 272 return -1 |
OLD | NEW |