Changeset 202340 in webkit


Ignore:
Timestamp:
Jun 22, 2016 11:20:31 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

W3C test importer should generate files to ignore by WebKit SCM
https://bugs.webkit.org/show_bug.cgi?id=142743

Patch by Youenn Fablet <youenn.fablet@crf.canon.fr> on 2016-06-22
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

  • resources/TestRepositories: Added the option to generate .gitignore and init.py for wpt repo.
  • web-platform-tests/.gitignore: Regeneration changes the order of the ignored files and removes the init.py which is now committed to WebKit trunk.
  • web-platform-tests/init.py: Added.

Tools:

TestDownloader generates the .gitignore file according submodules git repository information.
TestImporter requests the generation of .gitignore and the main init.py according LayoutTests/imported/w3c/resources/TestRepositories options.

  • Scripts/webkitpy/w3c/test_downloader.py:

(TestDownloader.generate_gitignore): Generating .gitignore according submodules description.

  • Scripts/webkitpy/w3c/test_importer.py:

(TestImporter.process_test_repositories_import_options): Added the generation of .gitignore/init.py if the repo has the right option.
(TestImporter):
(TestImporter.write_init_py): Writing not empty init.py files.
(TestImporter.import_tests): Using of write_init_py.

  • Scripts/webkitpy/w3c/test_importer_unittest.py:

(TestImporterTest.test_git_ignore_generation): Added .gitignore test.
(TestImporterTest):
(TestImporterTest.test_initpy_generation): Added init.py test.

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r202338 r202340  
     12016-06-22  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        W3C test importer should generate files to ignore by WebKit SCM
     4        https://bugs.webkit.org/show_bug.cgi?id=142743
     5
     6        Reviewed by Darin Adler.
     7
     8        * resources/TestRepositories: Added the option to generate .gitignore and __init__.py for wpt repo.
     9        * web-platform-tests/.gitignore: Regeneration changes the order of the ignored files and removes the __init__.py which is now committed to WebKit trunk.
     10        * web-platform-tests/__init__.py: Added.
     11
    1122016-06-22  Youenn Fablet  <youennf@gmail.com>
    213
  • trunk/LayoutTests/imported/w3c/resources/TestRepositories

    r200309 r202340  
    3131            "serve.py"
    3232        ],
    33         "import_options": ["generate_git_submodules_description"]
     33        "import_options": ["generate_git_submodules_description", "generate_gitignore"]
    3434    }
    3535]
  • trunk/LayoutTests/imported/w3c/web-platform-tests/.gitignore

    r191043 r202340  
     1/resources/
    12/.resources.url
    2 /__init__.py
    3 
    4 /resources/
    5 
     3/resources/webidl2/
     4/resources/.webidl2.url
     5/resources/webidl2/test/widlproc/
     6/resources/webidl2/test/.widlproc.url
     7/tools/
    68/.tools.url
    7 /tools/
     9/tools/html5lib/
     10/tools/.html5lib.url
     11/tools/html5lib/html5lib/tests/testdata/
     12/tools/html5lib/html5lib/tests/.testdata.url
     13/tools/pytest/
     14/tools/.pytest.url
     15/tools/pywebsocket/
     16/tools/.pywebsocket.url
     17/tools/six/
     18/tools/.six.url
     19/tools/webdriver/
     20/tools/.webdriver.url
     21/tools/wptserve/
     22/tools/.wptserve.url
  • trunk/Tools/ChangeLog

    r202329 r202340  
     12016-06-22  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        W3C test importer should generate files to ignore by WebKit SCM
     4        https://bugs.webkit.org/show_bug.cgi?id=142743
     5
     6        Reviewed by Darin Adler.
     7
     8        TestDownloader generates the .gitignore file according submodules git repository information.
     9        TestImporter requests the generation of .gitignore and the main __init__.py according LayoutTests/imported/w3c/resources/TestRepositories options.
     10
     11        * Scripts/webkitpy/w3c/test_downloader.py:
     12        (TestDownloader.generate_gitignore): Generating .gitignore according submodules description.
     13        * Scripts/webkitpy/w3c/test_importer.py:
     14        (TestImporter.process_test_repositories_import_options): Added the generation of .gitignore/__init__.py if the repo has the right option.
     15        (TestImporter):
     16        (TestImporter.write_init_py): Writing not empty __init__.py files.
     17        (TestImporter.import_tests): Using  of write_init_py.
     18        * Scripts/webkitpy/w3c/test_importer_unittest.py:
     19        (TestImporterTest.test_git_ignore_generation): Added .gitignore test.
     20        (TestImporterTest):
     21        (TestImporterTest.test_initpy_generation): Added __init__.py test.
     22
    1232016-06-21  Sam Weinig  <sam@webkit.org>
    224
  • trunk/Tools/Scripts/webkitpy/w3c/test_downloader.py

    r197027 r202340  
    3232import logging
    3333
    34 from webkitpy.common.system.executive import Executive
    3534from webkitpy.common.system.filesystem import FileSystem
    3635from webkitpy.common.webkit_finder import WebKitFinder
     
    185184        self._filesystem.write_text_file(filepath, json.dumps(self._git_submodules_description(test_repository), sort_keys=True, indent=4))
    186185
     186    def generate_gitignore(self, test_repository, destination_directory):
     187        rules = []
     188        for submodule in self._git_submodules_description(test_repository):
     189            path = list(submodule['path'])
     190            path.insert(0, '')
     191            rules.append('/'.join(path[:-1]) + '/' + path[-1] + '/')
     192            rules.append('/'.join(path[:-1]) + '/.' + path[-1] + '.url')
     193        self._filesystem.write_text_file(self._filesystem.join(destination_directory, test_repository['name'], '.gitignore'), '\n'.join(rules))
     194
    187195    def download_tests(self, destination_directory, test_paths=[]):
    188196        for test_repository in self.test_repositories:
  • trunk/Tools/Scripts/webkitpy/w3c/test_importer.py

    r200109 r202340  
    211211                self.filesystem.maybe_make_directory(self.filesystem.join(self.destination_directory, 'resources'))
    212212                self._test_downloader.generate_git_submodules_description(test_repository, self.filesystem.join(self.destination_directory, 'resources', test_repository['name'] + '-modules.json'))
    213             # FIXME: Generate WPT .gitignore and  main __init__.py
     213            if 'generate_gitignore' in test_repository['import_options']:
     214                self._test_downloader.generate_gitignore(test_repository, self.destination_directory)
     215            if 'generate_init_py' in test_repository['import_options']:
     216                self.write_init_py(self.filesystem.join(self.destination_directory, test_repository['name'], '__init__.py'))
     217
     218    def write_init_py(self, filepath):
     219        self.filesystem.write_text_file(filepath, '# This file is required for Python to search this directory for modules.')
    214220
    215221    def test_downloader(self):
     
    429435                elif orig_filepath.endswith('__init__.py') and not self.filesystem.getsize(orig_filepath):
    430436                    # Some bots dislike empty __init__.py.
    431                     self.filesystem.write_text_file(new_filepath, '# This file is required for Python to search this directory for modules.')
     437                    self.write_init_py(new_filepath)
    432438                else:
    433439                    self.filesystem.copyfile(orig_filepath, new_filepath)
  • trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py

    r197163 r202340  
    2626# SUCH DAMAGE.
    2727
    28 import optparse
    29 import shutil
    30 import tempfile
    3128import unittest
    3229
     
    3734from webkitpy.w3c.test_downloader import TestDownloader
    3835from webkitpy.w3c.test_importer import parse_args, TestImporter
    39 
    4036
    4137FAKE_SOURCE_DIR = '/tests/csswg'
     
    6460        "paths_to_skip": [],
    6561        "paths_to_import": [],
    66         "import_options": ["generate_git_submodules_description"]
     62        "import_options": ["generate_git_submodules_description", "generate_gitignore", "generate_init_py"]
    6763    }
    6864]
     
    215211        self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/.svn'))
    216212
     213    def test_git_ignore_generation(self):
     214        FAKE_FILES = {
     215            '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/.gitmodules': '[submodule "tools/resources"]\n    path = tools/resources\n        url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
     216            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/.gitmodules': '[submodule "tools/resources"]\n     path = tools/resources\n        url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
     217        }
     218
     219        FAKE_FILES.update(FAKE_REPOSITORY)
     220
     221        fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)
     222
     223        self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/csswg-tests/.gitignore'))
     224        self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/.gitignore'))
     225        # We should activate these lines but this is not working in mock systems.
     226        #self.assertTrue('/tools/.resources.url' in fs.read_text_file('/mock-checkout/LayoutTests/w3c/web-platform-tests/.gitignore'))
     227        #self.assertTrue('/tools/resources/' in fs.read_text_file('/mock-checkout/LayoutTests/w3c/web-platform-tests/.gitignore'))
     228
     229    def test_initpy_generation(self):
     230        FAKE_FILES = {
     231            '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/.gitmodules': '[submodule "tools/resources"]\n    path = tools/resources\n        url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
     232            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/.gitmodules': '[submodule "tools/resources"]\n     path = tools/resources\n        url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
     233        }
     234
     235        FAKE_FILES.update(FAKE_REPOSITORY)
     236
     237        host = MockHost()
     238        host.executive = MockExecutive2()
     239        host.filesystem = MockFileSystem(files=FAKE_FILES)
     240
     241        fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)
     242
     243        self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/csswg-tests/__init__.py'))
     244        self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/__init__.py'))
     245        self.assertTrue(fs.getsize('/mock-checkout/LayoutTests/w3c/web-platform-tests/__init__.py') > 0)
     246
    217247    # FIXME: Needs more tests.
Note: See TracChangeset for help on using the changeset viewer.