Changeset 180844 in webkit
- Timestamp:
- Feb 28, 2015 2:47:40 PM (9 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r180830 r180844 1 2015-02-28 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 W3C importer should use filesystem instead of shutil/host 4 https://bugs.webkit.org/show_bug.cgi?id=142012 5 6 Reviewed by Bem Jones-Bey. 7 8 Removed direct use of python shutil and os, except for os.walk which will require its own fix. 9 10 * Scripts/webkitpy/w3c/test_importer.py: 11 (main): 12 (TestImporter.do_import): 13 (TestImporter.find_importable_tests): 14 (TestImporter.import_tests): 15 (TestImporter.remove_deleted_files): 16 (TestImporter.write_import_log): 17 1 18 2015-02-28 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 19 -
trunk/Tools/Scripts/webkitpy/w3c/test_importer.py
r180830 r180844 69 69 """ 70 70 71 # FIXME: Change this file to use the Host abstractions rather that os, sys, shutils, etc.72 73 71 import argparse 74 72 import datetime … … 76 74 import mimetypes 77 75 import os 78 import shutil79 76 import sys 80 77 81 78 from webkitpy.common.host import Host 79 from webkitpy.common.system.filesystem import FileSystem 82 80 from webkitpy.common.webkit_finder import WebKitFinder 83 81 from webkitpy.common.system.executive import ScriptError … … 93 91 options, args = parse_args(_argv) 94 92 import_dir = args[0] 95 96 if not os.path.exists(import_dir):93 filesystem = FileSystem() 94 if not filesystem.exists(import_dir): 97 95 sys.exit('Source directory %s not found!' % import_dir) 98 96 … … 161 159 else: 162 160 for test_path in self.options.test_paths: 163 self.find_importable_tests( os.path.join(self.source_directory, test_path))161 self.find_importable_tests(self.filesystem.join(self.source_directory, test_path)) 164 162 self.import_tests() 165 163 … … 195 193 continue 196 194 197 fullpath = os.path.join(root, filename)195 fullpath = self.filesystem.join(root, filename) 198 196 199 197 mimetype = mimetypes.guess_type(fullpath) … … 206 204 if test_info is None: 207 205 # If html file is in a "resources" folder, it should be copied anyway 208 if os.path.basename(os.path.dirname(fullpath)) == "resources":206 if self.filesystem.basename(self.filesystem.dirname(fullpath)) == "resources": 209 207 copy_list.append({'src': fullpath, 'dest': filename}) 210 208 continue … … 213 211 reftests += 1 214 212 total_tests += 1 215 test_basename = os.path.basename(test_info['test'])213 test_basename = self.filesystem.basename(test_info['test']) 216 214 217 215 # Add the ref file, following WebKit style. … … 220 218 # Using a naming convention creates duplicate copies of the 221 219 # reference files. 222 ref_file = os.path.splitext(test_basename)[0] + '-expected'223 ref_file += os.path.splitext(test_basename)[1]220 ref_file = self.filesystem.splitext(test_basename)[0] + '-expected' 221 ref_file += self.filesystem.splitext(test_basename)[1] 224 222 225 223 copy_list.append({'src': test_info['reference'], 'dest': ref_file, 'reference_support_info': test_info['reference_support_info']}) … … 261 259 orig_path = dir_to_copy['dirname'] 262 260 263 subpath = os.path.relpath(orig_path, self.source_directory)264 new_path = os.path.join(self.destination_directory, subpath)265 266 if not( os.path.exists(new_path)):267 os.makedirs(new_path)261 subpath = self.filesystem.relpath(orig_path, self.source_directory) 262 new_path = self.filesystem.join(self.destination_directory, subpath) 263 264 if not(self.filesystem.exists(new_path)): 265 self.filesystem.maybe_make_directory(new_path) 268 266 269 267 copied_files = [] … … 271 269 for file_to_copy in dir_to_copy['copy_list']: 272 270 # FIXME: Split this block into a separate function. 273 orig_filepath = os.path.normpath(file_to_copy['src'])274 275 if os.path.isdir(orig_filepath):271 orig_filepath = self.filesystem.normpath(file_to_copy['src']) 272 273 if self.filesystem.isdir(orig_filepath): 276 274 # FIXME: Figure out what is triggering this and what to do about it. 277 275 _log.error('%s refers to a directory' % orig_filepath) 278 276 continue 279 277 280 if not( os.path.exists(orig_filepath)):278 if not(self.filesystem.exists(orig_filepath)): 281 279 _log.warning('%s not found. Possible error in the test.', orig_filepath) 282 280 continue 283 281 284 new_filepath = os.path.join(new_path, file_to_copy['dest'])282 new_filepath = self.filesystem.join(new_path, file_to_copy['dest']) 285 283 if 'reference_support_info' in file_to_copy.keys() and file_to_copy['reference_support_info'] != {}: 286 284 reference_support_info = file_to_copy['reference_support_info'] … … 288 286 reference_support_info = None 289 287 290 if not( os.path.exists(os.path.dirname(new_filepath))):291 os.makedirs(os.path.dirname(new_filepath))292 293 if not self.options.overwrite and os.path.exists(new_filepath):288 if not(self.filesystem.exists(self.filesystem.dirname(new_filepath))): 289 self.filesystem.maybe_make_directory(self.filesystem.dirname(new_filepath)) 290 291 if not self.options.overwrite and self.filesystem.exists(new_filepath): 294 292 _log.info('Skipping import of existing file ' + new_filepath) 295 293 else: … … 312 310 313 311 if not converted_file: 314 s hutil.copyfile(orig_filepath, new_filepath) # The file was unmodified.312 self.filesystem.copyfile(orig_filepath, new_filepath) # The file was unmodified. 315 313 else: 316 314 for prefixed_property in converted_file[0]: … … 331 329 self.filesystem.write_text_file(new_filepath, '# This file is required for Python to search this directory for modules.') 332 330 else: 333 s hutil.copyfile(orig_filepath, new_filepath)331 self.filesystem.copyfile(orig_filepath, new_filepath) 334 332 335 333 copied_files.append(new_filepath.replace(self._webkit_root, '')) … … 362 360 previous_file_list = [] 363 361 364 import_log_file = os.path.join(import_directory, 'w3c-import.log')365 if not os.path.exists(import_log_file):362 import_log_file = self.filesystem.join(import_directory, 'w3c-import.log') 363 if not self.filesystem.exists(import_log_file): 366 364 return 367 365 … … 375 373 for deleted_file in deleted_files: 376 374 _log.info('Deleting file removed from the W3C repo: %s', deleted_file) 377 deleted_file = os.path.join(self._webkit_root, deleted_file)378 os.remove(deleted_file)375 deleted_file = self.filesystem.join(self._webkit_root, deleted_file) 376 self.filesystem.remove(deleted_file) 379 377 380 378 def write_import_log(self, import_directory, file_list, prop_list, property_values_list):
Note: See TracChangeset
for help on using the changeset viewer.