Changeset 229921 in webkit


Ignore:
Timestamp:
Mar 23, 2018 2:19:37 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Lint web-platform-tests changes with the wpt linter before exporting
https://bugs.webkit.org/show_bug.cgi?id=183796

Patch by Brendan McLoughlin <brendan@bocoup.com> on 2018-03-23
Reviewed by Youenn Fablet.

  • Scripts/webkitpy/w3c/test_exporter.py:

(TestExporter.init):
(TestExporter.do_export):

  • Scripts/webkitpy/w3c/test_exporter_unittest.py:

(TestExporterTest.MockWPTLinter):
(TestExporterTest.MockWPTLinter.init):
(TestExporterTest.MockWPTLinter.lint):
(TestExporterTest.test_export):
(TestExporterTest.test_export_with_specific_branch):

  • Scripts/webkitpy/w3c/wpt_linter.py: Added.

(WPTLinter):
(WPTLinter.init):
(WPTLinter.lint):

Location:
trunk/Tools
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r229913 r229921  
     12018-03-23  Brendan McLoughlin  <brendan@bocoup.com>
     2
     3        Lint web-platform-tests changes with the wpt linter before exporting
     4        https://bugs.webkit.org/show_bug.cgi?id=183796
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * Scripts/webkitpy/w3c/test_exporter.py:
     9        (TestExporter.__init__):
     10        (TestExporter.do_export):
     11        * Scripts/webkitpy/w3c/test_exporter_unittest.py:
     12        (TestExporterTest.MockWPTLinter):
     13        (TestExporterTest.MockWPTLinter.__init__):
     14        (TestExporterTest.MockWPTLinter.lint):
     15        (TestExporterTest.test_export):
     16        (TestExporterTest.test_export_with_specific_branch):
     17        * Scripts/webkitpy/w3c/wpt_linter.py: Added.
     18        (WPTLinter):
     19        (WPTLinter.__init__):
     20        (WPTLinter.lint):
     21
    1222018-03-23  David Kilzer  <ddkilzer@apple.com>
    223
  • trunk/Tools/Scripts/webkitpy/w3c/test_exporter.py

    r229865 r229921  
    3535from webkitpy.common.webkit_finder import WebKitFinder
    3636from webkitpy.w3c.wpt_github import WPTGitHub
     37from webkitpy.w3c.wpt_linter import WPTLinter
    3738
    3839_log = logging.getLogger(__name__)
     
    4546class TestExporter(object):
    4647
    47     def __init__(self, host, options, gitClass=Git, bugzillaClass=Bugzilla, WPTGitHubClass=WPTGitHub):
     48    def __init__(self, host, options, gitClass=Git, bugzillaClass=Bugzilla, WPTGitHubClass=WPTGitHub, WPTLinterClass=WPTLinter):
    4849        self._host = host
    4950        self._filesystem = host.filesystem
     
    6566
    6667        self._git = self._ensure_wpt_repository("https://github.com/w3c/web-platform-tests.git", self._options.repository_directory, gitClass)
     68        self._linter = WPTLinterClass(self._options.repository_directory, host.filesystem)
    6769
    6870        self._username = options.username
     
    240242        if git_patch_file:
    241243            self._filesystem.remove(git_patch_file)
     244
     245        lint_errors = self._linter.lint()
     246        if lint_errors:
     247            _log.error("The wpt linter detected %s linting error(s). Please address the above errors before attempting to export changes to the web-platform-test repository." % (lint_errors,))
     248            self.delete_local_branch()
     249            self.clean()
     250            return
    242251
    243252        try:
     
    296305            return record.getMessage()
    297306
    298     logger = logging.getLogger()
     307    logger = logging.getLogger('webkitpy.w3c.test_exporter')
    299308    logger.setLevel(logging.INFO)
    300309    handler = LogHandler()
  • trunk/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py

    r229865 r229921  
    2929from webkitpy.w3c.wpt_github_mock import MockWPTGitHub
    3030
     31mock_linter = None
    3132
    3233class TestExporterTest(unittest.TestCase):
     
    106107            return self._mockSCM
    107108
     109    class MockWPTLinter(object):
     110        def __init__(self, repository_directory, filesystem):
     111            self.calls = [repository_directory]
     112            # workaround to appease the style checker which thinks
     113            # exporter._linter is an instance of WPTLinter and
     114            # complains if we try to access the calls property which
     115            # only exists on MockWPTLinter
     116            global mock_linter
     117            mock_linter = self
     118
     119        def lint(self):
     120            self.calls.append('lint')
     121            return 0
     122
    108123    def test_export(self):
    109124        host = TestExporterTest.MyMockHost()
    110125        options = parse_args(['test_exporter.py', '-g', 'HEAD', '-b', '1234', '-c', '-n', 'USER', '-t', 'TOKEN'])
    111         exporter = TestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub)
     126        exporter = TestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub, TestExporterTest.MockWPTLinter)
    112127        exporter.do_export()
    113128        self.assertEquals(exporter._github.calls, ['create_pr', 'add_label "webkit-export"'])
     
    132147            'fetch bug 1234',
    133148            'post comment to bug 1234 : Submitted web-platform-tests pull request: https://github.com/w3c/web-platform-tests/pull/5678'])
     149        self.assertEquals(mock_linter.calls, ['/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests', 'lint'])
    134150
    135151    def test_export_with_specific_branch(self):
    136152        host = TestExporterTest.MyMockHost()
    137153        options = parse_args(['test_exporter.py', '-g', 'HEAD', '-b', '1234', '-c', '-n', 'USER', '-t', 'TOKEN', '-bn', 'wpt-export-branch'])
    138         exporter = TestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub)
     154        exporter = TestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub, TestExporterTest.MockWPTLinter)
    139155        exporter.do_export()
    140156        self.assertEquals(exporter._git.calls, [
Note: See TracChangeset for help on using the changeset viewer.