Enhancement request: Make export-w3c-test-changes add the PR to "See Also" links
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2018 17:54:56 +0000 (17:54 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2018 17:54:56 +0000 (17:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186140

Patch by Darshan Kadu <dkadu@igalia.com> on 2018-08-14
Reviewed by Youenn Fablet.

Added an optional parameter see_also to post_comment_to_bug function and used it for adding see_also variable's content in "See Also"
* Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
(Bugzilla.post_comment_to_bug):
Modified mock for see_also parameter
* Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py:
(MockBugzilla.post_comment_to_bug):
Made following unit tests to have see_also in bug comment
* Scripts/webkitpy/tool/bot/flakytestreporter_unittest.py:
* Scripts/webkitpy/tool/bot/sheriff_unittest.py:
(SheriffTest.test_post_blame_comment_on_bug):
* Scripts/webkitpy/tool/commands/applywatchlistlocal_unittest.py:
* Scripts/webkitpy/tool/commands/queues_unittest.py:
* Scripts/webkitpy/tool/commands/upload_unittest.py:
* Scripts/webkitpy/tool/steps/applywatchlist_unittest.py:
* Scripts/webkitpy/w3c/test_exporter.py:
(WebPlatformTestExporter.make_pull_request):
* Scripts/webkitpy/w3c/test_exporter_unittest.py:
(TestExporterTest.MockBugzilla.post_comment_to_bug):
(TestExporterTest.test_export):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234856 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py
Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py
Tools/Scripts/webkitpy/tool/bot/flakytestreporter_unittest.py
Tools/Scripts/webkitpy/tool/bot/sheriff_unittest.py
Tools/Scripts/webkitpy/tool/commands/applywatchlistlocal_unittest.py
Tools/Scripts/webkitpy/tool/commands/queues_unittest.py
Tools/Scripts/webkitpy/tool/commands/upload_unittest.py
Tools/Scripts/webkitpy/tool/steps/applywatchlist_unittest.py
Tools/Scripts/webkitpy/w3c/test_exporter.py
Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py

index 30b733a..a04c55f 100644 (file)
@@ -1,3 +1,30 @@
+2018-08-14  Darshan Kadu  <dkadu@igalia.com>
+
+        Enhancement request: Make export-w3c-test-changes add the PR to "See Also" links
+        https://bugs.webkit.org/show_bug.cgi?id=186140
+
+        Reviewed by Youenn Fablet.
+
+        Added an optional parameter see_also to post_comment_to_bug function and used it for adding see_also variable's content in "See Also"
+        * Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
+        (Bugzilla.post_comment_to_bug):
+        Modified mock for see_also parameter
+        * Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py:
+        (MockBugzilla.post_comment_to_bug):
+        Made following unit tests to have see_also in bug comment
+        * Scripts/webkitpy/tool/bot/flakytestreporter_unittest.py:
+        * Scripts/webkitpy/tool/bot/sheriff_unittest.py:
+        (SheriffTest.test_post_blame_comment_on_bug):
+        * Scripts/webkitpy/tool/commands/applywatchlistlocal_unittest.py:
+        * Scripts/webkitpy/tool/commands/queues_unittest.py:
+        * Scripts/webkitpy/tool/commands/upload_unittest.py:
+        * Scripts/webkitpy/tool/steps/applywatchlist_unittest.py:
+        * Scripts/webkitpy/w3c/test_exporter.py:
+        (WebPlatformTestExporter.make_pull_request):
+        * Scripts/webkitpy/w3c/test_exporter_unittest.py:
+        (TestExporterTest.MockBugzilla.post_comment_to_bug):
+        (TestExporterTest.test_export):
+
 2018-08-14  Aakash Jain  <aakash_jain@apple.com>
 
         [ews-build] Add support for max_builds parameter for workers
index 116a99f..85e1ed3 100644 (file)
@@ -860,13 +860,16 @@ class Bugzilla(object):
         self.browser["keywords"] = keyword
         self.browser.submit()
 
-    def post_comment_to_bug(self, bug_id, comment_text, cc=None):
+    def post_comment_to_bug(self, bug_id, comment_text, cc=None, see_also=None):
         self.authenticate()
 
         _log.info("Adding comment to bug %s" % bug_id)
         self.open_url(self.bug_url_for_bug_id(bug_id))
         self.browser.select_form(name="changeform")
         self.browser["comment"] = comment_text
+        if see_also:
+            _log.info("Adding PR link to See Also List for bug %s" % bug_id)
+            self.browser["see_also"] = ", ".join(see_also)
         if cc:
             self.browser["newcc"] = ", ".join(cc)
         self.browser.submit()
index fb08ae9..3dfa4aa 100644 (file)
@@ -468,9 +468,9 @@ class MockBugzilla(object):
         _log.info("MOCK setting flag '%s' to '%s' on attachment '%s' with comment '%s'" % (
                   flag_name, flag_value, attachment_id, comment_text))
 
-    def post_comment_to_bug(self, bug_id, comment_text, cc=None):
-        _log.info("MOCK bug comment: bug_id=%s, cc=%s\n--- Begin comment ---\n%s\n--- End comment ---\n" % (
-                  bug_id, cc, comment_text))
+    def post_comment_to_bug(self, bug_id, comment_text, cc=None, see_also=None):
+        _log.info("MOCK bug comment: bug_id=%s, cc=%s, see_also=%s\n--- Begin comment ---\n%s\n--- End comment ---\n" % (
+                  bug_id, cc, see_also, comment_text))
 
     def add_attachment_to_bug(self, bug_id, file_or_string, description, filename=None, comment_text=None, mimetype=None):
         _log.info("MOCK add_attachment_to_bug: bug_id=%s, description=%s filename=%s mimetype=%s" %
index 7b85d5b..1bd9d7c 100644 (file)
@@ -127,7 +127,7 @@ component: Tools / Tests
 cc: abarth@webkit.org
 blocked: 50856
 MOCK add_attachment_to_bug: bug_id=60001, description=Failure diff from mock-bot-id filename=failure.diff mimetype=None
-MOCK bug comment: bug_id=50000, cc=None
+MOCK bug comment: bug_id=50000, cc=None, see_also=None
 --- Begin comment ---
 The dummy-queue encountered the following flaky tests while processing attachment 10000:
 
index 78e7965..416592d 100644 (file)
@@ -65,19 +65,19 @@ class SheriffTest(unittest.TestCase):
             sheriff.post_blame_comment_on_bug(commit_info, builders, ["mock-test-1"])
             sheriff.post_blame_comment_on_bug(commit_info, builders, ["mock-test-1", "mock-test-2"])
 
-        expected_logs = u"""MOCK bug comment: bug_id=1234, cc=['watcher@example.com']
+        expected_logs = u"""MOCK bug comment: bug_id=1234, cc=['watcher@example.com'], see_also=None
 --- Begin comment ---
 https://trac.webkit.org/changeset/4321 might have broken Foo and Bar
 --- End comment ---
 
-MOCK bug comment: bug_id=1234, cc=['watcher@example.com']
+MOCK bug comment: bug_id=1234, cc=['watcher@example.com'], see_also=None
 --- Begin comment ---
 https://trac.webkit.org/changeset/4321 might have broken Foo and Bar
 The following tests are not passing:
 mock-test-1
 --- End comment ---
 
-MOCK bug comment: bug_id=1234, cc=['watcher@example.com']
+MOCK bug comment: bug_id=1234, cc=['watcher@example.com'], see_also=None
 --- Begin comment ---
 https://trac.webkit.org/changeset/4321 might have broken Foo and Bar
 The following tests are not passing:
index e88a86f..15c0b1f 100644 (file)
@@ -43,7 +43,7 @@ Message2."
 
     def test_args_parsing_with_bug(self):
         expected_logs = """MockWatchList: determine_cc_and_messages
-MOCK bug comment: bug_id=50002, cc=set(['eric@webkit.org', 'levin@chromium.org', 'abarth@webkit.org'])
+MOCK bug comment: bug_id=50002, cc=set(['eric@webkit.org', 'levin@chromium.org', 'abarth@webkit.org']), see_also=None
 --- Begin comment ---
 Message1.
 
index ab64143..3ea8785 100644 (file)
@@ -424,14 +424,14 @@ MOCK: release_work_item: commit-queue 10000
 
     def test_report_flaky_tests(self):
         queue = TestCommitQueue(MockTool())
-        expected_logs = """MOCK bug comment: bug_id=50002, cc=None
+        expected_logs = """MOCK bug comment: bug_id=50002, cc=None, see_also=None
 --- Begin comment ---
 The commit-queue just saw foo/bar.html flake (text diff) while processing attachment 10000 on bug 50000.
 Port: MockPort  Platform: MockPlatform 1.0
 --- End comment ---
 
 MOCK add_attachment_to_bug: bug_id=50002, description=Failure diff from bot filename=failure.diff mimetype=None
-MOCK bug comment: bug_id=50002, cc=None
+MOCK bug comment: bug_id=50002, cc=None, see_also=None
 --- Begin comment ---
 The commit-queue just saw bar/baz.html flake (text diff) while processing attachment 10000 on bug 50000.
 Port: MockPort  Platform: MockPlatform 1.0
@@ -439,7 +439,7 @@ Port: MockPort  Platform: MockPlatform 1.0
 
 bar/baz-diffs.txt does not exist in results archive, uploading entire archive.
 MOCK add_attachment_to_bug: bug_id=50002, description=Archive of layout-test-results from bot filename=layout-test-results.zip mimetype=None
-MOCK bug comment: bug_id=50000, cc=None
+MOCK bug comment: bug_id=50000, cc=None, see_also=None
 --- Begin comment ---
 The commit-queue encountered the following flaky tests while processing attachment 10000:
 
index b51d3e4..afa79fc 100644 (file)
@@ -194,7 +194,7 @@ Revision: 9876
 MOCK: user.open_url: http://example.com/50000
 Is this correct?
 Adding comment to Bug 50000.
-MOCK bug comment: bug_id=50000, cc=None
+MOCK bug comment: bug_id=50000, cc=None, see_also=None
 --- Begin comment ---
 MOCK comment
 
index a978f41..b74f5c9 100644 (file)
@@ -42,7 +42,7 @@ class ApplyWatchListTest(unittest.TestCase):
             'diff': 'The diff',
         }
         expected_logs = """MockWatchList: determine_cc_and_messages
-MOCK bug comment: bug_id=50001, cc=set(['levin@chromium.org'])
+MOCK bug comment: bug_id=50001, cc=set(['levin@chromium.org']), see_also=None
 --- Begin comment ---
 Message2.
 --- End comment ---
index 6a72d15..7290311 100644 (file)
@@ -324,7 +324,8 @@ class WebPlatformTestExporter(object):
                 _log.warning(e)
                 _log.info('Could not add label "%s" to pr #%s. User "%s" may not have permission to update labels in the %s/%s repo.' % (WEBKIT_EXPORT_PR_LABEL, pr_number, self.username, WPT_GH_ORG, WPT_GH_REPO_NAME))
         if self._bug_id and pr_number:
-            self._bugzilla.post_comment_to_bug(self._bug_id, "Submitted web-platform-tests pull request: " + WPT_PR_URL + str(pr_number))
+            pr_url = WPT_PR_URL + str(pr_number)
+            self._bugzilla.post_comment_to_bug(self._bug_id, "Submitted web-platform-tests pull request: " + pr_url, see_also=[pr_url])
 
     def create_wpt_pull_request(self, remote_branch_name, title, body):
         pr_number = None
index 1efe507..01bb189 100644 (file)
@@ -41,7 +41,9 @@ class TestExporterTest(unittest.TestCase):
             self.calls.append('fetch bug ' + id)
             return {"title": "my bug title"}
 
-        def post_comment_to_bug(self, id, comment):
+        def post_comment_to_bug(self, id, comment, see_also=None):
+            if see_also:
+                self.calls.append("Append %s to see also list" % ", ".join(see_also))
             self.calls.append('post comment to bug ' + id + ' : ' + comment)
             return True
 
@@ -148,6 +150,7 @@ class TestExporterTest(unittest.TestCase):
             'reset hard origin/master'])
         self.assertEquals(exporter._bugzilla.calls, [
             'fetch bug 1234',
+            'Append https://github.com/web-platform-tests/wpt/pull/5678 to see also list',
             'post comment to bug 1234 : Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/5678'])
         self.assertEquals(mock_linter.calls, ['/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests', 'lint'])