Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/bindings/bindings_tests.py

Issue 2166223002: Rename Tools/Scripts/webkitpy/bindings/main.py to bindings_tests.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 19 matching lines...) Expand all
30 import sys 30 import sys
31 import tempfile 31 import tempfile
32 32
33 from webkitpy.common.system.executive import Executive 33 from webkitpy.common.system.executive import Executive
34 34
35 # Source/ path is needed both to find input IDL files, and to import other 35 # Source/ path is needed both to find input IDL files, and to import other
36 # Python modules. 36 # Python modules.
37 module_path = os.path.dirname(__file__) 37 module_path = os.path.dirname(__file__)
38 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir, 38 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir,
39 os.pardir, os.pardir, 'Source')) 39 os.pardir, os.pardir, 'Source'))
40 sys.path.append(source_path) # for Source/bindings imports 40 bindings_script_path = os.path.join(source_path, 'bindings', 'scripts')
41 sys.path.append(bindings_script_path) # for Source/bindings imports
41 42
42 from bindings.scripts.code_generator_v8 import CodeGeneratorUnionType 43 from code_generator_v8 import CodeGeneratorUnionType
43 import bindings.scripts.compute_interfaces_info_individual 44 from compute_interfaces_info_individual import InterfaceInfoCollector
44 from bindings.scripts.compute_interfaces_info_individual import InterfaceInfoCol lector 45 from compute_interfaces_info_overall import compute_interfaces_info_overall, int erfaces_info
45 import bindings.scripts.compute_interfaces_info_overall 46 from idl_compiler import IdlCompilerDictionaryImpl, IdlCompilerV8
46 from bindings.scripts.compute_interfaces_info_overall import compute_interfaces_ info_overall, interfaces_info 47 from utilities import ComponentInfoProviderCore
47 from bindings.scripts.idl_compiler import IdlCompilerDictionaryImpl, IdlCompiler V8 48 from utilities import ComponentInfoProviderModules
48 from bindings.scripts.idl_reader import IdlReader 49 from utilities import write_file
49 from bindings.scripts.utilities import ComponentInfoProviderCore
50 from bindings.scripts.utilities import ComponentInfoProviderModules
51 from bindings.scripts.utilities import idl_filename_to_component
52 from bindings.scripts.utilities import write_file
53 50
54 51
55 PASS_MESSAGE = 'All tests PASS!' 52 PASS_MESSAGE = 'All tests PASS!'
56 FAIL_MESSAGE = """Some tests FAIL! 53 FAIL_MESSAGE = """Some tests FAIL!
57 To update the reference files, execute: 54 To update the reference files, execute:
58 run-bindings-tests --reset-results 55 run-bindings-tests --reset-results
59 56
60 If the failures are not due to your changes, test results may be out of sync; 57 If the failures are not due to your changes, test results may be out of sync;
61 please rebaseline them in a separate CL, after checking that tests fail in ToT. 58 please rebaseline them in a separate CL, after checking that tests fail in ToT.
62 In CL, please set: 59 In CL, please set:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 95
99 Simple backport of tempfile.TemporaryDirectory from Python 3.2. 96 Simple backport of tempfile.TemporaryDirectory from Python 3.2.
100 """ 97 """
101 name = tempfile.mkdtemp() 98 name = tempfile.mkdtemp()
102 try: 99 try:
103 yield name 100 yield name
104 finally: 101 finally:
105 shutil.rmtree(name) 102 shutil.rmtree(name)
106 103
107 104
108 def generate_interface_dependencies(output_directory): 105 def generate_interface_dependencies():
109 def idl_paths_recursive(directory): 106 def idl_paths_recursive(directory):
110 # This is slow, especially on Windows, due to os.walk making 107 # This is slow, especially on Windows, due to os.walk making
111 # 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
112 # later: 109 # later:
113 # https://github.com/benhoyt/scandir 110 # https://github.com/benhoyt/scandir
114 # http://bugs.python.org/issue11406 111 # http://bugs.python.org/issue11406
115 idl_paths = [] 112 idl_paths = []
116 for dirpath, _, files in os.walk(directory): 113 for dirpath, _, files in os.walk(directory):
117 idl_paths.extend(os.path.join(dirpath, filename) 114 idl_paths.extend(os.path.join(dirpath, filename)
118 for filename in fnmatch.filter(files, '*.idl')) 115 for filename in fnmatch.filter(files, '*.idl'))
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 269
273 def generate_union_type_containers(output_directory, component): 270 def generate_union_type_containers(output_directory, component):
274 generator = CodeGeneratorUnionType( 271 generator = CodeGeneratorUnionType(
275 component_info_providers[component], cache_dir=None, 272 component_info_providers[component], cache_dir=None,
276 output_dir=output_directory, target_component=component) 273 output_dir=output_directory, target_component=component)
277 outputs = generator.generate_code() 274 outputs = generator.generate_code()
278 for output_path, output_code in outputs: 275 for output_path, output_code in outputs:
279 write_file(output_code, output_path, only_if_changed=True) 276 write_file(output_code, output_path, only_if_changed=True)
280 277
281 try: 278 try:
282 generate_interface_dependencies(output_directory) 279 generate_interface_dependencies()
283 for component in COMPONENT_DIRECTORY: 280 for component in COMPONENT_DIRECTORY:
284 output_dir = os.path.join(output_directory, component) 281 output_dir = os.path.join(output_directory, component)
285 if not os.path.exists(output_dir): 282 if not os.path.exists(output_dir):
286 os.makedirs(output_dir) 283 os.makedirs(output_dir)
287 284
288 generate_union_type_containers(output_dir, component) 285 generate_union_type_containers(output_dir, component)
289 286
290 idl_compiler = IdlCompilerV8( 287 idl_compiler = IdlCompilerV8(
291 output_dir, 288 output_dir,
292 info_provider=component_info_providers[component], 289 info_provider=component_info_providers[component],
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 346
350 347
351 def run_bindings_tests(reset_results, verbose): 348 def run_bindings_tests(reset_results, verbose):
352 # Generate output into the reference directory if resetting results, or 349 # Generate output into the reference directory if resetting results, or
353 # a temp directory if not. 350 # a temp directory if not.
354 if reset_results: 351 if reset_results:
355 print 'Resetting results' 352 print 'Resetting results'
356 return bindings_tests(reference_directory, verbose) 353 return bindings_tests(reference_directory, verbose)
357 with TemporaryDirectory() as temp_dir: 354 with TemporaryDirectory() as temp_dir:
358 return bindings_tests(temp_dir, verbose) 355 return bindings_tests(temp_dir, verbose)
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/run-bindings-tests ('k') | third_party/WebKit/Tools/Scripts/webkitpy/bindings/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698