Index: Tools/Scripts/webkitpy/bindings/main.py |
diff --git a/Tools/Scripts/webkitpy/bindings/main.py b/Tools/Scripts/webkitpy/bindings/main.py |
index 7671ec0a61ebfa3da0a16f0d8dbfabf3a5749a6a..8a88f51adf9494d9d223bb42b139b71ab6831a4e 100644 |
--- a/Tools/Scripts/webkitpy/bindings/main.py |
+++ b/Tools/Scripts/webkitpy/bindings/main.py |
@@ -72,6 +72,11 @@ COMPONENT_DIRECTORY = frozenset(['core', 'modules']) |
test_input_directory = os.path.join(source_path, 'bindings', 'tests', 'idls') |
reference_directory = os.path.join(source_path, 'bindings', 'tests', 'results') |
+PLY_LEX_YACC_FILES = frozenset([ |
+ 'lextab.py', # PLY lex |
+ 'lextab.pyc', |
+ 'parsetab.pickle', # PLY yacc |
+]) |
@contextmanager |
def TemporaryDirectory(): |
@@ -125,6 +130,16 @@ def generate_interface_dependencies(): |
def bindings_tests(output_directory, verbose): |
executive = Executive() |
+ def list_files(directory): |
+ files = [] |
+ for component in os.listdir(directory): |
+ if component not in COMPONENT_DIRECTORY: |
+ continue |
+ directory_with_component = os.path.join(directory, component) |
+ for filename in os.listdir(directory_with_component): |
+ files.append(os.path.join(directory_with_component, filename)) |
+ return files |
+ |
def diff(filename1, filename2): |
# Python's difflib module is too slow, especially on long output, so |
# run external diff(1) command |
@@ -137,14 +152,17 @@ def bindings_tests(output_directory, verbose): |
# non-zero exit if files differ. |
return executive.run_command(cmd, error_handler=lambda x: None) |
+ def is_cache_file(filename): |
+ if filename in PLY_LEX_YACC_FILES: |
+ return True |
+ if filename.endswith('.cache'): # Jinja |
+ return True |
+ return False |
+ |
def delete_cache_files(): |
# FIXME: Instead of deleting cache files, don't generate them. |
- cache_files = [os.path.join(output_directory, output_file) |
- for output_file in os.listdir(output_directory) |
- if (output_file in ('lextab.py', # PLY lex |
- 'lextab.pyc', |
- 'parsetab.pickle') or # PLY yacc |
- output_file.endswith('.cache'))] # Jinja |
+ cache_files = [path for path in list_files(output_directory) |
+ if is_cache_file(os.path.basename(path))] |
for cache_file in cache_files: |
os.remove(cache_file) |
@@ -169,19 +187,25 @@ def bindings_tests(output_directory, verbose): |
print 'PASS: %s' % reference_basename |
return True |
- def identical_output_files(): |
- file_pairs = [(os.path.join(reference_directory, output_file), |
- os.path.join(output_directory, output_file)) |
- for output_file in os.listdir(output_directory)] |
+ def identical_output_files(output_files): |
+ reference_files = [os.path.join(reference_directory, |
+ os.path.relpath(path, output_directory)) |
+ for path in output_files] |
return all([identical_file(reference_filename, output_filename) |
- for (reference_filename, output_filename) in file_pairs]) |
- |
- def no_excess_files(): |
- generated_files = set(os.listdir(output_directory)) |
- generated_files.add('.svn') # Subversion working copy directory |
- excess_files = [output_file |
- for output_file in os.listdir(reference_directory) |
- if output_file not in generated_files] |
+ for (reference_filename, output_filename) in zip(reference_files, output_files)]) |
+ |
+ def no_excess_files(output_files): |
+ generated_files = set([os.path.relpath(path, output_directory) |
+ for path in output_files]) |
+ # Add subversion working copy directories in core and modules. |
+ for component in COMPONENT_DIRECTORY: |
+ generated_files.add(os.path.join(component, '.svn')) |
+ |
+ excess_files = [] |
+ for path in list_files(reference_directory): |
+ relpath = os.path.relpath(path, reference_directory) |
+ if relpath not in generated_files: |
+ excess_files.append(relpath) |
if excess_files: |
print ('Excess reference files! ' |
'(probably cruft from renaming or deleting):\n' + |
@@ -191,15 +215,19 @@ def bindings_tests(output_directory, verbose): |
try: |
generate_interface_dependencies() |
- idl_compiler = IdlCompilerV8(output_directory, |
- interfaces_info=interfaces_info, |
- only_if_changed=True) |
- dictionary_impl_compiler = IdlCompilerDictionaryImpl( |
- output_directory, interfaces_info=interfaces_info, |
- only_if_changed=True) |
- |
- idl_filenames = [] |
for component in COMPONENT_DIRECTORY: |
+ output_dir = os.path.join(output_directory, component) |
+ if not os.path.exists(output_dir): |
+ os.makedirs(output_dir) |
+ |
+ idl_compiler = IdlCompilerV8(output_dir, |
+ interfaces_info=interfaces_info, |
+ only_if_changed=True) |
+ dictionary_impl_compiler = IdlCompilerDictionaryImpl( |
+ output_dir, interfaces_info=interfaces_info, |
+ only_if_changed=True) |
+ |
+ idl_filenames = [] |
input_directory = os.path.join(test_input_directory, component) |
for filename in os.listdir(input_directory): |
if (filename.endswith('.idl') and |
@@ -209,21 +237,21 @@ def bindings_tests(output_directory, verbose): |
idl_filenames.append( |
os.path.realpath( |
os.path.join(input_directory, filename))) |
- for idl_path in idl_filenames: |
- idl_basename = os.path.basename(idl_path) |
- idl_compiler.compile_file(idl_path) |
- definition_name, _ = os.path.splitext(idl_basename) |
- if (definition_name in interfaces_info and |
- interfaces_info[definition_name]['is_dictionary']): |
- dictionary_impl_compiler.compile_file(idl_path) |
- if verbose: |
- print 'Compiled: %s' % idl_path |
+ for idl_path in idl_filenames: |
+ idl_basename = os.path.basename(idl_path) |
+ idl_compiler.compile_file(idl_path) |
+ definition_name, _ = os.path.splitext(idl_basename) |
+ if (definition_name in interfaces_info and interfaces_info[definition_name]['is_dictionary']): |
+ dictionary_impl_compiler.compile_file(idl_path) |
+ if verbose: |
+ print 'Compiled: %s' % idl_path |
finally: |
delete_cache_files() |
# Detect all changes |
- passed = identical_output_files() |
- passed &= no_excess_files() |
+ output_files = list_files(output_directory) |
+ passed = identical_output_files(output_files) |
+ passed &= no_excess_files(output_files) |
if passed: |
if verbose: |