Chromium Code Reviews| 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..1d8234b87eb960bcdb084861fe17e7967a28c619 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 |
| import datetime |
| import json |
| import optparse |
| @@ -44,9 +45,18 @@ from webkitpy.common.webkit_finder import WebKitFinder |
| google_code_url = 'https://www.googleapis.com/projecthosting/v2/projects/chromium/issues/%s?key=AIzaSyDgCqT1Dt5AZWLHo4QJjyMHaCjhnFacGF0' |
| crbug_prefix = 'crbug.com/' |
| +class StaleTestCSV(object): |
|
nainar
2016/05/05 05:02:50
I am creating an output csv right now - this seems
|
| + def __init__(self, filename): |
| + self._filename = filename |
| + 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.
|
| + |
| + def add_to_csv(self, bug_number, test_name): |
| + self._writer.writerow([bug_number, test_name]) |
| + |
| class StaleTestPrinter(object): |
| def __init__(self, options): |
| self._days = options.days |
| + self._stale_test_csv = StaleTestCSV(options.create_csv) |
| def is_stale(self, bug_number): |
| url = google_code_url % bug_number |
| @@ -55,7 +65,7 @@ class StaleTestPrinter(object): |
| 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 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.
|
| def print_stale_tests(self): |
| finder = WebKitFinder(FileSystem()) |
| @@ -88,13 +98,19 @@ class StaleTestPrinter(object): |
| is_bug_stale = False |
| else: |
| raise error |
| + elif len(part) and not (part.startswith('[') or part.startswith(']') or part[0].isupper()) and is_bug_stale is True: |
| + test_name = part |
| if is_bug_stale: |
| print line.strip() |
| + if self._stale_test_csv._filename: |
| + 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.
|
| + |
| 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) |