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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Tools/Scripts/print-stale-test-expectations-entries
diff --git a/third_party/WebKit/Tools/Scripts/print-stale-test-expectations-entries b/third_party/WebKit/Tools/Scripts/print-stale-test-expectations-entries
index 48363189c3c767bdec79aa01cb91360ba731c943..a5eec50bb01d9376b39dceb86237291a991e4e22 100755
--- a/third_party/WebKit/Tools/Scripts/print-stale-test-expectations-entries
+++ b/third_party/WebKit/Tools/Scripts/print-stale-test-expectations-entries
@@ -30,6 +30,7 @@
"""Prints lists of bug numbers / tests whose bugs haven't been modified recently."""
+import csv
Dirk Pranke 2016/05/12 02:11:15 this is no longer needed ...
nainar 2016/05/12 04:58:47 Removed.
import datetime
import json
import optparse
@@ -38,63 +39,61 @@ import sys
import time
import urllib2
+from webkitpy.common.host import Host
from webkitpy.common.system.filesystem import FileSystem
from webkitpy.common.webkit_finder import WebKitFinder
+from webkitpy.layout_tests.models.test_expectations import TestExpectationParser
google_code_url = 'https://www.googleapis.com/projecthosting/v2/projects/chromium/issues/%s?key=AIzaSyDgCqT1Dt5AZWLHo4QJjyMHaCjhnFacGF0'
crbug_prefix = 'crbug.com/'
+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.
+ def __init__(self, filename):
+ self._filename = filename
+
+ def add_to_csv(self, bug_number, test_name):
+ file = open(self._filename, 'a')
+ file.write("%s, %s\n" % (bug_number, test_name))
+
class StaleTestPrinter(object):
def __init__(self, options):
self._days = options.days
+ 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.
- def is_stale(self, bug_number):
+ def is_stale(self, bug_link):
+ bug_number = bug_link.strip(crbug_prefix)
url = google_code_url % bug_number
response = urllib2.urlopen(url)
parsed = json.loads(response.read())
last_updated = parsed['updated']
parsed_time = datetime.datetime.strptime(last_updated.split(".")[0]+"UTC", "%Y-%m-%dT%H:%M:%S%Z")
time_delta = datetime.datetime.now() - parsed_time
- return time_delta.days > 90
+ return time_delta.days > self._days
def print_stale_tests(self):
- finder = WebKitFinder(FileSystem())
- path_to_expectations = finder.path_from_webkit_base('LayoutTests', 'TestExpectations')
- expectations = open(path_to_expectations)
-
- for line in expectations:
- comment_index = line.find("#")
- if comment_index == -1:
- comment_index = len(line)
-
- remaining_string = re.sub(r"\s+", " ", line[:comment_index].strip())
- if len(remaining_string) == 0:
- continue
-
- is_bug_stale = True
- parts = line.split(' ')
- for part in parts:
- if part.startswith(crbug_prefix):
- bug_number = part.split('/')[1]
- try:
- if not self.is_stale(bug_number):
- is_bug_stale = False
- break;
- except urllib2.HTTPError as error:
- if error.code == 404:
- print '%s%s does not exist.' % (crbug_prefix, bug_number)
- elif error.code == 403:
- print '%s%s is not accessible. Not able to tell if it\'s stale.' % (crbug_prefix, bug_number)
- is_bug_stale = False
- else:
- raise error
-
- if is_bug_stale:
- print line.strip()
+ port = Host().port_factory.get()
+ 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.
+ parser = TestExpectationParser(port, all_tests=(), is_lint_mode=False)
+ for line in parser.parse(*exps.items()[0]):
+ bugs, name = line.bugs, line.name
+ try:
+ if bugs and all(self.is_stale(bug) for bug in bugs):
+ print line.original_string.strip()
+ if self._stale_test_csv._filename:
+ 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.
+ except urllib2.HTTPError as error:
+ if error.code == 404:
+ print 'Does not exist.'
+ elif error.code == 403:
+ print 'Is not accessible. Not able to tell if it\'s stale.'
+ is_bug_stale = False
+ else:
+ 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.
def main(argv):
option_parser = optparse.OptionParser()
option_parser.add_option('--days', type='int', default=90, help='Number of days to consider a bug stale.'),
+ option_parser.add_option('--create-csv', type='string', default=0, help='Generate a CSV of the stale entries as well. Followed by the filename.'),
options, args = option_parser.parse_args(argv)
printer = StaleTestPrinter(options)
« no previous file with comments | « test ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698