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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 print output | 134 print output |
134 return 0 | 135 return 0 |
135 | 136 |
136 def generate_interface_dependencies(self): | 137 def generate_interface_dependencies(self): |
137 idl_files_list_file, idl_files_list_filename = provider.newtempfile() | 138 idl_files_list_file, idl_files_list_filename = provider.newtempfile() |
138 idl_paths = [os.path.join(input_directory, input_file) | 139 idl_paths = [os.path.join(input_directory, input_file) |
139 for input_file in os.listdir(input_directory) | 140 for input_file in os.listdir(input_directory) |
140 if input_file.endswith('.idl')] | 141 if input_file.endswith('.idl')] |
141 idl_files_list_contents = ''.join(idl_path + '\n' | 142 idl_files_list_contents = ''.join(idl_path + '\n' |
142 for idl_path in idl_paths) | 143 for idl_path in idl_paths) |
| 144 testing_idl_paths = [os.path.join(testing_input_directory, input_file) |
| 145 for input_file in os.listdir(testing_input_directory) |
| 146 if input_file.endswith('.idl')] |
| 147 idl_files_list_contents = idl_files_list_contents.join(idl_path + '\n' |
| 148 for idl_path in testing_idl_paths) |
143 os.write(idl_files_list_file, idl_files_list_contents) | 149 os.write(idl_files_list_file, idl_files_list_contents) |
144 | 150 |
145 # Dummy files, required by compute_dependencies but not checked | 151 # Dummy files, required by compute_dependencies but not checked |
146 _, window_constructors_file = provider.newtempfile() | 152 _, window_constructors_file = provider.newtempfile() |
147 _, workerglobalscope_constructors_file = provider.newtempfile() | 153 _, workerglobalscope_constructors_file = provider.newtempfile() |
148 _, sharedworkerglobalscope_constructors_file = provider.newtempfile() | 154 _, sharedworkerglobalscope_constructors_file = provider.newtempfile() |
149 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile() | 155 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile() |
150 cmd = ['python', | 156 cmd = ['python', |
151 'bindings/scripts/compute_dependencies.py', | 157 'bindings/scripts/compute_dependencies.py', |
152 '--idl-files-list', idl_files_list_filename, | 158 '--idl-files-list', idl_files_list_filename, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 def identical_output_directory(self, work_directory): | 198 def identical_output_directory(self, work_directory): |
193 file_pairs = [(os.path.join(reference_directory, output_file), | 199 file_pairs = [(os.path.join(reference_directory, output_file), |
194 os.path.join(work_directory, output_file)) | 200 os.path.join(work_directory, output_file)) |
195 for output_file in os.listdir(work_directory) | 201 for output_file in os.listdir(work_directory) |
196 # FIXME: add option to compiler to not generate tables | 202 # FIXME: add option to compiler to not generate tables |
197 if output_file != 'parsetab.py'] | 203 if output_file != 'parsetab.py'] |
198 return all([self.identical_file(reference_filename, work_filename) | 204 return all([self.identical_file(reference_filename, work_filename) |
199 for (reference_filename, work_filename) in file_pairs]) | 205 for (reference_filename, work_filename) in file_pairs]) |
200 | 206 |
201 def run_tests(self): | 207 def run_tests(self): |
202 def generate_and_check_output_pl(idl_filename): | 208 def generate_and_check_output_pl(idl_filename, input_directory): |
203 # Generate output into the reference directory if resetting | 209 # Generate output into the reference directory if resetting |
204 # results, or a temp directory if not. | 210 # results, or a temp directory if not. |
205 if self.reset_results: | 211 if self.reset_results: |
206 work_directory = reference_directory | 212 work_directory = reference_directory |
207 else: | 213 else: |
208 work_directory = provider.newtempdir() | 214 work_directory = provider.newtempdir() |
209 idl_path = os.path.join(input_directory, idl_filename) | 215 idl_path = os.path.join(input_directory, idl_filename) |
210 if self.generate_from_idl_pl(idl_path, work_directory): | 216 if self.generate_from_idl_pl(idl_path, work_directory): |
211 return False | 217 return False |
212 if self.reset_results: | 218 if self.reset_results: |
(...skipping 10 matching lines...) Expand all Loading... |
223 if self.generate_from_idl_py(idl_path, work_directory): | 229 if self.generate_from_idl_py(idl_path, work_directory): |
224 return False | 230 return False |
225 # Detect changes | 231 # Detect changes |
226 return self.identical_output_directory(work_directory) | 232 return self.identical_output_directory(work_directory) |
227 | 233 |
228 if self.reset_results: | 234 if self.reset_results: |
229 passed = True | 235 passed = True |
230 else: | 236 else: |
231 passed = self.identical_file(reference_event_names_filename, | 237 passed = self.identical_file(reference_event_names_filename, |
232 self.event_names_filename) | 238 self.event_names_filename) |
233 passed &= all([generate_and_check_output_pl(input_file) | 239 passed &= all([generate_and_check_output_pl(input_file, input_directory) |
234 for input_file in os.listdir(input_directory) | 240 for input_file in os.listdir(input_directory) |
235 if input_file.endswith('.idl')]) | 241 if input_file.endswith('.idl')]) |
| 242 passed &= all([generate_and_check_output_pl(input_file, testing_input_di
rectory) |
| 243 for input_file in os.listdir(testing_input_directory) |
| 244 if input_file.endswith('.idl')]) |
236 print | 245 print |
237 print 'Python:' | 246 print 'Python:' |
238 passed &= all([generate_and_check_output_py(input_file) | 247 passed &= all([generate_and_check_output_py(input_file) |
239 for input_file in os.listdir(input_directory) | 248 for input_file in os.listdir(input_directory) |
240 if input_file.endswith('.idl')]) | 249 if input_file.endswith('.idl')]) |
241 return passed | 250 return passed |
242 | 251 |
243 def main(self): | 252 def main(self): |
244 current_scm = detect_scm_system(os.curdir) | 253 current_scm = detect_scm_system(os.curdir) |
245 os.chdir(os.path.join(current_scm.checkout_root, 'Source')) | 254 os.chdir(os.path.join(current_scm.checkout_root, 'Source')) |
246 | 255 |
247 if self.generate_interface_dependencies(): | 256 if self.generate_interface_dependencies(): |
248 print 'Failed to generate interface dependencies file.' | 257 print 'Failed to generate interface dependencies file.' |
249 return -1 | 258 return -1 |
250 | 259 |
251 all_tests_passed = self.run_tests() | 260 all_tests_passed = self.run_tests() |
252 print | 261 print |
253 if all_tests_passed: | 262 if all_tests_passed: |
254 print 'All tests PASS!' | 263 print 'All tests PASS!' |
255 return 0 | 264 return 0 |
256 print 'Some tests FAIL! (To update the reference files, execute "run-bin
dings-tests --reset-results")' | 265 print 'Some tests FAIL! (To update the reference files, execute "run-bin
dings-tests --reset-results")' |
257 return -1 | 266 return -1 |
OLD | NEW |