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

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
« test ('K') | « 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
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
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
43 44
44 google_code_url = 'https://www.googleapis.com/projecthosting/v2/projects/chromiu m/issues/%s?key=AIzaSyDgCqT1Dt5AZWLHo4QJjyMHaCjhnFacGF0' 45 google_code_url = 'https://www.googleapis.com/projecthosting/v2/projects/chromiu m/issues/%s?key=AIzaSyDgCqT1Dt5AZWLHo4QJjyMHaCjhnFacGF0'
45 crbug_prefix = 'crbug.com/' 46 crbug_prefix = 'crbug.com/'
46 47
48 class StaleTestCSV(object):
nainar 2016/05/05 05:02:50 I am creating an output csv right now - this seems
49 def __init__(self, filename):
50 self._filename = filename
51 self._writer = csv.writer(open(filename, 'wb'), delimiter=',', quotechar ='|', quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
Dirk Pranke 2016/05/06 01:51:55 using '|' as a quotechar seems like an odd choice.
nainar 2016/05/11 13:24:35 Done.
52
53 def add_to_csv(self, bug_number, test_name):
54 self._writer.writerow([bug_number, test_name])
55
47 class StaleTestPrinter(object): 56 class StaleTestPrinter(object):
48 def __init__(self, options): 57 def __init__(self, options):
49 self._days = options.days 58 self._days = options.days
59 self._stale_test_csv = StaleTestCSV(options.create_csv)
50 60
51 def is_stale(self, bug_number): 61 def is_stale(self, bug_number):
52 url = google_code_url % bug_number 62 url = google_code_url % bug_number
53 response = urllib2.urlopen(url) 63 response = urllib2.urlopen(url)
54 parsed = json.loads(response.read()) 64 parsed = json.loads(response.read())
55 last_updated = parsed['updated'] 65 last_updated = parsed['updated']
56 parsed_time = datetime.datetime.strptime(last_updated.split(".")[0]+"UTC ", "%Y-%m-%dT%H:%M:%S%Z") 66 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 67 time_delta = datetime.datetime.now() - parsed_time
58 return time_delta.days > 90 68 return time_delta.days > (self._days if self._days else 90)
Dirk Pranke 2016/05/06 01:51:55 you don't really need the if since self._days will
nainar 2016/05/11 13:24:36 Done.
59 69
60 def print_stale_tests(self): 70 def print_stale_tests(self):
61 finder = WebKitFinder(FileSystem()) 71 finder = WebKitFinder(FileSystem())
62 path_to_expectations = finder.path_from_webkit_base('LayoutTests', 'Test Expectations') 72 path_to_expectations = finder.path_from_webkit_base('LayoutTests', 'Test Expectations')
63 expectations = open(path_to_expectations) 73 expectations = open(path_to_expectations)
64 74
65 for line in expectations: 75 for line in expectations:
66 comment_index = line.find("#") 76 comment_index = line.find("#")
67 if comment_index == -1: 77 if comment_index == -1:
68 comment_index = len(line) 78 comment_index = len(line)
(...skipping 12 matching lines...) Expand all
81 is_bug_stale = False 91 is_bug_stale = False
82 break; 92 break;
83 except urllib2.HTTPError as error: 93 except urllib2.HTTPError as error:
84 if error.code == 404: 94 if error.code == 404:
85 print '%s%s does not exist.' % (crbug_prefix, bug_nu mber) 95 print '%s%s does not exist.' % (crbug_prefix, bug_nu mber)
86 elif error.code == 403: 96 elif error.code == 403:
87 print '%s%s is not accessible. Not able to tell if i t\'s stale.' % (crbug_prefix, bug_number) 97 print '%s%s is not accessible. Not able to tell if i t\'s stale.' % (crbug_prefix, bug_number)
88 is_bug_stale = False 98 is_bug_stale = False
89 else: 99 else:
90 raise error 100 raise error
101 elif len(part) and not (part.startswith('[') or part.startswith( ']') or part[0].isupper()) and is_bug_stale is True:
102 test_name = part
91 103
92 if is_bug_stale: 104 if is_bug_stale:
93 print line.strip() 105 print line.strip()
106 if self._stale_test_csv._filename:
107 self._stale_test_csv.add_to_csv(bug_number, test_name)
Dirk Pranke 2016/05/06 01:51:55 Ick. We shouldn't be parsing the file by hand. Do
nainar 2016/05/11 13:24:36 Done.
108
94 109
95 def main(argv): 110 def main(argv):
96 option_parser = optparse.OptionParser() 111 option_parser = optparse.OptionParser()
97 option_parser.add_option('--days', type='int', default=90, help='Number of d ays to consider a bug stale.'), 112 option_parser.add_option('--days', type='int', default=90, help='Number of d ays to consider a bug stale.'),
113 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) 114 options, args = option_parser.parse_args(argv)
99 115
100 printer = StaleTestPrinter(options) 116 printer = StaleTestPrinter(options)
101 printer.print_stale_tests() 117 printer.print_stale_tests()
102 return 0 118 return 0
103 119
104 if __name__ == '__main__': 120 if __name__ == '__main__':
105 sys.exit(main(sys.argv[1:])) 121 sys.exit(main(sys.argv[1:]))
OLDNEW
« test ('K') | « test ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698