| 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 InterfaceInfoCol
lector |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 # excess stat() calls. Faster versions may appear in Python 3.5 or | 99 # excess stat() calls. Faster versions may appear in Python 3.5 or |
| 100 # later: | 100 # later: |
| 101 # https://github.com/benhoyt/scandir | 101 # https://github.com/benhoyt/scandir |
| 102 # http://bugs.python.org/issue11406 | 102 # http://bugs.python.org/issue11406 |
| 103 idl_paths = [] | 103 idl_paths = [] |
| 104 for dirpath, _, files in os.walk(directory): | 104 for dirpath, _, files in os.walk(directory): |
| 105 idl_paths.extend(os.path.join(dirpath, filename) | 105 idl_paths.extend(os.path.join(dirpath, filename) |
| 106 for filename in fnmatch.filter(files, '*.idl')) | 106 for filename in fnmatch.filter(files, '*.idl')) |
| 107 return idl_paths | 107 return idl_paths |
| 108 | 108 |
| 109 def collect_blink_idl_paths(): |
| 110 """Returns IDL file paths which blink actually uses.""" |
| 111 idl_paths = [] |
| 112 for component in COMPONENT_DIRECTORY: |
| 113 directory = os.path.join(source_path, component) |
| 114 idl_paths.extend(idl_paths_recursive(directory)) |
| 115 return idl_paths |
| 116 |
| 109 # We compute interfaces info for *all* IDL files, not just test IDL | 117 # We compute interfaces info for *all* IDL files, not just test IDL |
| 110 # files, as code generator output depends on inheritance (both ancestor | 118 # files, as code generator output depends on inheritance (both ancestor |
| 111 # chain and inherited extended attributes), and some real interfaces | 119 # chain and inherited extended attributes), and some real interfaces |
| 112 # are special-cased, such as Node. | 120 # are special-cased, such as Node. |
| 113 # | 121 # |
| 114 # For example, when testing the behavior of interfaces that inherit | 122 # For example, when testing the behavior of interfaces that inherit |
| 115 # from Node, we also need to know that these inherit from EventTarget, | 123 # from Node, we also need to know that these inherit from EventTarget, |
| 116 # since this is also special-cased and Node inherits from EventTarget, | 124 # since this is also special-cased and Node inherits from EventTarget, |
| 117 # but this inheritance information requires computing dependencies for | 125 # but this inheritance information requires computing dependencies for |
| 118 # the real Node.idl file. | 126 # the real Node.idl file. |
| 119 non_test_idl_paths = [] | 127 non_test_idl_paths = collect_blink_idl_paths() |
| 120 test_idl_paths = [] | 128 test_idl_paths = idl_paths_recursive(test_input_directory) |
| 121 test_idl_dir = test_input_directory + os.sep | |
| 122 for idl_path in idl_paths_recursive(source_path): | |
| 123 if idl_path.startswith(test_idl_dir): | |
| 124 test_idl_paths.append(idl_path) | |
| 125 else: | |
| 126 non_test_idl_paths.append(idl_path) | |
| 127 # 2-stage computation: individual, then overall | 129 # 2-stage computation: individual, then overall |
| 128 # | 130 # |
| 129 # Properly should compute separately by component (currently test | 131 # Properly should compute separately by component (currently test |
| 130 # includes are invalid), but that's brittle (would need to update this file | 132 # includes are invalid), but that's brittle (would need to update this file |
| 131 # for each new component) and doesn't test the code generator any better | 133 # for each new component) and doesn't test the code generator any better |
| 132 # than using a single component. | 134 # than using a single component. |
| 133 # | 135 # |
| 134 # In order to allow test IDL files to override the production IDL files if | 136 # In order to allow test IDL files to override the production IDL files if |
| 135 # they have the same interface name, process the test IDL files after the | 137 # they have the same interface name, process the test IDL files after the |
| 136 # non-test IDL files. | 138 # non-test IDL files. |
| 137 reader = IdlReader() | 139 info_individuals = [] |
| 140 info_collector = InterfaceInfoCollector() |
| 138 for idl_path_list in (non_test_idl_paths, test_idl_paths): | 141 for idl_path_list in (non_test_idl_paths, test_idl_paths): |
| 139 for idl_path in idl_path_list: | 142 for idl_path in idl_path_list: |
| 140 if os.path.basename(idl_path) in NON_BLINK_IDL_FILES: | 143 if os.path.basename(idl_path) in NON_BLINK_IDL_FILES: |
| 141 continue | 144 continue |
| 142 compute_info_individual(idl_path, reader) | 145 info_collector.collect_info(idl_path) |
| 143 info_individuals = [info_individual()] | 146 info_individuals.append(info_collector.get_info_as_dict()) |
| 144 # TestDictionary.{h,cpp} are placed under Source/bindings/tests/idls/core. | 147 # TestDictionary.{h,cpp} are placed under Source/bindings/tests/idls/core. |
| 145 # However, IdlCompiler generates TestDictionary.{h,cpp} by using relative_di
r. | 148 # However, IdlCompiler generates TestDictionary.{h,cpp} by using relative_di
r. |
| 146 # So the files will be generated under output_dir/core/bindings/tests/idls/c
ore. | 149 # So the files will be generated under output_dir/core/bindings/tests/idls/c
ore. |
| 147 # To avoid this issue, we need to clear relative_dir here. | 150 # To avoid this issue, we need to clear relative_dir here. |
| 148 for info in info_individuals: | 151 for info in info_individuals: |
| 149 for value in info['interfaces_info'].itervalues(): | 152 for value in info['interfaces_info'].itervalues(): |
| 150 value['relative_dir'] = '' | 153 value['relative_dir'] = '' |
| 151 compute_interfaces_info_overall(info_individuals) | 154 compute_interfaces_info_overall(info_individuals) |
| 152 | 155 |
| 153 | 156 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 304 |
| 302 | 305 |
| 303 def run_bindings_tests(reset_results, verbose): | 306 def run_bindings_tests(reset_results, verbose): |
| 304 # Generate output into the reference directory if resetting results, or | 307 # Generate output into the reference directory if resetting results, or |
| 305 # a temp directory if not. | 308 # a temp directory if not. |
| 306 if reset_results: | 309 if reset_results: |
| 307 print 'Resetting results' | 310 print 'Resetting results' |
| 308 return bindings_tests(reference_directory, verbose) | 311 return bindings_tests(reference_directory, verbose) |
| 309 with TemporaryDirectory() as temp_dir: | 312 with TemporaryDirectory() as temp_dir: |
| 310 return bindings_tests(temp_dir, verbose) | 313 return bindings_tests(temp_dir, verbose) |
| OLD | NEW |