| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 # core/inspector/InspectorInstrumentation.idl is not a valid Blink IDL. | 73 # core/inspector/InspectorInstrumentation.idl is not a valid Blink IDL. |
| 74 NON_BLINK_IDL_FILES = frozenset([ | 74 NON_BLINK_IDL_FILES = frozenset([ |
| 75 'InspectorInstrumentation.idl', | 75 'InspectorInstrumentation.idl', |
| 76 ]) | 76 ]) |
| 77 | 77 |
| 78 COMPONENT_DIRECTORY = frozenset(['core', 'modules']) | 78 COMPONENT_DIRECTORY = frozenset(['core', 'modules']) |
| 79 | 79 |
| 80 test_input_directory = os.path.join(source_path, 'bindings', 'tests', 'idls') | 80 test_input_directory = os.path.join(source_path, 'bindings', 'tests', 'idls') |
| 81 reference_directory = os.path.join(source_path, 'bindings', 'tests', 'results') | 81 reference_directory = os.path.join(source_path, 'bindings', 'tests', 'results') |
| 82 | 82 |
| 83 PLY_LEX_YACC_FILES = frozenset([ | |
| 84 'lextab.py', # PLY lex | |
| 85 'lextab.pyc', | |
| 86 'parsetab.pickle', # PLY yacc | |
| 87 ]) | |
| 88 | |
| 89 @contextmanager | 83 @contextmanager |
| 90 def TemporaryDirectory(): | 84 def TemporaryDirectory(): |
| 91 """Wrapper for tempfile.mkdtemp() so it's usable with 'with' statement. | 85 """Wrapper for tempfile.mkdtemp() so it's usable with 'with' statement. |
| 92 | 86 |
| 93 Simple backport of tempfile.TemporaryDirectory from Python 3.2. | 87 Simple backport of tempfile.TemporaryDirectory from Python 3.2. |
| 94 """ | 88 """ |
| 95 name = tempfile.mkdtemp() | 89 name = tempfile.mkdtemp() |
| 96 try: | 90 try: |
| 97 yield name | 91 yield name |
| 98 finally: | 92 finally: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 # 2-stage computation: individual, then overall | 127 # 2-stage computation: individual, then overall |
| 134 # | 128 # |
| 135 # Properly should compute separately by component (currently test | 129 # Properly should compute separately by component (currently test |
| 136 # includes are invalid), but that's brittle (would need to update this file | 130 # 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 | 131 # for each new component) and doesn't test the code generator any better |
| 138 # than using a single component. | 132 # than using a single component. |
| 139 # | 133 # |
| 140 # In order to allow test IDL files to override the production IDL files if | 134 # 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 | 135 # they have the same interface name, process the test IDL files after the |
| 142 # non-test IDL files. | 136 # non-test IDL files. |
| 143 reader = IdlReader(outputdir=output_directory) | 137 reader = IdlReader() |
| 144 for idl_path_list in (non_test_idl_paths, test_idl_paths): | 138 for idl_path_list in (non_test_idl_paths, test_idl_paths): |
| 145 for idl_path in idl_path_list: | 139 for idl_path in idl_path_list: |
| 146 if os.path.basename(idl_path) in NON_BLINK_IDL_FILES: | 140 if os.path.basename(idl_path) in NON_BLINK_IDL_FILES: |
| 147 continue | 141 continue |
| 148 compute_info_individual(idl_path, reader) | 142 compute_info_individual(idl_path, reader) |
| 149 info_individuals = [info_individual()] | 143 info_individuals = [info_individual()] |
| 150 # TestDictionary.{h,cpp} are placed under Source/bindings/tests/idls/core. | 144 # TestDictionary.{h,cpp} are placed under Source/bindings/tests/idls/core. |
| 151 # However, IdlCompiler generates TestDictionary.{h,cpp} by using relative_di
r. | 145 # 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. | 146 # 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. | 147 # To avoid this issue, we need to clear relative_dir here. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 176 cmd = ['diff', | 170 cmd = ['diff', |
| 177 '-u', # unified format | 171 '-u', # unified format |
| 178 '-N', # treat absent files as empty | 172 '-N', # treat absent files as empty |
| 179 filename1, | 173 filename1, |
| 180 filename2] | 174 filename2] |
| 181 # Return output and don't raise exception, even though diff(1) has | 175 # Return output and don't raise exception, even though diff(1) has |
| 182 # non-zero exit if files differ. | 176 # non-zero exit if files differ. |
| 183 return executive.run_command(cmd, error_handler=lambda x: None) | 177 return executive.run_command(cmd, error_handler=lambda x: None) |
| 184 | 178 |
| 185 def is_cache_file(filename): | 179 def is_cache_file(filename): |
| 186 if filename in PLY_LEX_YACC_FILES: | 180 return filename.endswith('.cache') |
| 187 return True | |
| 188 if filename.endswith('.cache'): # Jinja | |
| 189 return True | |
| 190 return False | |
| 191 | 181 |
| 192 def delete_cache_files(): | 182 def delete_cache_files(): |
| 193 # FIXME: Instead of deleting cache files, don't generate them. | 183 # FIXME: Instead of deleting cache files, don't generate them. |
| 194 cache_files = [path for path in list_files(output_directory) | 184 cache_files = [path for path in list_files(output_directory) |
| 195 if is_cache_file(os.path.basename(path))] | 185 if is_cache_file(os.path.basename(path))] |
| 196 for cache_file in cache_files: | 186 for cache_file in cache_files: |
| 197 os.remove(cache_file) | 187 os.remove(cache_file) |
| 198 | 188 |
| 199 def identical_file(reference_filename, output_filename): | 189 def identical_file(reference_filename, output_filename): |
| 200 reference_basename = os.path.basename(reference_filename) | 190 reference_basename = os.path.basename(reference_filename) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 301 |
| 312 | 302 |
| 313 def run_bindings_tests(reset_results, verbose): | 303 def run_bindings_tests(reset_results, verbose): |
| 314 # Generate output into the reference directory if resetting results, or | 304 # Generate output into the reference directory if resetting results, or |
| 315 # a temp directory if not. | 305 # a temp directory if not. |
| 316 if reset_results: | 306 if reset_results: |
| 317 print 'Resetting results' | 307 print 'Resetting results' |
| 318 return bindings_tests(reference_directory, verbose) | 308 return bindings_tests(reference_directory, verbose) |
| 319 with TemporaryDirectory() as temp_dir: | 309 with TemporaryDirectory() as temp_dir: |
| 320 return bindings_tests(temp_dir, verbose) | 310 return bindings_tests(temp_dir, verbose) |
| OLD | NEW |