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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 NOTRY=true | 57 NOTRY=true |
58 TBR=(someone in Source/bindings/OWNERS or WATCHLISTS:bindings) | 58 TBR=(someone in Source/bindings/OWNERS or WATCHLISTS:bindings) |
59 """ | 59 """ |
60 | 60 |
61 DEPENDENCY_IDL_FILES = frozenset([ | 61 DEPENDENCY_IDL_FILES = frozenset([ |
62 'TestImplements.idl', | 62 'TestImplements.idl', |
63 'TestImplements2.idl', | 63 'TestImplements2.idl', |
64 'TestImplements3.idl', | 64 'TestImplements3.idl', |
65 'TestPartialInterface.idl', | 65 'TestPartialInterface.idl', |
66 'TestPartialInterface2.idl', | 66 'TestPartialInterface2.idl', |
| 67 'TestPartialInterface3.idl', |
67 ]) | 68 ]) |
68 | 69 |
| 70 COMPONENT_DIRECTORY = frozenset(['core', 'modules']) |
69 | 71 |
70 test_input_directory = os.path.join(source_path, 'bindings', 'tests', 'idls') | 72 test_input_directory = os.path.join(source_path, 'bindings', 'tests', 'idls') |
71 reference_directory = os.path.join(source_path, 'bindings', 'tests', 'results') | 73 reference_directory = os.path.join(source_path, 'bindings', 'tests', 'results') |
72 | 74 |
73 | 75 |
74 @contextmanager | 76 @contextmanager |
75 def TemporaryDirectory(): | 77 def TemporaryDirectory(): |
76 """Wrapper for tempfile.mkdtemp() so it's usable with 'with' statement. | 78 """Wrapper for tempfile.mkdtemp() so it's usable with 'with' statement. |
77 | 79 |
78 Simple backport of tempfile.TemporaryDirectory from Python 3.2. | 80 Simple backport of tempfile.TemporaryDirectory from Python 3.2. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 191 |
190 try: | 192 try: |
191 generate_interface_dependencies() | 193 generate_interface_dependencies() |
192 idl_compiler = IdlCompilerV8(output_directory, | 194 idl_compiler = IdlCompilerV8(output_directory, |
193 interfaces_info=interfaces_info, | 195 interfaces_info=interfaces_info, |
194 only_if_changed=True) | 196 only_if_changed=True) |
195 dictionary_impl_compiler = IdlCompilerDictionaryImpl( | 197 dictionary_impl_compiler = IdlCompilerDictionaryImpl( |
196 output_directory, interfaces_info=interfaces_info, | 198 output_directory, interfaces_info=interfaces_info, |
197 only_if_changed=True) | 199 only_if_changed=True) |
198 | 200 |
199 idl_basenames = [filename | 201 idl_filenames = [] |
200 for filename in os.listdir(test_input_directory) | 202 for component in COMPONENT_DIRECTORY: |
201 if (filename.endswith('.idl') and | 203 input_directory = os.path.join(test_input_directory, component) |
202 # Dependencies aren't built | 204 for filename in os.listdir(input_directory): |
203 # (they are used by the dependent) | 205 if (filename.endswith('.idl') and |
204 filename not in DEPENDENCY_IDL_FILES)] | 206 # Dependencies aren't built |
205 for idl_basename in idl_basenames: | 207 # (they are used by the dependent) |
206 idl_path = os.path.realpath( | 208 filename not in DEPENDENCY_IDL_FILES): |
207 os.path.join(test_input_directory, idl_basename)) | 209 idl_filenames.append( |
| 210 os.path.realpath( |
| 211 os.path.join(input_directory, filename))) |
| 212 for idl_path in idl_filenames: |
| 213 idl_basename = os.path.basename(idl_path) |
208 idl_compiler.compile_file(idl_path) | 214 idl_compiler.compile_file(idl_path) |
209 definition_name, _ = os.path.splitext(idl_basename) | 215 definition_name, _ = os.path.splitext(idl_basename) |
210 if (definition_name in interfaces_info and | 216 if (definition_name in interfaces_info and |
211 interfaces_info[definition_name]['is_dictionary']): | 217 interfaces_info[definition_name]['is_dictionary']): |
212 dictionary_impl_compiler.compile_file(idl_path) | 218 dictionary_impl_compiler.compile_file(idl_path) |
213 if verbose: | 219 if verbose: |
214 print 'Compiled: %s' % filename | 220 print 'Compiled: %s' % idl_path |
215 finally: | 221 finally: |
216 delete_cache_files() | 222 delete_cache_files() |
217 | 223 |
218 # Detect all changes | 224 # Detect all changes |
219 passed = identical_output_files() | 225 passed = identical_output_files() |
220 passed &= no_excess_files() | 226 passed &= no_excess_files() |
221 | 227 |
222 if passed: | 228 if passed: |
223 if verbose: | 229 if verbose: |
224 print | 230 print |
225 print PASS_MESSAGE | 231 print PASS_MESSAGE |
226 return 0 | 232 return 0 |
227 print | 233 print |
228 print FAIL_MESSAGE | 234 print FAIL_MESSAGE |
229 return 1 | 235 return 1 |
230 | 236 |
231 | 237 |
232 def run_bindings_tests(reset_results, verbose): | 238 def run_bindings_tests(reset_results, verbose): |
233 # Generate output into the reference directory if resetting results, or | 239 # Generate output into the reference directory if resetting results, or |
234 # a temp directory if not. | 240 # a temp directory if not. |
235 if reset_results: | 241 if reset_results: |
236 print 'Resetting results' | 242 print 'Resetting results' |
237 return bindings_tests(reference_directory, verbose) | 243 return bindings_tests(reference_directory, verbose) |
238 with TemporaryDirectory() as temp_dir: | 244 with TemporaryDirectory() as temp_dir: |
239 return bindings_tests(temp_dir, verbose) | 245 return bindings_tests(temp_dir, verbose) |
OLD | NEW |