Changeset 73688 in webkit
- Timestamp:
- Dec 9, 2010 10:45:42 PM (13 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r73682 r73688 1 2010-12-09 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 Teach webkit-patch how to search bugzilla 6 https://bugs.webkit.org/show_bug.cgi?id=50500 7 8 This is a step towards teaching webkitpy how to file 9 new bugs for flaky tests and update them when new flakes occur. 10 11 * Scripts/webkitpy/common/net/bugzilla/bugzilla.py: 12 * Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py: 13 * Scripts/webkitpy/tool/commands/__init__.py: 14 * Scripts/webkitpy/tool/commands/bugsearch.py: Added. 15 1 16 2010-12-09 Adam Barth <abarth@webkit.org> 2 17 -
trunk/WebKitTools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py
r71958 r73688 34 34 import re 35 35 import StringIO 36 import urllib 36 37 37 38 from datetime import datetime # used in timestamp() … … 73 74 self._bugzilla = bugzilla 74 75 75 # Note: _load_query and _fetch_bug are the only two methods which access 76 # self._bugzilla. 76 def _is_xml_bugs_form(self, form): 77 # ClientForm.HTMLForm.find_control throws if the control is not found, 78 # so we do a manual search instead: 79 return "xml" in [control.id for control in form.controls] 80 81 # This is kinda a hack. There is probably a better way to get this information from bugzilla. 82 def _parse_result_count(self, results_page): 83 result_count_text = BeautifulSoup(results_page).find(attrs={'class': 'bz_result_count'}).string 84 result_count_parts = result_count_text.split(" ") 85 if result_count_parts[0] == "Zarro": 86 return 0 87 return int(result_count_parts[0]) 88 89 # Note: _load_query, _fetch_bug and _fetch_bugs_from_advanced_query 90 # are the only methods which access self._bugzilla. 77 91 78 92 def _load_query(self, query): 79 93 self._bugzilla.authenticate() 80 81 94 full_url = "%s%s" % (self._bugzilla.bug_server_url, query) 82 95 return self._bugzilla.browser.open(full_url) 96 97 def _fetch_bugs_from_advanced_query(self, query): 98 results_page = self._load_query(query) 99 if not self._parse_result_count(results_page): 100 return [] 101 # Bugzilla results pages have an "XML" submit button at the bottom 102 # which can be used to get an XML page containing all of the <bug> elements. 103 # This is slighty lame that this assumes that _load_query used 104 # self._bugzilla.browser and that it's in an acceptable state. 105 self._bugzilla.browser.select_form(predicate=self._is_xml_bugs_form) 106 bugs_xml = self._bugzilla.browser.submit() 107 return self._bugzilla._parse_bugs_from_xml(bugs_xml) 83 108 84 109 def _fetch_bug(self, bug_id): … … 114 139 needs_commit_query_url = "buglist.cgi?query_format=advanced&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&field0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=review%2B" 115 140 return self._fetch_bug_ids_advanced_query(needs_commit_query_url) 141 142 def fetch_bugs_matching_quicksearch(self, search_string): 143 # We may want to use a more explicit query than "quicksearch". 144 # If quicksearch changes we should probably change to use 145 # a normal buglist.cgi?query_format=advanced query. 146 quicksearch_url = "buglist.cgi?quicksearch=%s" % urllib.quote(search_string) 147 return self._fetch_bugs_from_advanced_query(quicksearch_url) 116 148 117 149 def fetch_patches_from_pending_commit_list(self): … … 251 283 return attachment 252 284 253 def _parse_bug_page(self, page): 285 def _parse_bugs_from_xml(self, page): 286 soup = BeautifulSoup(page) 287 # Without the unicode() call, BeautifulSoup occasionally complains of being 288 # passed None for no apparent reason. 289 return [Bug(self._parse_bug_dictionary_from_xml(unicode(bug_xml)), self) for bug_xml in soup('bug')] 290 291 def _parse_bug_dictionary_from_xml(self, page): 254 292 soup = BeautifulSoup(page) 255 293 bug = {} … … 274 312 def fetch_bug_dictionary(self, bug_id): 275 313 try: 276 return self._parse_bug_ page(self._fetch_bug_page(bug_id))314 return self._parse_bug_dictionary_from_xml(self._fetch_bug_page(bug_id)) 277 315 except KeyboardInterrupt: 278 316 raise 279 317 except: 280 318 self.authenticate() 281 return self._parse_bug_ page(self._fetch_bug_page(bug_id))319 return self._parse_bug_dictionary_from_xml(self._fetch_bug_page(bug_id)) 282 320 283 321 # FIXME: A BugzillaCache object should provide all these fetch_ methods. -
trunk/WebKitTools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py
r71856 r73688 100 100 self.assertEquals(None, parse_bug_id("http://bugs.webkit.org/show_bug.cgi?ctype=xml&id=12345")) 101 101 102 _example_bug = """ 103 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 104 <!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/bugzilla.dtd"> 105 <bugzilla version="3.2.3" 106 urlbase="https://bugs.webkit.org/" 107 maintainer="admin@webkit.org" 108 exporter="eric@webkit.org" 109 > 102 _bug_xml = """ 110 103 <bug> 111 104 <bug_id>32585</bug_id> … … 150 143 <size>10882</size> 151 144 <attacher>mjs@apple.com</attacher> 152 145 153 146 <token>1261988248-dc51409e9c421a4358f365fa8bec8357</token> 154 147 <data encoding="base64">SW5kZXg6IFdlYktpdC9tYWMvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09 … … 156 149 ZEZpbmlzaExvYWRXaXRoUmVhc29uOnJlYXNvbl07Cit9CisKIEBlbmQKIAogI2VuZGlmCg== 157 150 </data> 158 151 159 152 <flag name="review" 160 153 id="27602" … … 164 157 </attachment> 165 158 </bug> 159 """ 160 161 _single_bug_xml = """ 162 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 163 <!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/bugzilla.dtd"> 164 <bugzilla version="3.2.3" 165 urlbase="https://bugs.webkit.org/" 166 maintainer="admin@webkit.org" 167 exporter="eric@webkit.org" 168 > 169 %s 166 170 </bugzilla> 167 """ 171 """ % _bug_xml 172 168 173 _expected_example_bug_parsing = { 169 174 "id" : 32585, … … 195 200 self.assertEquals(actual[key], expected_value, ("Failure for key: %s: Actual='%s' Expected='%s'" % (key, actual[key], expected_value))) 196 201 197 def test_ bug_parsing(self):198 bug = Bugzilla()._parse_bug_ page(self._example_bug)202 def test_parse_bug_dictionary_from_xml(self): 203 bug = Bugzilla()._parse_bug_dictionary_from_xml(self._single_bug_xml) 199 204 self._assert_dictionaries_equal(bug, self._expected_example_bug_parsing) 205 206 _sample_multi_bug_xml = """ 207 <bugzilla version="3.2.3" urlbase="https://bugs.webkit.org/" maintainer="admin@webkit.org" exporter="eric@webkit.org"> 208 %s 209 %s 210 </bugzilla> 211 """ % (_bug_xml, _bug_xml) 212 213 def test_parse_bugs_from_xml(self): 214 bugzilla = Bugzilla() 215 bugs = bugzilla._parse_bugs_from_xml(self._sample_multi_bug_xml) 216 self.assertEquals(len(bugs), 2) 217 self.assertEquals(bugs[0].id(), self._expected_example_bug_parsing['id']) 218 bugs = bugzilla._parse_bugs_from_xml("") 219 self.assertEquals(len(bugs), 0) 200 220 201 221 # This could be combined into test_bug_parsing later if desired. … … 329 349 """ 330 350 351 def _assert_result_count(self, queries, html, count): 352 self.assertEquals(queries._parse_result_count(html), count) 353 354 def test_parse_result_count(self): 355 queries = BugzillaQueries(None) 356 # Pages with results, always list the count at least twice. 357 self._assert_result_count(queries, '<span class="bz_result_count">314 bugs found.</span><span class="bz_result_count">314 bugs found.</span>', 314) 358 self._assert_result_count(queries, '<span class="bz_result_count">Zarro Boogs found.</span>', 0) 359 self.assertRaises(Exception, queries._parse_result_count, ['Invalid']) 360 331 361 def test_request_page_parsing(self): 332 362 queries = BugzillaQueries(None) -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/__init__.py
r71667 r73688 1 1 # Required for Python to search this directory for module files 2 2 3 from webkitpy.tool.commands.bugsearch import BugSearch 3 4 from webkitpy.tool.commands.download import * 4 5 from webkitpy.tool.commands.earlywarningsystem import *
Note: See TracChangeset
for help on using the changeset viewer.