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

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: Remove test 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 | « no previous file | 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 20 matching lines...) Expand all
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 datetime 33 import datetime
34 import json 34 import json
35 import optparse 35 import optparse
36 import re 36 import re
37 import sys 37 import sys
38 import time 38 import time
39 import urllib2 39 import urllib2
40 40
41 from webkitpy.common.host import Host
41 from webkitpy.common.system.filesystem import FileSystem 42 from webkitpy.common.system.filesystem import FileSystem
42 from webkitpy.common.webkit_finder import WebKitFinder 43 from webkitpy.common.webkit_finder import WebKitFinder
44 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser
43 45
44 google_code_url = 'https://www.googleapis.com/projecthosting/v2/projects/chromiu m/issues/%s?key=AIzaSyDgCqT1Dt5AZWLHo4QJjyMHaCjhnFacGF0' 46 google_code_url = 'https://www.googleapis.com/projecthosting/v2/projects/chromiu m/issues/%s?key=AIzaSyDgCqT1Dt5AZWLHo4QJjyMHaCjhnFacGF0'
45 crbug_prefix = 'crbug.com/' 47 crbug_prefix = 'crbug.com/'
46 48
47 class StaleTestPrinter(object): 49 class StaleTestPrinter(object):
48 def __init__(self, options): 50 def __init__(self, options):
49 self._days = options.days 51 self.days = options.days
52 self.create_csv = options.create_csv
50 53
51 def is_stale(self, bug_number): 54 def is_stale(self, bug_link):
55 bug_number = bug_link.strip(crbug_prefix)
52 url = google_code_url % bug_number 56 url = google_code_url % bug_number
53 response = urllib2.urlopen(url) 57 response = urllib2.urlopen(url)
54 parsed = json.loads(response.read()) 58 parsed = json.loads(response.read())
55 last_updated = parsed['updated'] 59 last_updated = parsed['updated']
56 parsed_time = datetime.datetime.strptime(last_updated.split(".")[0]+"UTC ", "%Y-%m-%dT%H:%M:%S%Z") 60 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 61 time_delta = datetime.datetime.now() - parsed_time
58 return time_delta.days > 90 62 return time_delta.days > self.days
59 63
60 def print_stale_tests(self): 64 def print_stale_tests(self):
61 finder = WebKitFinder(FileSystem()) 65 host = Host()
62 path_to_expectations = finder.path_from_webkit_base('LayoutTests', 'Test Expectations') 66 port = host.port_factory.get()
63 expectations = open(path_to_expectations) 67 exps = port.expectations_dict()
64 68 csv_contents = ''
65 for line in expectations: 69 parser = TestExpectationParser(port, all_tests=(), is_lint_mode=False)
66 comment_index = line.find("#") 70 for line in parser.parse(*exps.items()[0]):
67 if comment_index == -1: 71 bugs, name = line.bugs, line.name
68 comment_index = len(line) 72 try:
69 73 if bugs and all(self.is_stale(bug) for bug in bugs):
70 remaining_string = re.sub(r"\s+", " ", line[:comment_index].strip()) 74 print line.original_string.strip()
71 if len(remaining_string) == 0: 75 csv_contents += "%s, %s\n" % (bugs[0], name)
72 continue 76 except urllib2.HTTPError as error:
73 77 if error.code == 404:
74 is_bug_stale = True 78 print 'Does not exist.'
75 parts = line.split(' ') 79 elif error.code == 403:
76 for part in parts: 80 print 'Is not accessible. Not able to tell if it\'s stale.'
77 if part.startswith(crbug_prefix): 81 is_bug_stale = False
78 bug_number = part.split('/')[1] 82 else:
79 try: 83 print error
80 if not self.is_stale(bug_number): 84 if self.create_csv:
81 is_bug_stale = False 85 host.filesystem.write_text_file(self.create_csv, csv_contents)
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 86
95 def main(argv): 87 def main(argv):
96 option_parser = optparse.OptionParser() 88 option_parser = optparse.OptionParser()
97 option_parser.add_option('--days', type='int', default=90, help='Number of d ays to consider a bug stale.'), 89 option_parser.add_option('--days', type='int', default=90, help='Number of d ays to consider a bug stale.'),
90 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) 91 options, args = option_parser.parse_args(argv)
99 92
100 printer = StaleTestPrinter(options) 93 printer = StaleTestPrinter(options)
101 printer.print_stale_tests() 94 printer.print_stale_tests()
102 return 0 95 return 0
103 96
104 if __name__ == '__main__': 97 if __name__ == '__main__':
105 sys.exit(main(sys.argv[1:])) 98 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698