| 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 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 Loading... |
| 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 29 matching lines...) Expand all Loading... |
| 129 try: | 131 try: |
| 130 output = self.run_command(cmd) | 132 output = self.run_command(cmd) |
| 131 except ScriptError, e: | 133 except ScriptError, e: |
| 132 print e.output | 134 print e.output |
| 133 return e.exit_code | 135 return e.exit_code |
| 134 if output: | 136 if output: |
| 135 print output | 137 print output |
| 136 return 0 | 138 return 0 |
| 137 | 139 |
| 138 def generate_interface_dependencies(self): | 140 def generate_interface_dependencies(self): |
| 139 idl_files_list_file, idl_files_list_filename = provider.newtempfile() | 141 idl_files_list_file, main_idl_files_list_filename = provider.newtempfile
() |
| 140 idl_paths = [os.path.join(input_directory, input_file) | 142 idl_paths = [os.path.join(input_directory, input_file) |
| 141 for input_file in os.listdir(input_directory) | 143 for input_file in os.listdir(input_directory) |
| 142 if input_file.endswith('.idl')] | 144 if input_file.endswith('.idl')] |
| 143 idl_files_list_contents = ''.join(idl_path + '\n' | 145 idl_files_list_contents = ''.join(idl_path + '\n' |
| 144 for idl_path in idl_paths) | 146 for idl_path in idl_paths) |
| 145 os.write(idl_files_list_file, idl_files_list_contents) | 147 os.write(idl_files_list_file, idl_files_list_contents) |
| 148 support_idl_files_list_file, support_idl_files_list_filename = provider.
newtempfile() |
| 149 support_idl_paths = [os.path.join(support_input_directory, input_file) |
| 150 for input_file in os.listdir(support_input_directory) |
| 151 if input_file.endswith('.idl')] |
| 152 support_idl_files_list_contents = ''.join(idl_path + '\n' |
| 153 for idl_path in support_idl_paths) |
| 154 os.write(support_idl_files_list_file, support_idl_files_list_contents) |
| 146 | 155 |
| 147 # Dummy files, required by compute_dependencies but not checked | 156 # Dummy files, required by compute_dependencies but not checked |
| 148 _, window_constructors_file = provider.newtempfile() | 157 _, window_constructors_file = provider.newtempfile() |
| 149 _, workerglobalscope_constructors_file = provider.newtempfile() | 158 _, workerglobalscope_constructors_file = provider.newtempfile() |
| 150 _, sharedworkerglobalscope_constructors_file = provider.newtempfile() | 159 _, sharedworkerglobalscope_constructors_file = provider.newtempfile() |
| 151 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile() | 160 _, dedicatedworkerglobalscope_constructors_file = provider.newtempfile() |
| 152 cmd = ['python', | 161 cmd = ['python', |
| 153 'bindings/scripts/compute_dependencies.py', | 162 'bindings/scripts/compute_dependencies.py', |
| 154 '--idl-files-list', idl_files_list_filename, | 163 '--main-idl-files-list', main_idl_files_list_filename, |
| 164 '--support-idl-files-list', support_idl_files_list_filename, |
| 155 '--interface-dependencies-file', self.interface_dependencies_file
name, | 165 '--interface-dependencies-file', self.interface_dependencies_file
name, |
| 166 '--bindings-derived-sources-file', self.derived_sources_list_file
name, |
| 156 '--window-constructors-file', window_constructors_file, | 167 '--window-constructors-file', window_constructors_file, |
| 157 '--workerglobalscope-constructors-file', workerglobalscope_constr
uctors_file, | 168 '--workerglobalscope-constructors-file', workerglobalscope_constr
uctors_file, |
| 158 '--sharedworkerglobalscope-constructors-file', sharedworkerglobal
scope_constructors_file, | 169 '--sharedworkerglobalscope-constructors-file', sharedworkerglobal
scope_constructors_file, |
| 159 '--dedicatedworkerglobalscope-constructors-file', dedicatedworker
globalscope_constructors_file, | 170 '--dedicatedworkerglobalscope-constructors-file', dedicatedworker
globalscope_constructors_file, |
| 160 '--event-names-file', self.event_names_filename, | 171 '--event-names-file', self.event_names_filename, |
| 161 '--write-file-only-if-changed', '0'] | 172 '--write-file-only-if-changed', '0'] |
| 162 | 173 |
| 163 if self.reset_results: | 174 if self.reset_results: |
| 164 print 'Reset results: EventInterfaces.in' | 175 print 'Reset results: EventInterfaces.in' |
| 165 try: | 176 try: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 194 def identical_output_directory(self, work_directory): | 205 def identical_output_directory(self, work_directory): |
| 195 file_pairs = [(os.path.join(reference_directory, output_file), | 206 file_pairs = [(os.path.join(reference_directory, output_file), |
| 196 os.path.join(work_directory, output_file)) | 207 os.path.join(work_directory, output_file)) |
| 197 for output_file in os.listdir(work_directory) | 208 for output_file in os.listdir(work_directory) |
| 198 # FIXME: add option to compiler to not generate tables | 209 # FIXME: add option to compiler to not generate tables |
| 199 if output_file != 'parsetab.py'] | 210 if output_file != 'parsetab.py'] |
| 200 return all([self.identical_file(reference_filename, work_filename) | 211 return all([self.identical_file(reference_filename, work_filename) |
| 201 for (reference_filename, work_filename) in file_pairs]) | 212 for (reference_filename, work_filename) in file_pairs]) |
| 202 | 213 |
| 203 def run_tests(self): | 214 def run_tests(self): |
| 204 def generate_and_check_output_pl(idl_filename): | 215 def generate_and_check_output_pl(idl_filename, directory): |
| 205 # Generate output into the reference directory if resetting | 216 # Generate output into the reference directory if resetting |
| 206 # results, or a temp directory if not. | 217 # results, or a temp directory if not. |
| 207 if self.reset_results: | 218 if self.reset_results: |
| 208 work_directory = reference_directory | 219 work_directory = reference_directory |
| 209 else: | 220 else: |
| 210 work_directory = provider.newtempdir() | 221 work_directory = provider.newtempdir() |
| 211 idl_path = os.path.join(input_directory, idl_filename) | 222 idl_path = os.path.join(directory, idl_filename) |
| 212 if self.generate_from_idl_pl(idl_path, work_directory): | 223 if self.generate_from_idl_pl(idl_path, work_directory): |
| 213 return False | 224 return False |
| 214 if self.reset_results: | 225 if self.reset_results: |
| 215 print 'Reset results: %s' % input_file | 226 print 'Reset results: %s' % input_file |
| 216 return True | 227 return True |
| 217 return self.identical_output_directory(work_directory) | 228 return self.identical_output_directory(work_directory) |
| 218 | 229 |
| 219 def generate_and_check_output_py(idl_filename): | 230 def generate_and_check_output_py(idl_filename): |
| 220 if idl_filename in SKIP_PYTHON: | 231 if idl_filename in SKIP_PYTHON: |
| 221 print 'SKIP: %s' % idl_filename | 232 print 'SKIP: %s' % idl_filename |
| 222 return True | 233 return True |
| 223 work_directory = provider.newtempdir() | 234 work_directory = provider.newtempdir() |
| 224 idl_path = os.path.join(input_directory, idl_filename) | 235 idl_path = os.path.join(input_directory, idl_filename) |
| 225 if self.generate_from_idl_py(idl_path, work_directory): | 236 if self.generate_from_idl_py(idl_path, work_directory): |
| 226 return False | 237 return False |
| 227 # Detect changes | 238 # Detect changes |
| 228 return self.identical_output_directory(work_directory) | 239 return self.identical_output_directory(work_directory) |
| 229 | 240 |
| 230 if self.reset_results: | 241 if self.reset_results: |
| 231 passed = True | 242 passed = True |
| 232 else: | 243 else: |
| 233 passed = self.identical_file(reference_event_names_filename, | 244 passed = self.identical_file(reference_event_names_filename, |
| 234 self.event_names_filename) | 245 self.event_names_filename) |
| 235 passed &= all([generate_and_check_output_pl(input_file) | 246 for directory in [input_directory, support_input_directory]: |
| 236 for input_file in os.listdir(input_directory) | 247 passed &= all([generate_and_check_output_pl(input_file, directory) |
| 237 if input_file.endswith('.idl')]) | 248 for input_file in os.listdir(directory) |
| 249 if input_file.endswith('.idl')]) |
| 238 print | 250 print |
| 239 if self.test_python: | 251 if self.test_python: |
| 240 print 'Python:' | 252 print 'Python:' |
| 241 passed &= all([generate_and_check_output_py(input_file) | 253 passed &= all([generate_and_check_output_py(input_file) |
| 242 for input_file in os.listdir(input_directory) | 254 for input_file in os.listdir(input_directory) |
| 243 if input_file.endswith('.idl')]) | 255 if input_file.endswith('.idl')]) |
| 244 return passed | 256 return passed |
| 245 | 257 |
| 246 def main(self): | 258 def main(self): |
| 247 current_scm = detect_scm_system(os.curdir) | 259 current_scm = detect_scm_system(os.curdir) |
| 248 os.chdir(os.path.join(current_scm.checkout_root, 'Source')) | 260 os.chdir(os.path.join(current_scm.checkout_root, 'Source')) |
| 249 | 261 |
| 250 if self.generate_interface_dependencies(): | 262 if self.generate_interface_dependencies(): |
| 251 print 'Failed to generate interface dependencies file.' | 263 print 'Failed to generate interface dependencies file.' |
| 252 return -1 | 264 return -1 |
| 253 | 265 |
| 254 all_tests_passed = self.run_tests() | 266 all_tests_passed = self.run_tests() |
| 255 print | 267 print |
| 256 if all_tests_passed: | 268 if all_tests_passed: |
| 257 print 'All tests PASS!' | 269 print 'All tests PASS!' |
| 258 return 0 | 270 return 0 |
| 259 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")' |
| 260 return -1 | 272 return -1 |
| OLD | NEW |