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

Unified Diff: Tools/Scripts/webkitpy/bindings/main.py

Issue 169743005: Faster run-bindings-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed timings and fast is the only mode. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Tools/Scripts/webkitpy/bindings/main.py
diff --git a/Tools/Scripts/webkitpy/bindings/main.py b/Tools/Scripts/webkitpy/bindings/main.py
index 856a857d2ff75d4ff359c97a3e06a35763857563..6998d7a05b3f8205486c3be7ea2784e0d98e8324 100644
--- a/Tools/Scripts/webkitpy/bindings/main.py
+++ b/Tools/Scripts/webkitpy/bindings/main.py
@@ -24,12 +24,24 @@
import fnmatch
import os
-import cPickle as pickle
from shutil import rmtree
+import sys
import tempfile
from webkitpy.common.checkout.scm.detection import detect_scm_system
from webkitpy.common.system.executive import ScriptError
+# Add Source path to PYTHONPATH to support function calls to bindings/scripts
+# for compute_dependencies and idl_compiler
+module_path = os.path.dirname(__file__)
+source_path = os.path.normpath(os.path.join(module_path, os.pardir,
+ os.pardir, os.pardir, os.pardir,
+ 'Source'))
+sys.path.append(source_path)
+
+from bindings.scripts.compute_dependencies import compute
+from bindings.scripts.unstable.idl_compiler import compile_idl
+
+
PASS_MESSAGE = 'All tests PASS!'
FAIL_MESSAGE = """Some tests FAIL!
To update the reference files, execute:
@@ -54,6 +66,8 @@ DEPENDENCY_IDL_FILES = set([
SKIP_PYTHON = 'TestSVG.idl' # Not implementing SVG-specific hacks in Python
+EXTENDED_ATTRIBUTES_FILE = 'bindings/IDLExtendedAttributes.txt'
+
all_input_directory = '.' # Relative to Source/
test_input_directory = os.path.join('bindings', 'tests', 'idls')
reference_directory = os.path.join('bindings', 'tests', 'results')
@@ -86,10 +100,12 @@ provider = ScopedTempFileProvider()
class BindingsTests(object):
def __init__(self, reset_results, test_python, verbose, executive):
+ self.interfaces_info = {} # in-memory interfaces
self.reset_results = reset_results
self.test_python = test_python
self.verbose = verbose
self.executive = executive
+ self.reader = None
_, self.interface_dependencies_filename = provider.newtempfile()
_, self.interfaces_info_filename = provider.newtempfile()
# Generate output into the reference directory if resetting results, or
@@ -117,7 +133,7 @@ class BindingsTests(object):
'--include', '.',
'--outputDir', self.output_directory,
'--interfaceDependenciesFile', self.interface_dependencies_filename,
- '--idlAttributesFile', 'bindings/IDLExtendedAttributes.txt',
+ '--idlAttributesFile', EXTENDED_ATTRIBUTES_FILE,
idl_file]
try:
self.run_command(cmd)
@@ -128,18 +144,17 @@ class BindingsTests(object):
return 0
def generate_from_idl_py(self, idl_file):
- cmd = ['python',
- 'bindings/scripts/unstable/idl_compiler.py',
- '--output-dir', self.output_directory_py,
- '--idl-attributes-file', 'bindings/IDLExtendedAttributes.txt',
- '--interfaces-info-file', self.interfaces_info_filename,
- idl_file]
try:
- self.run_command(cmd)
+ idl_file_fullpath = os.path.realpath(idl_file)
+ self.reader = compile_idl(idl_file_fullpath,
+ self.output_directory_py,
+ EXTENDED_ATTRIBUTES_FILE,
+ self.interfaces_info, self.reader)
except ScriptError, e:
print 'ERROR: idl_compiler.py: ' + os.path.basename(idl_file)
print e.output
return e.exit_code
+
return 0
def generate_interface_dependencies(self):
@@ -162,38 +177,40 @@ class BindingsTests(object):
os.write(list_file, list_contents)
return list_filename
- def compute_dependencies(idl_files_list_filename,
- event_names_filename):
+ # Faster in-memory file list.
+ def list_idl_file(idl_paths):
+ idls = []
+ for idl_path in idl_paths:
+ idls.append(idl_path)
+ return idls
+
+ def compute_dependencies(idl_files_list, event_names_filename, pickle_name):
# Dummy files, required by compute_dependencies but not checked
_, window_constructors_file = provider.newtempfile()
_, workerglobalscope_constructors_file = provider.newtempfile()
_, sharedworkerglobalscope_constructors_file = provider.newtempfile()
_, dedicatedworkerglobalscope_constructors_file = provider.newtempfile()
_, serviceworkersglobalscope_constructors_file = provider.newtempfile()
- cmd = ['python',
- 'bindings/scripts/compute_dependencies.py',
- '--idl-files-list', idl_files_list_filename,
- '--interface-dependencies-file', self.interface_dependencies_filename,
- '--interfaces-info-file', self.interfaces_info_filename,
- '--window-constructors-file', window_constructors_file,
- '--workerglobalscope-constructors-file', workerglobalscope_constructors_file,
- '--sharedworkerglobalscope-constructors-file', sharedworkerglobalscope_constructors_file,
- '--dedicatedworkerglobalscope-constructors-file', dedicatedworkerglobalscope_constructors_file,
- '--serviceworkerglobalscope-constructors-file', serviceworkersglobalscope_constructors_file,
- '--event-names-file', event_names_filename,
- '--write-file-only-if-changed', '0']
- self.run_command(cmd)
- test_idl_files_list_filename = write_list_file(idl_paths(test_input_directory))
- all_idl_files_list_filename = write_list_file(idl_paths_recursive(all_input_directory))
+ return compute(idl_files_list,
+ self.interface_dependencies_filename,
+ window_constructors_file,
+ workerglobalscope_constructors_file,
+ sharedworkerglobalscope_constructors_file,
+ dedicatedworkerglobalscope_constructors_file,
+ serviceworkersglobalscope_constructors_file,
+ event_names_filename, False)
+
+ test_idl_files_list = list_idl_file(idl_paths(test_input_directory))
+ all_idl_files_list = list_idl_file(idl_paths_recursive(all_input_directory))
if self.reset_results and self.verbose:
print 'Reset results: EventInterfaces.in'
try:
# We first compute dependencies for testing files only,
# so we can compare EventInterfaces.in.
- compute_dependencies(test_idl_files_list_filename,
- self.event_names_filename)
+ compute_dependencies(test_idl_files_list, self.event_names_filename,
+ self.interfaces_info_filename)
# We then compute dependencies for all IDL files, as code generator
# output depends on inheritance (both ancestor chain and inherited
@@ -207,8 +224,9 @@ class BindingsTests(object):
#
# Don't overwrite the event names file generated for testing IDLs
_, dummy_event_names_filename = provider.newtempfile()
- compute_dependencies(all_idl_files_list_filename,
- dummy_event_names_filename)
+ self.interfaces_info = compute_dependencies(all_idl_files_list,
+ dummy_event_names_filename,
+ self.interfaces_info_filename)
except ScriptError, e:
print 'ERROR: compute_dependencies.py'
print e.output

Powered by Google App Engine
This is Rietveld 408576698