Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 from webkitpy.common.system.executive import Executive | 34 from webkitpy.common.system.executive import Executive | 
| 35 | 35 | 
| 36 # Source/ path is needed both to find input IDL files, and to import other | 36 # Source/ path is needed both to find input IDL files, and to import other | 
| 37 # Python modules. | 37 # Python modules. | 
| 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 InterfaceInfoGen eratorIndividual | 
| 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.idl_reader import IdlReader | 48 from bindings.scripts.idl_reader import IdlReader | 
| 49 from bindings.scripts.utilities import idl_filename_to_component | 49 from bindings.scripts.utilities import idl_filename_to_component | 
| 50 | 50 | 
| 51 | 51 | 
| 52 PASS_MESSAGE = 'All tests PASS!' | 52 PASS_MESSAGE = 'All tests PASS!' | 
| 53 FAIL_MESSAGE = """Some tests FAIL! | 53 FAIL_MESSAGE = """Some tests FAIL! | 
| 54 To update the reference files, execute: | 54 To update the reference files, execute: | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 # excess stat() calls. Faster versions may appear in Python 3.5 or | 105 # excess stat() calls. Faster versions may appear in Python 3.5 or | 
| 106 # later: | 106 # later: | 
| 107 # https://github.com/benhoyt/scandir | 107 # https://github.com/benhoyt/scandir | 
| 108 # http://bugs.python.org/issue11406 | 108 # http://bugs.python.org/issue11406 | 
| 109 idl_paths = [] | 109 idl_paths = [] | 
| 110 for dirpath, _, files in os.walk(directory): | 110 for dirpath, _, files in os.walk(directory): | 
| 111 idl_paths.extend(os.path.join(dirpath, filename) | 111 idl_paths.extend(os.path.join(dirpath, filename) | 
| 112 for filename in fnmatch.filter(files, '*.idl')) | 112 for filename in fnmatch.filter(files, '*.idl')) | 
| 113 return idl_paths | 113 return idl_paths | 
| 114 | 114 | 
| 115 def collect_blink_idl_paths(): | |
| 116 """Returns IDL file paths which blink actually uses.""" | |
| 117 idl_paths = [] | |
| 118 for component in COMPONENT_DIRECTORY: | |
| 119 directory = os.path.join(source_path, component) | |
| 120 idl_paths.extend(idl_paths_recursive(directory)) | |
| 121 return idl_paths | |
| 122 | |
| 115 # We compute interfaces info for *all* IDL files, not just test IDL | 123 # We compute interfaces info for *all* IDL files, not just test IDL | 
| 116 # files, as code generator output depends on inheritance (both ancestor | 124 # files, as code generator output depends on inheritance (both ancestor | 
| 117 # chain and inherited extended attributes), and some real interfaces | 125 # chain and inherited extended attributes), and some real interfaces | 
| 118 # are special-cased, such as Node. | 126 # are special-cased, such as Node. | 
| 119 # | 127 # | 
| 120 # For example, when testing the behavior of interfaces that inherit | 128 # For example, when testing the behavior of interfaces that inherit | 
| 121 # from Node, we also need to know that these inherit from EventTarget, | 129 # from Node, we also need to know that these inherit from EventTarget, | 
| 122 # since this is also special-cased and Node inherits from EventTarget, | 130 # since this is also special-cased and Node inherits from EventTarget, | 
| 123 # but this inheritance information requires computing dependencies for | 131 # but this inheritance information requires computing dependencies for | 
| 124 # the real Node.idl file. | 132 # the real Node.idl file. | 
| 125 non_test_idl_paths = [] | 133 non_test_idl_paths = collect_blink_idl_paths() | 
| 126 test_idl_paths = [] | 134 test_idl_paths = idl_paths_recursive(test_input_directory) | 
| 127 test_idl_dir = test_input_directory + os.sep | |
| 128 for idl_path in idl_paths_recursive(source_path): | |
| 129 if idl_path.startswith(test_idl_dir): | |
| 130 test_idl_paths.append(idl_path) | |
| 131 else: | |
| 132 non_test_idl_paths.append(idl_path) | |
| 133 # 2-stage computation: individual, then overall | 135 # 2-stage computation: individual, then overall | 
| 134 # | 136 # | 
| 135 # Properly should compute separately by component (currently test | 137 # Properly should compute separately by component (currently test | 
| 136 # includes are invalid), but that's brittle (would need to update this file | 138 # includes are invalid), but that's brittle (would need to update this file | 
| 137 # for each new component) and doesn't test the code generator any better | 139 # for each new component) and doesn't test the code generator any better | 
| 138 # than using a single component. | 140 # than using a single component. | 
| 139 # | 141 # | 
| 140 # In order to allow test IDL files to override the production IDL files if | 142 # In order to allow test IDL files to override the production IDL files if | 
| 141 # they have the same interface name, process the test IDL files after the | 143 # they have the same interface name, process the test IDL files after the | 
| 142 # non-test IDL files. | 144 # non-test IDL files. | 
| 143 reader = IdlReader(outputdir=output_directory) | 145 info_individuals = [] | 
| 146 info_generator_individual = InterfaceInfoGeneratorIndividual( | |
| 147 cache_directory=output_directory) | |
| 144 for idl_path_list in (non_test_idl_paths, test_idl_paths): | 148 for idl_path_list in (non_test_idl_paths, test_idl_paths): | 
| 145 for idl_path in idl_path_list: | 149 for idl_path in idl_path_list: | 
| 146 if os.path.basename(idl_path) in NON_BLINK_IDL_FILES: | 150 if os.path.basename(idl_path) in NON_BLINK_IDL_FILES: | 
| 147 continue | 151 continue | 
| 148 compute_info_individual(idl_path, reader) | 152 info_generator_individual.compute_info(idl_path) | 
| 149 info_individuals = [info_individual()] | 153 info_individuals.append(info_generator_individual.get_info_as_dict()) | 
| 
 
bashi
2014/10/22 09:43:30
No actual change here in this CL, but I'm planning
 
 | |
| 150 # TestDictionary.{h,cpp} are placed under Source/bindings/tests/idls/core. | 154 # TestDictionary.{h,cpp} are placed under Source/bindings/tests/idls/core. | 
| 151 # However, IdlCompiler generates TestDictionary.{h,cpp} by using relative_di r. | 155 # However, IdlCompiler generates TestDictionary.{h,cpp} by using relative_di r. | 
| 152 # So the files will be generated under output_dir/core/bindings/tests/idls/c ore. | 156 # So the files will be generated under output_dir/core/bindings/tests/idls/c ore. | 
| 153 # To avoid this issue, we need to clear relative_dir here. | 157 # To avoid this issue, we need to clear relative_dir here. | 
| 154 for info in info_individuals: | 158 for info in info_individuals: | 
| 155 for value in info['interfaces_info'].itervalues(): | 159 for value in info['interfaces_info'].itervalues(): | 
| 156 value['relative_dir'] = '' | 160 value['relative_dir'] = '' | 
| 157 compute_interfaces_info_overall(info_individuals) | 161 compute_interfaces_info_overall(info_individuals) | 
| 158 | 162 | 
| 159 | 163 | 
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 | 315 | 
| 312 | 316 | 
| 313 def run_bindings_tests(reset_results, verbose): | 317 def run_bindings_tests(reset_results, verbose): | 
| 314 # Generate output into the reference directory if resetting results, or | 318 # Generate output into the reference directory if resetting results, or | 
| 315 # a temp directory if not. | 319 # a temp directory if not. | 
| 316 if reset_results: | 320 if reset_results: | 
| 317 print 'Resetting results' | 321 print 'Resetting results' | 
| 318 return bindings_tests(reference_directory, verbose) | 322 return bindings_tests(reference_directory, verbose) | 
| 319 with TemporaryDirectory() as temp_dir: | 323 with TemporaryDirectory() as temp_dir: | 
| 320 return bindings_tests(temp_dir, verbose) | 324 return bindings_tests(temp_dir, verbose) | 
| OLD | NEW |