Changeset 180830 in webkit


Ignore:
Timestamp:
Feb 28, 2015 3:49:20 AM (9 years ago)
Author:
youenn.fablet@crf.canon.fr
Message:

W3C test importer should use filesystem to read and write files
https://bugs.webkit.org/show_bug.cgi?id=142084

Reviewed by Bem Jones-Bey.

Use of FileSystem.write_binary_file, read_text_file and write_text_file in lieu of open().

  • Scripts/webkitpy/w3c/test_importer.py:

(TestImporter.import_tests):
(TestImporter.remove_deleted_files):
(TestImporter.write_import_log):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r180798 r180830  
     12015-02-28  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        W3C test importer should use filesystem to read and write files
     4        https://bugs.webkit.org/show_bug.cgi?id=142084
     5
     6        Reviewed by Bem Jones-Bey.
     7
     8        Use of FileSystem.write_binary_file, read_text_file and write_text_file in lieu of open().
     9
     10        * Scripts/webkitpy/w3c/test_importer.py:
     11        (TestImporter.import_tests):
     12        (TestImporter.remove_deleted_files):
     13        (TestImporter.write_import_log):
     14
    1152015-02-27  Sam Weinig  <sam@webkit.org>
    216
  • trunk/Tools/Scripts/webkitpy/w3c/test_importer.py

    r180635 r180830  
    326326                        prefixed_property_values.extend(set(converted_file[1]) - set(prefixed_property_values))
    327327
    328                         outfile = open(new_filepath, 'wb')
    329                         outfile.write(converted_file[2])
    330                         outfile.close()
     328                        self.filesystem.write_binary_file(new_filepath, converted_file[2])
    331329                elif orig_filepath.endswith('__init__.py') and not self.filesystem.getsize(orig_filepath):
    332330                    # Some bots dislike empty __init__.py.
     
    368366            return
    369367
    370         import_log = open(import_log_file, 'r')
    371         contents = import_log.readlines()
     368        contents = self.filesystem.read_text_file(import_log_file).split('\n')
    372369
    373370        if 'List of files\n' in contents:
     
    381378            os.remove(deleted_file)
    382379
    383         import_log.close()
    384 
    385380    def write_import_log(self, import_directory, file_list, prop_list, property_values_list):
    386381        """ Writes a w3c-import.log file in each directory with imported files. """
    387382
    388         import_log = open(os.path.join(import_directory, 'w3c-import.log'), 'w')
    389         import_log.write('The tests in this directory were imported from the W3C repository.\n')
    390         import_log.write('Do NOT modify these tests directly in Webkit.\n')
    391         import_log.write('Instead, push changes to the W3C CSS repo:\n')
    392         import_log.write('\thttp://hg.csswg.org/test\n')
    393         import_log.write('Or create a pull request on the W3C CSS github:\n')
    394         import_log.write('\thttps://github.com/w3c/csswg-test\n\n')
    395         import_log.write('Then run the Tools/Scripts/import-w3c-tests in Webkit to reimport\n\n')
    396         import_log.write('Do NOT modify or remove this file\n\n')
    397         import_log.write('------------------------------------------------------------------------\n')
    398         import_log.write('Properties requiring vendor prefixes:\n')
     383        import_log = []
     384        import_log.append('The tests in this directory were imported from the W3C repository.\n')
     385        import_log.append('Do NOT modify these tests directly in Webkit.\n')
     386        import_log.append('Instead, push changes to the W3C CSS repo:\n')
     387        import_log.append('\thttp://hg.csswg.org/test\n')
     388        import_log.append('Or create a pull request on the W3C CSS github:\n')
     389        import_log.append('\thttps://github.com/w3c/csswg-test\n\n')
     390        import_log.append('Then run the Tools/Scripts/import-w3c-tests in Webkit to reimport\n\n')
     391        import_log.append('Do NOT modify or remove this file\n\n')
     392        import_log.append('------------------------------------------------------------------------\n')
     393        import_log.append('Properties requiring vendor prefixes:\n')
    399394        if prop_list:
    400395            for prop in prop_list:
    401                 import_log.write(prop + '\n')
     396                import_log.append(prop + '\n')
    402397        else:
    403             import_log.write('None\n')
    404         import_log.write('Property values requiring vendor prefixes:\n')
     398            import_log.append('None\n')
     399        import_log.append('Property values requiring vendor prefixes:\n')
    405400        if property_values_list:
    406401            for value in property_values_list:
    407                 import_log.write(value + '\n')
     402                import_log.append(value + '\n')
    408403        else:
    409             import_log.write('None\n')
    410         import_log.write('------------------------------------------------------------------------\n')
    411         import_log.write('List of files:\n')
     404            import_log.append('None\n')
     405        import_log.append('------------------------------------------------------------------------\n')
     406        import_log.append('List of files:\n')
    412407        for item in sorted(file_list):
    413             import_log.write(item + '\n')
    414 
    415         import_log.close()
     408            import_log.append(item + '\n')
     409
     410        self.filesystem.write_text_file(self.filesystem.join(import_directory, 'w3c-import.log'), ''.join(import_log))
Note: See TracChangeset for help on using the changeset viewer.