| 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. |
| 11 # | 11 # |
| 12 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 12 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 13 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 13 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 14 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 14 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 15 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 15 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 16 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 16 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 17 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 17 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 18 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 18 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 19 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 19 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 20 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 21 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 22 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 # | 23 # |
| 24 | 24 |
| 25 from contextlib import contextmanager | 25 from contextlib import contextmanager |
| 26 import filecmp | 26 import filecmp |
| 27 import fnmatch | 27 import fnmatch |
| 28 import os | 28 import os |
| 29 import re |
| 29 import shutil | 30 import shutil |
| 30 import sys | 31 import sys |
| 31 import tempfile | 32 import tempfile |
| 32 | 33 |
| 33 from webkitpy.common.system.executive import Executive | 34 from webkitpy.common.system.executive import Executive |
| 34 | 35 |
| 35 # 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 |
| 36 # Python modules. | 37 # Python modules. |
| 37 module_path = os.path.dirname(__file__) | 38 module_path = os.path.dirname(__file__) |
| 38 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, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 85 |
| 85 Simple backport of tempfile.TemporaryDirectory from Python 3.2. | 86 Simple backport of tempfile.TemporaryDirectory from Python 3.2. |
| 86 """ | 87 """ |
| 87 name = tempfile.mkdtemp() | 88 name = tempfile.mkdtemp() |
| 88 try: | 89 try: |
| 89 yield name | 90 yield name |
| 90 finally: | 91 finally: |
| 91 shutil.rmtree(name) | 92 shutil.rmtree(name) |
| 92 | 93 |
| 93 | 94 |
| 95 COMPONENT_PATH_PATTERN = re.compile(r'/(core|modules)(/|$)') |
| 96 |
| 97 |
| 98 def detect_component_dir(path): |
| 99 match = COMPONENT_PATH_PATTERN.search(os.path.dirname(path)) |
| 100 if match: |
| 101 return match.group(1) |
| 102 raise AssertionError('"%s" is not placed under known component_dir, core or
modules.' % path) |
| 103 |
| 104 |
| 94 def generate_interface_dependencies(): | 105 def generate_interface_dependencies(): |
| 95 def idl_paths_recursive(directory): | 106 def idl_paths_recursive(directory): |
| 96 # This is slow, especially on Windows, due to os.walk making | 107 # This is slow, especially on Windows, due to os.walk making |
| 97 # excess stat() calls. Faster versions may appear in Python 3.5 or | 108 # excess stat() calls. Faster versions may appear in Python 3.5 or |
| 98 # later: | 109 # later: |
| 99 # https://github.com/benhoyt/scandir | 110 # https://github.com/benhoyt/scandir |
| 100 # http://bugs.python.org/issue11406 | 111 # http://bugs.python.org/issue11406 |
| 101 idl_paths = [] | 112 idl_paths = [] |
| 102 for dirpath, _, files in os.walk(directory): | 113 for dirpath, _, files in os.walk(directory): |
| 103 idl_paths.extend(os.path.join(dirpath, filename) | 114 idl_paths.extend(os.path.join(dirpath, filename) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 115 # but this inheritance information requires computing dependencies for | 126 # but this inheritance information requires computing dependencies for |
| 116 # the real Node.idl file. | 127 # the real Node.idl file. |
| 117 | 128 |
| 118 # 2-stage computation: individual, then overall | 129 # 2-stage computation: individual, then overall |
| 119 # | 130 # |
| 120 # Properly should compute separately by component (currently test | 131 # Properly should compute separately by component (currently test |
| 121 # 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 |
| 122 # 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 |
| 123 # than using a single component. | 134 # than using a single component. |
| 124 for idl_filename in idl_paths_recursive(source_path): | 135 for idl_filename in idl_paths_recursive(source_path): |
| 125 compute_info_individual(idl_filename, 'tests') | 136 compute_info_individual(idl_filename, detect_component_dir(idl_filename)
) |
| 126 info_individuals = [info_individual()] | 137 info_individuals = [info_individual()] |
| 138 # TestDictionary.{h,cpp} are placed under Source/bindings/tests/idls/core. |
| 139 # However, IdlCompiler generates TestDictionary.{h,cpp} by using relative_di
r. |
| 140 # So the files will be generated under output_dir/core/bindings/tests/idls/c
ore. |
| 141 # To avoid this issue, we need to clear relative_dir here. |
| 142 for info in info_individuals: |
| 143 for value in info['interfaces_info'].itervalues(): |
| 144 value['relative_dir'] = '' |
| 127 compute_interfaces_info_overall(info_individuals) | 145 compute_interfaces_info_overall(info_individuals) |
| 128 | 146 |
| 129 | 147 |
| 130 def bindings_tests(output_directory, verbose): | 148 def bindings_tests(output_directory, verbose): |
| 131 executive = Executive() | 149 executive = Executive() |
| 132 | 150 |
| 133 def list_files(directory): | 151 def list_files(directory): |
| 134 files = [] | 152 files = [] |
| 135 for component in os.listdir(directory): | 153 for component in os.listdir(directory): |
| 136 if component not in COMPONENT_DIRECTORY: | 154 if component not in COMPONENT_DIRECTORY: |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 282 |
| 265 | 283 |
| 266 def run_bindings_tests(reset_results, verbose): | 284 def run_bindings_tests(reset_results, verbose): |
| 267 # Generate output into the reference directory if resetting results, or | 285 # Generate output into the reference directory if resetting results, or |
| 268 # a temp directory if not. | 286 # a temp directory if not. |
| 269 if reset_results: | 287 if reset_results: |
| 270 print 'Resetting results' | 288 print 'Resetting results' |
| 271 return bindings_tests(reference_directory, verbose) | 289 return bindings_tests(reference_directory, verbose) |
| 272 with TemporaryDirectory() as temp_dir: | 290 with TemporaryDirectory() as temp_dir: |
| 273 return bindings_tests(temp_dir, verbose) | 291 return bindings_tests(temp_dir, verbose) |
| OLD | NEW |