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

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

Issue 2131463005: In print-stale-test-expectations-entries, avoid repeating the same request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 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'
47 crbug_prefix = 'crbug.com/' 47 crbug_prefix = 'crbug.com/'
48 48
49 49
50 class StaleTestPrinter(object): 50 class StaleTestPrinter(object):
51 51
52 def __init__(self, options): 52 def __init__(self, options):
53 self.days = options.days 53 self.days = options.days
54 self.create_csv = options.create_csv 54 self.create_csv = options.create_csv
55 self.is_stale_results = {}
55 56
56 def is_stale(self, bug_link): 57 def is_stale(self, bug_link):
58 if bug_link in self.is_stale_results:
59 return self.is_stale_results[bug_link]
60 # In case there's an error in the request, don't make the same request a gain.
61 self.is_stale_results[bug_link] = False
57 bug_number = bug_link.strip(crbug_prefix) 62 bug_number = bug_link.strip(crbug_prefix)
58 url = google_code_url % bug_number 63 url = google_code_url % bug_number
59 response = urllib2.urlopen(url) 64 response = urllib2.urlopen(url)
60 parsed = json.loads(response.read()) 65 parsed = json.loads(response.read())
61 last_updated = parsed['updated'] 66 last_updated = parsed['updated']
62 parsed_time = datetime.datetime.strptime(last_updated.split(".")[0] + "U TC", "%Y-%m-%dT%H:%M:%S%Z") 67 parsed_time = datetime.datetime.strptime(last_updated.split(".")[0] + "U TC", "%Y-%m-%dT%H:%M:%S%Z")
63 time_delta = datetime.datetime.now() - parsed_time 68 time_delta = datetime.datetime.now() - parsed_time
64 return time_delta.days > self.days 69 self.is_stale_results[bug_link] = time_delta.days > self.days
70 return self.is_stale_results[bug_link]
65 71
66 def print_stale_tests(self): 72 def print_stale_tests(self):
67 host = Host() 73 host = Host()
68 port = host.port_factory.get() 74 port = host.port_factory.get()
69 exps = port.expectations_dict() 75 exps = port.expectations_dict()
70 csv_contents = '' 76 csv_contents = ''
71 parser = TestExpectationParser(port, all_tests=(), is_lint_mode=False) 77 parser = TestExpectationParser(port, all_tests=(), is_lint_mode=False)
72 for line in parser.parse(*exps.items()[0]): 78 for line in parser.parse(*exps.items()[0]):
73 bugs, name = line.bugs, line.name 79 bugs, name = line.bugs, line.name
74 try: 80 try:
(...skipping 21 matching lines...) Expand all
96 default=0, 102 default=0,
97 help='Generate a CSV of the stale entries as well. Followed by the filen ame.'), 103 help='Generate a CSV of the stale entries as well. Followed by the filen ame.'),
98 options, args = option_parser.parse_args(argv) 104 options, args = option_parser.parse_args(argv)
99 105
100 printer = StaleTestPrinter(options) 106 printer = StaleTestPrinter(options)
101 printer.print_stale_tests() 107 printer.print_stale_tests()
102 return 0 108 return 0
103 109
104 if __name__ == '__main__': 110 if __name__ == '__main__':
105 sys.exit(main(sys.argv[1:])) 111 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