Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: third_party/WebKit/Tools/Scripts/print-stale-test-expectations-entries

Issue 1949353002: Add ability to create CSV of Stale Test Expectations with list of all bugs and filenames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (C) 2013 Google Inc. All rights reserved. 3 # Copyright (C) 2013 Google Inc. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 12 matching lines...) Expand all
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
31 """Prints lists of bug numbers / tests whose bugs haven't been modified recently .""" 31 """Prints lists of bug numbers / tests whose bugs haven't been modified recently ."""
32 32
33 import csv
Dirk Pranke 2016/05/12 02:11:15 this is no longer needed ...
nainar 2016/05/12 04:58:47 Removed.
33 import datetime 34 import datetime
34 import json 35 import json
35 import optparse 36 import optparse
36 import re 37 import re
37 import sys 38 import sys
38 import time 39 import time
39 import urllib2 40 import urllib2
40 41
42 from webkitpy.common.host import Host
41 from webkitpy.common.system.filesystem import FileSystem 43 from webkitpy.common.system.filesystem import FileSystem
42 from webkitpy.common.webkit_finder import WebKitFinder 44 from webkitpy.common.webkit_finder import WebKitFinder
45 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser
43 46
44 google_code_url = 'https://www.googleapis.com/projecthosting/v2/projects/chromiu m/issues/%s?key=AIzaSyDgCqT1Dt5AZWLHo4QJjyMHaCjhnFacGF0' 47 google_code_url = 'https://www.googleapis.com/projecthosting/v2/projects/chromiu m/issues/%s?key=AIzaSyDgCqT1Dt5AZWLHo4QJjyMHaCjhnFacGF0'
45 crbug_prefix = 'crbug.com/' 48 crbug_prefix = 'crbug.com/'
46 49
50 class StaleTestCSV(object):
Dirk Pranke 2016/05/12 02:11:15 this class isn't really adding any value. I would
nainar 2016/05/12 04:58:47 Done.
51 def __init__(self, filename):
52 self._filename = filename
53
54 def add_to_csv(self, bug_number, test_name):
55 file = open(self._filename, 'a')
56 file.write("%s, %s\n" % (bug_number, test_name))
57
47 class StaleTestPrinter(object): 58 class StaleTestPrinter(object):
48 def __init__(self, options): 59 def __init__(self, options):
49 self._days = options.days 60 self._days = options.days
61 self._stale_test_csv = StaleTestCSV(options.create_csv)
Dirk Pranke 2016/05/12 02:11:15 change this to self.create_csv = options.create_cs
nainar 2016/05/12 04:58:47 Done. Done.
50 62
51 def is_stale(self, bug_number): 63 def is_stale(self, bug_link):
64 bug_number = bug_link.strip(crbug_prefix)
52 url = google_code_url % bug_number 65 url = google_code_url % bug_number
53 response = urllib2.urlopen(url) 66 response = urllib2.urlopen(url)
54 parsed = json.loads(response.read()) 67 parsed = json.loads(response.read())
55 last_updated = parsed['updated'] 68 last_updated = parsed['updated']
56 parsed_time = datetime.datetime.strptime(last_updated.split(".")[0]+"UTC ", "%Y-%m-%dT%H:%M:%S%Z") 69 parsed_time = datetime.datetime.strptime(last_updated.split(".")[0]+"UTC ", "%Y-%m-%dT%H:%M:%S%Z")
57 time_delta = datetime.datetime.now() - parsed_time 70 time_delta = datetime.datetime.now() - parsed_time
58 return time_delta.days > 90 71 return time_delta.days > self._days
59 72
60 def print_stale_tests(self): 73 def print_stale_tests(self):
61 finder = WebKitFinder(FileSystem()) 74 port = Host().port_factory.get()
62 path_to_expectations = finder.path_from_webkit_base('LayoutTests', 'Test Expectations') 75 exps = port.expectations_dict()
Dirk Pranke 2016/05/12 02:11:15 change this to : host = Host() port = host.po
nainar 2016/05/12 04:58:47 Done.
63 expectations = open(path_to_expectations) 76 parser = TestExpectationParser(port, all_tests=(), is_lint_mode=False)
64 77 for line in parser.parse(*exps.items()[0]):
65 for line in expectations: 78 bugs, name = line.bugs, line.name
66 comment_index = line.find("#") 79 try:
67 if comment_index == -1: 80 if bugs and all(self.is_stale(bug) for bug in bugs):
68 comment_index = len(line) 81 print line.original_string.strip()
69 82 if self._stale_test_csv._filename:
70 remaining_string = re.sub(r"\s+", " ", line[:comment_index].strip()) 83 self._stale_test_csv.add_to_csv(bugs[0], name)
Dirk Pranke 2016/05/12 02:11:15 change lines 82-83 to: csv_contents += "%s, %s\n"
nainar 2016/05/12 04:58:47 Done.
71 if len(remaining_string) == 0: 84 except urllib2.HTTPError as error:
72 continue 85 if error.code == 404:
73 86 print 'Does not exist.'
74 is_bug_stale = True 87 elif error.code == 403:
75 parts = line.split(' ') 88 print 'Is not accessible. Not able to tell if it\'s stale.'
76 for part in parts: 89 is_bug_stale = False
77 if part.startswith(crbug_prefix): 90 else:
78 bug_number = part.split('/')[1] 91 print error
Dirk Pranke 2016/05/12 02:11:15 add two lines de-dented out to match lines 76-77 (
nainar 2016/05/12 04:58:47 Done.
79 try:
80 if not self.is_stale(bug_number):
81 is_bug_stale = False
82 break;
83 except urllib2.HTTPError as error:
84 if error.code == 404:
85 print '%s%s does not exist.' % (crbug_prefix, bug_nu mber)
86 elif error.code == 403:
87 print '%s%s is not accessible. Not able to tell if i t\'s stale.' % (crbug_prefix, bug_number)
88 is_bug_stale = False
89 else:
90 raise error
91
92 if is_bug_stale:
93 print line.strip()
94 92
95 def main(argv): 93 def main(argv):
96 option_parser = optparse.OptionParser() 94 option_parser = optparse.OptionParser()
97 option_parser.add_option('--days', type='int', default=90, help='Number of d ays to consider a bug stale.'), 95 option_parser.add_option('--days', type='int', default=90, help='Number of d ays to consider a bug stale.'),
96 option_parser.add_option('--create-csv', type='string', default=0, help='Gen erate a CSV of the stale entries as well. Followed by the filename.'),
98 options, args = option_parser.parse_args(argv) 97 options, args = option_parser.parse_args(argv)
99 98
100 printer = StaleTestPrinter(options) 99 printer = StaleTestPrinter(options)
101 printer.print_stale_tests() 100 printer.print_stale_tests()
102 return 0 101 return 0
103 102
104 if __name__ == '__main__': 103 if __name__ == '__main__':
105 sys.exit(main(sys.argv[1:])) 104 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « test ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698