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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 COMPONENT_DIRECTORY = frozenset(['core', 'modules']) | 80 COMPONENT_DIRECTORY = frozenset(['core', 'modules']) |
81 | 81 |
82 test_input_directory = os.path.join(source_path, 'bindings', 'tests', 'idls') | 82 test_input_directory = os.path.join(source_path, 'bindings', 'tests', 'idls') |
83 reference_directory = os.path.join(source_path, 'bindings', 'tests', 'results') | 83 reference_directory = os.path.join(source_path, 'bindings', 'tests', 'results') |
84 | 84 |
85 # component -> ComponentInfoProvider. | 85 # component -> ComponentInfoProvider. |
86 # Note that this dict contains information about testing idl files, which live | 86 # Note that this dict contains information about testing idl files, which live |
87 # in Source/bindings/tests/idls/{core,modules}, not in Source/{core,modules}. | 87 # in Source/bindings/tests/idls/{core,modules}, not in Source/{core,modules}. |
88 component_info_providers = {} | 88 component_info_providers = {} |
89 | 89 |
| 90 |
90 @contextmanager | 91 @contextmanager |
91 def TemporaryDirectory(): | 92 def TemporaryDirectory(): |
92 """Wrapper for tempfile.mkdtemp() so it's usable with 'with' statement. | 93 """Wrapper for tempfile.mkdtemp() so it's usable with 'with' statement. |
93 | 94 |
94 Simple backport of tempfile.TemporaryDirectory from Python 3.2. | 95 Simple backport of tempfile.TemporaryDirectory from Python 3.2. |
95 """ | 96 """ |
96 name = tempfile.mkdtemp() | 97 name = tempfile.mkdtemp() |
97 try: | 98 try: |
98 yield name | 99 yield name |
99 finally: | 100 finally: |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 for component in COMPONENT_DIRECTORY: | 254 for component in COMPONENT_DIRECTORY: |
254 generated_files.add(os.path.join(component, '.svn')) | 255 generated_files.add(os.path.join(component, '.svn')) |
255 | 256 |
256 excess_files = [] | 257 excess_files = [] |
257 for path in list_files(reference_directory): | 258 for path in list_files(reference_directory): |
258 relpath = os.path.relpath(path, reference_directory) | 259 relpath = os.path.relpath(path, reference_directory) |
259 if relpath not in generated_files: | 260 if relpath not in generated_files: |
260 excess_files.append(relpath) | 261 excess_files.append(relpath) |
261 if excess_files: | 262 if excess_files: |
262 print ('Excess reference files! ' | 263 print ('Excess reference files! ' |
263 '(probably cruft from renaming or deleting):\n' + | 264 '(probably cruft from renaming or deleting):\n' + |
264 '\n'.join(excess_files)) | 265 '\n'.join(excess_files)) |
265 return False | 266 return False |
266 return True | 267 return True |
267 | 268 |
268 def generate_union_type_containers(output_directory, component): | 269 def generate_union_type_containers(output_directory, component): |
269 generator = CodeGeneratorUnionType( | 270 generator = CodeGeneratorUnionType( |
270 component_info_providers[component], cache_dir=None, | 271 component_info_providers[component], cache_dir=None, |
271 output_dir=output_directory, target_component=component) | 272 output_dir=output_directory, target_component=component) |
272 outputs = generator.generate_code() | 273 outputs = generator.generate_code() |
273 for output_path, output_code in outputs: | 274 for output_path, output_code in outputs: |
274 write_file(output_code, output_path, only_if_changed=True) | 275 write_file(output_code, output_path, only_if_changed=True) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 345 |
345 | 346 |
346 def run_bindings_tests(reset_results, verbose): | 347 def run_bindings_tests(reset_results, verbose): |
347 # Generate output into the reference directory if resetting results, or | 348 # Generate output into the reference directory if resetting results, or |
348 # a temp directory if not. | 349 # a temp directory if not. |
349 if reset_results: | 350 if reset_results: |
350 print 'Resetting results' | 351 print 'Resetting results' |
351 return bindings_tests(reference_directory, verbose) | 352 return bindings_tests(reference_directory, verbose) |
352 with TemporaryDirectory() as temp_dir: | 353 with TemporaryDirectory() as temp_dir: |
353 return bindings_tests(temp_dir, verbose) | 354 return bindings_tests(temp_dir, verbose) |
OLD | NEW |