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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 for filename in fnmatch.filter(files, '*.idl')) | 139 for filename in fnmatch.filter(files, '*.idl')) |
140 return idl_paths | 140 return idl_paths |
141 | 141 |
142 def write_list_file(idl_paths): | 142 def write_list_file(idl_paths): |
143 list_file, list_filename = self.provider.new_temp_file() | 143 list_file, list_filename = self.provider.new_temp_file() |
144 list_contents = ''.join(idl_path + '\n' | 144 list_contents = ''.join(idl_path + '\n' |
145 for idl_path in idl_paths) | 145 for idl_path in idl_paths) |
146 os.write(list_file, list_contents) | 146 os.write(list_file, list_contents) |
147 return list_filename | 147 return list_filename |
148 | 148 |
149 def compute_interfaces_info(idl_files_list_filename, | 149 def generate_event_interfaces(event_names_filename): |
150 event_names_filename): | |
151 cmd = ['python', | 150 cmd = ['python', |
152 'bindings/scripts/compute_interfaces_info.py', | 151 'bindings/scripts/generate_event_interfaces.py', |
153 '--idl-files-list', idl_files_list_filename, | |
154 '--interfaces-info-file', self.interfaces_info_filename, | 152 '--interfaces-info-file', self.interfaces_info_filename, |
155 '--event-names-file', event_names_filename, | 153 '--event-names-file', event_names_filename, |
156 '--write-file-only-if-changed', '0'] | 154 '--write-file-only-if-changed', '0'] |
157 self.run_command(cmd) | 155 self.run_command(cmd) |
158 | 156 |
| 157 def compute_interfaces_info(idl_files_list_filename): |
| 158 cmd = ['python', |
| 159 'bindings/scripts/compute_interfaces_info.py', |
| 160 '--idl-files-list', idl_files_list_filename, |
| 161 '--interfaces-info-file', self.interfaces_info_filename, |
| 162 '--write-file-only-if-changed', '0'] |
| 163 self.run_command(cmd) |
| 164 |
159 test_idl_files_list_filename = write_list_file(idl_paths(test_input_dire
ctory)) | 165 test_idl_files_list_filename = write_list_file(idl_paths(test_input_dire
ctory)) |
160 all_idl_files_list_filename = write_list_file(idl_paths_recursive(all_in
put_directory)) | 166 all_idl_files_list_filename = write_list_file(idl_paths_recursive(all_in
put_directory)) |
161 | 167 |
162 if self.reset_results and self.verbose: | 168 if self.reset_results and self.verbose: |
163 print 'Reset results: EventInterfaces.in' | 169 print 'Reset results: EventInterfaces.in' |
164 try: | 170 try: |
165 # We first compute interfaces info for testing files only, | 171 # We first compute interfaces info for testing files only, |
166 # so we can compare EventInterfaces.in. | 172 # so we can compare EventInterfaces.in. |
167 compute_interfaces_info(test_idl_files_list_filename, | 173 compute_interfaces_info(test_idl_files_list_filename) |
168 self.event_names_filename) | 174 generate_event_interfaces(self.event_names_filename) |
169 | 175 |
170 # We then compute interfaces info for all IDL files, as code | 176 # We then compute interfaces info for all IDL files, as code |
171 # generator output depends on inheritance (both ancestor chain and | 177 # generator output depends on inheritance (both ancestor chain and |
172 # inherited extended attributes), and some real interfaces are | 178 # inherited extended attributes), and some real interfaces are |
173 # special-cased, such as Node. | 179 # special-cased, such as Node. |
174 # For example, when testing the behavior of interfaces that inherit | 180 # For example, when testing the behavior of interfaces that inherit |
175 # from Node, we also need to know that these inherit from | 181 # from Node, we also need to know that these inherit from |
176 # EventTarget, since this is also special-cased and Node inherits | 182 # EventTarget, since this is also special-cased and Node inherits |
177 # from EventTarget, but this inheritance information requires | 183 # from EventTarget, but this inheritance information requires |
178 # computing dependencies for the real Node.idl file. | 184 # computing dependencies for the real Node.idl file. |
179 # | 185 # |
180 # Don't overwrite the event names file generated for testing IDLs | 186 # Don't overwrite the event names file generated for testing IDLs |
181 _, dummy_event_names_filename = self.provider.new_temp_file() | 187 compute_interfaces_info(all_idl_files_list_filename) |
182 compute_interfaces_info(all_idl_files_list_filename, | |
183 dummy_event_names_filename) | |
184 except ScriptError, e: | 188 except ScriptError, e: |
185 print 'ERROR: compute_interfaces_info.py' | 189 print 'ERROR: compute_interfaces_info.py' |
186 print e.output | 190 print e.output |
187 return e.exit_code | 191 return e.exit_code |
188 return 0 | 192 return 0 |
189 | 193 |
190 def identical_file(self, reference_filename, output_filename): | 194 def identical_file(self, reference_filename, output_filename): |
191 reference_basename = os.path.basename(reference_filename) | 195 reference_basename = os.path.basename(reference_filename) |
192 cmd = ['diff', | 196 cmd = ['diff', |
193 '-u', | 197 '-u', |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 print PASS_MESSAGE | 272 print PASS_MESSAGE |
269 return 0 | 273 return 0 |
270 print | 274 print |
271 print FAIL_MESSAGE | 275 print FAIL_MESSAGE |
272 return -1 | 276 return -1 |
273 | 277 |
274 | 278 |
275 def run_bindings_tests(reset_results, verbose): | 279 def run_bindings_tests(reset_results, verbose): |
276 with ScopedTempFileProvider() as provider: | 280 with ScopedTempFileProvider() as provider: |
277 return BindingsTests(reset_results, verbose, provider).main() | 281 return BindingsTests(reset_results, verbose, provider).main() |
OLD | NEW |