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 27 matching lines...) Expand all Loading... |
38 module_path = os.path.dirname(__file__) | 38 module_path = os.path.dirname(__file__) |
39 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir, | 39 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir, |
40 os.pardir, os.pardir, 'Source')) | 40 os.pardir, os.pardir, 'Source')) |
41 sys.path.append(source_path) # for Source/bindings imports | 41 sys.path.append(source_path) # for Source/bindings imports |
42 | 42 |
43 import bindings.scripts.compute_interfaces_info_individual | 43 import bindings.scripts.compute_interfaces_info_individual |
44 from bindings.scripts.compute_interfaces_info_individual import compute_info_ind
ividual, info_individual | 44 from bindings.scripts.compute_interfaces_info_individual import compute_info_ind
ividual, info_individual |
45 import bindings.scripts.compute_interfaces_info_overall | 45 import bindings.scripts.compute_interfaces_info_overall |
46 from bindings.scripts.compute_interfaces_info_overall import compute_interfaces_
info_overall, interfaces_info | 46 from bindings.scripts.compute_interfaces_info_overall import compute_interfaces_
info_overall, interfaces_info |
47 from bindings.scripts.idl_compiler import IdlCompilerDictionaryImpl, IdlCompiler
V8 | 47 from bindings.scripts.idl_compiler import IdlCompilerDictionaryImpl, IdlCompiler
V8 |
| 48 from bindings.scripts.utilities import idl_filename_to_component |
48 | 49 |
49 | 50 |
50 PASS_MESSAGE = 'All tests PASS!' | 51 PASS_MESSAGE = 'All tests PASS!' |
51 FAIL_MESSAGE = """Some tests FAIL! | 52 FAIL_MESSAGE = """Some tests FAIL! |
52 To update the reference files, execute: | 53 To update the reference files, execute: |
53 run-bindings-tests --reset-results | 54 run-bindings-tests --reset-results |
54 | 55 |
55 If the failures are not due to your changes, test results may be out of sync; | 56 If the failures are not due to your changes, test results may be out of sync; |
56 please rebaseline them in a separate CL, after checking that tests fail in ToT. | 57 please rebaseline them in a separate CL, after checking that tests fail in ToT. |
57 In CL, please set: | 58 In CL, please set: |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 try: | 237 try: |
237 generate_interface_dependencies() | 238 generate_interface_dependencies() |
238 for component in COMPONENT_DIRECTORY: | 239 for component in COMPONENT_DIRECTORY: |
239 output_dir = os.path.join(output_directory, component) | 240 output_dir = os.path.join(output_directory, component) |
240 if not os.path.exists(output_dir): | 241 if not os.path.exists(output_dir): |
241 os.makedirs(output_dir) | 242 os.makedirs(output_dir) |
242 | 243 |
243 idl_compiler = IdlCompilerV8(output_dir, | 244 idl_compiler = IdlCompilerV8(output_dir, |
244 interfaces_info=interfaces_info, | 245 interfaces_info=interfaces_info, |
245 only_if_changed=True) | 246 only_if_changed=True) |
| 247 if component == 'core': |
| 248 partial_interface_output_dir = os.path.join(output_directory, |
| 249 'modules') |
| 250 if not os.path.exists(partial_interface_output_dir): |
| 251 os.makedirs(partial_interface_output_dir) |
| 252 idl_partial_interface_compiler = IdlCompilerV8( |
| 253 partial_interface_output_dir, |
| 254 interfaces_info=interfaces_info, |
| 255 only_if_changed=True, |
| 256 target_component='modules') |
| 257 else: |
| 258 idl_partial_interface_compiler = None |
| 259 |
246 dictionary_impl_compiler = IdlCompilerDictionaryImpl( | 260 dictionary_impl_compiler = IdlCompilerDictionaryImpl( |
247 output_dir, interfaces_info=interfaces_info, | 261 output_dir, interfaces_info=interfaces_info, |
248 only_if_changed=True) | 262 only_if_changed=True) |
249 | 263 |
250 idl_filenames = [] | 264 idl_filenames = [] |
251 input_directory = os.path.join(test_input_directory, component) | 265 input_directory = os.path.join(test_input_directory, component) |
252 for filename in os.listdir(input_directory): | 266 for filename in os.listdir(input_directory): |
253 if (filename.endswith('.idl') and | 267 if (filename.endswith('.idl') and |
254 # Dependencies aren't built | 268 # Dependencies aren't built |
255 # (they are used by the dependent) | 269 # (they are used by the dependent) |
256 filename not in DEPENDENCY_IDL_FILES): | 270 filename not in DEPENDENCY_IDL_FILES): |
257 idl_filenames.append( | 271 idl_filenames.append( |
258 os.path.realpath( | 272 os.path.realpath( |
259 os.path.join(input_directory, filename))) | 273 os.path.join(input_directory, filename))) |
260 for idl_path in idl_filenames: | 274 for idl_path in idl_filenames: |
261 idl_basename = os.path.basename(idl_path) | 275 idl_basename = os.path.basename(idl_path) |
262 idl_compiler.compile_file(idl_path) | 276 idl_compiler.compile_file(idl_path) |
263 definition_name, _ = os.path.splitext(idl_basename) | 277 definition_name, _ = os.path.splitext(idl_basename) |
264 if (definition_name in interfaces_info and interfaces_info[defin
ition_name]['is_dictionary']): | 278 if definition_name in interfaces_info: |
265 dictionary_impl_compiler.compile_file(idl_path) | 279 interface_info = interfaces_info[definition_name] |
| 280 if interface_info['is_dictionary']: |
| 281 dictionary_impl_compiler.compile_file(idl_path) |
| 282 if component == 'core' and interface_info['dependencies_othe
r_component_full_paths']: |
| 283 idl_partial_interface_compiler.compile_file(idl_path) |
266 if verbose: | 284 if verbose: |
267 print 'Compiled: %s' % idl_path | 285 print 'Compiled: %s' % idl_path |
268 finally: | 286 finally: |
269 delete_cache_files() | 287 delete_cache_files() |
270 | 288 |
271 # Detect all changes | 289 # Detect all changes |
272 output_files = list_files(output_directory) | 290 output_files = list_files(output_directory) |
273 passed = identical_output_files(output_files) | 291 passed = identical_output_files(output_files) |
274 passed &= no_excess_files(output_files) | 292 passed &= no_excess_files(output_files) |
275 | 293 |
276 if passed: | 294 if passed: |
277 if verbose: | 295 if verbose: |
278 print | 296 print |
279 print PASS_MESSAGE | 297 print PASS_MESSAGE |
280 return 0 | 298 return 0 |
281 print | 299 print |
282 print FAIL_MESSAGE | 300 print FAIL_MESSAGE |
283 return 1 | 301 return 1 |
284 | 302 |
285 | 303 |
286 def run_bindings_tests(reset_results, verbose): | 304 def run_bindings_tests(reset_results, verbose): |
287 # Generate output into the reference directory if resetting results, or | 305 # Generate output into the reference directory if resetting results, or |
288 # a temp directory if not. | 306 # a temp directory if not. |
289 if reset_results: | 307 if reset_results: |
290 print 'Resetting results' | 308 print 'Resetting results' |
291 return bindings_tests(reference_directory, verbose) | 309 return bindings_tests(reference_directory, verbose) |
292 with TemporaryDirectory() as temp_dir: | 310 with TemporaryDirectory() as temp_dir: |
293 return bindings_tests(temp_dir, verbose) | 311 return bindings_tests(temp_dir, verbose) |
OLD | NEW |