| 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 25 matching lines...) Expand all Loading... |
| 36 # Python modules. | 36 # Python modules. |
| 37 module_path = os.path.dirname(__file__) | 37 module_path = os.path.dirname(__file__) |
| 38 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir, | 38 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir, |
| 39 os.pardir, os.pardir, 'Source')) | 39 os.pardir, os.pardir, 'Source')) |
| 40 sys.path.append(source_path) # for Source/bindings imports | 40 sys.path.append(source_path) # for Source/bindings imports |
| 41 | 41 |
| 42 import bindings.scripts.compute_interfaces_info_individual | 42 import bindings.scripts.compute_interfaces_info_individual |
| 43 from bindings.scripts.compute_interfaces_info_individual import compute_info_ind
ividual, info_individual | 43 from bindings.scripts.compute_interfaces_info_individual import compute_info_ind
ividual, info_individual |
| 44 import bindings.scripts.compute_interfaces_info_overall | 44 import bindings.scripts.compute_interfaces_info_overall |
| 45 from bindings.scripts.compute_interfaces_info_overall import compute_interfaces_
info_overall, interfaces_info | 45 from bindings.scripts.compute_interfaces_info_overall import compute_interfaces_
info_overall, interfaces_info |
| 46 from bindings.scripts.idl_compiler import IdlCompilerV8 | 46 from bindings.scripts.idl_compiler import IdlCompilerDictionaryImpl, IdlCompiler
V8 |
| 47 | 47 |
| 48 | 48 |
| 49 PASS_MESSAGE = 'All tests PASS!' | 49 PASS_MESSAGE = 'All tests PASS!' |
| 50 FAIL_MESSAGE = """Some tests FAIL! | 50 FAIL_MESSAGE = """Some tests FAIL! |
| 51 To update the reference files, execute: | 51 To update the reference files, execute: |
| 52 run-bindings-tests --reset-results | 52 run-bindings-tests --reset-results |
| 53 | 53 |
| 54 If the failures are not due to your changes, test results may be out of sync; | 54 If the failures are not due to your changes, test results may be out of sync; |
| 55 please rebaseline them in a separate CL, after checking that tests fail in ToT. | 55 please rebaseline them in a separate CL, after checking that tests fail in ToT. |
| 56 In CL, please set: | 56 In CL, please set: |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 '(probably cruft from renaming or deleting):\n' + | 185 '(probably cruft from renaming or deleting):\n' + |
| 186 '\n'.join(excess_files)) | 186 '\n'.join(excess_files)) |
| 187 return False | 187 return False |
| 188 return True | 188 return True |
| 189 | 189 |
| 190 try: | 190 try: |
| 191 generate_interface_dependencies() | 191 generate_interface_dependencies() |
| 192 idl_compiler = IdlCompilerV8(output_directory, | 192 idl_compiler = IdlCompilerV8(output_directory, |
| 193 interfaces_info=interfaces_info, | 193 interfaces_info=interfaces_info, |
| 194 only_if_changed=True) | 194 only_if_changed=True) |
| 195 dictionary_impl_compiler = IdlCompilerDictionaryImpl( |
| 196 output_directory, interfaces_info=interfaces_info, |
| 197 only_if_changed=True) |
| 195 | 198 |
| 196 idl_basenames = [filename | 199 idl_basenames = [filename |
| 197 for filename in os.listdir(test_input_directory) | 200 for filename in os.listdir(test_input_directory) |
| 198 if (filename.endswith('.idl') and | 201 if (filename.endswith('.idl') and |
| 199 # Dependencies aren't built | 202 # Dependencies aren't built |
| 200 # (they are used by the dependent) | 203 # (they are used by the dependent) |
| 201 filename not in DEPENDENCY_IDL_FILES)] | 204 filename not in DEPENDENCY_IDL_FILES)] |
| 202 for idl_basename in idl_basenames: | 205 for idl_basename in idl_basenames: |
| 203 idl_path = os.path.realpath( | 206 idl_path = os.path.realpath( |
| 204 os.path.join(test_input_directory, idl_basename)) | 207 os.path.join(test_input_directory, idl_basename)) |
| 205 idl_compiler.compile_file(idl_path) | 208 idl_compiler.compile_file(idl_path) |
| 209 definition_name, _ = os.path.splitext(idl_basename) |
| 210 if (definition_name in interfaces_info and |
| 211 interfaces_info[definition_name]['is_dictionary']): |
| 212 dictionary_impl_compiler.compile_file(idl_path) |
| 206 if verbose: | 213 if verbose: |
| 207 print 'Compiled: %s' % filename | 214 print 'Compiled: %s' % filename |
| 208 finally: | 215 finally: |
| 209 delete_cache_files() | 216 delete_cache_files() |
| 210 | 217 |
| 211 # Detect all changes | 218 # Detect all changes |
| 212 passed = identical_output_files() | 219 passed = identical_output_files() |
| 213 passed &= no_excess_files() | 220 passed &= no_excess_files() |
| 214 | 221 |
| 215 if passed: | 222 if passed: |
| 216 if verbose: | 223 if verbose: |
| 217 print | 224 print |
| 218 print PASS_MESSAGE | 225 print PASS_MESSAGE |
| 219 return 0 | 226 return 0 |
| 220 print | 227 print |
| 221 print FAIL_MESSAGE | 228 print FAIL_MESSAGE |
| 222 return 1 | 229 return 1 |
| 223 | 230 |
| 224 | 231 |
| 225 def run_bindings_tests(reset_results, verbose): | 232 def run_bindings_tests(reset_results, verbose): |
| 226 # Generate output into the reference directory if resetting results, or | 233 # Generate output into the reference directory if resetting results, or |
| 227 # a temp directory if not. | 234 # a temp directory if not. |
| 228 if reset_results: | 235 if reset_results: |
| 229 print 'Resetting results' | 236 print 'Resetting results' |
| 230 return bindings_tests(reference_directory, verbose) | 237 return bindings_tests(reference_directory, verbose) |
| 231 with TemporaryDirectory() as temp_dir: | 238 with TemporaryDirectory() as temp_dir: |
| 232 return bindings_tests(temp_dir, verbose) | 239 return bindings_tests(temp_dir, verbose) |
| OLD | NEW |