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

Side by Side Diff: media/tools/layout_tests/layouttest_analyzer_helpers.py

Issue 7806008: Add two command-line parameters and one bug fix for the layout test analyzer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified based on CR comments. Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Helper functions for the layout test analyzer.""" 6 """Helper functions for the layout test analyzer."""
7 7
8 import copy 8 import copy
9 from datetime import datetime 9 from datetime import datetime
10 from email.mime.multipart import MIMEMultipart 10 from email.mime.multipart import MIMEMultipart
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 main_te_info[k] = True 258 main_te_info[k] = True
259 if 'Bugs' in te_info: 259 if 'Bugs' in te_info:
260 for bug in te_info['Bugs']: 260 for bug in te_info['Bugs']:
261 if bug not in bug_map: 261 if bug not in bug_map:
262 bug_map[bug] = [] 262 bug_map[bug] = []
263 bug_map[bug].append((name, main_te_info)) 263 bug_map[bug].append((name, main_te_info))
264 return bug_map 264 return bug_map
265 265
266 266
267 def SendStatusEmail(prev_time, analyzer_result_map, prev_analyzer_result_map, 267 def SendStatusEmail(prev_time, analyzer_result_map, prev_analyzer_result_map,
268 bug_anno_map, receiver_email_address): 268 bug_anno_map, receiver_email_address, test_group_name):
269 """Send status email. 269 """Send status email.
270 270
271 Args: 271 Args:
272 prev_time: the date string such as '2011-10-09-11'. This format has been 272 prev_time: the date string such as '2011-10-09-11'. This format has been
273 used in this analyzer. 273 used in this analyzer.
274 analyzer_result_map: current analyzer result. 274 analyzer_result_map: current analyzer result.
275 prev_analyzer_result_map: previous analyzer result, which is read from 275 prev_analyzer_result_map: previous analyzer result, which is read from
276 a file. 276 a file.
277 bug_anno_map: bug annotation map where bug name and annotations are 277 bug_anno_map: bug annotation map where bug name and annotations are
278 stored. 278 stored.
279 receiver_email_address: receiver's email address. 279 receiver_email_address: receiver's email address.
280 test_group_name: string representing the test group name (e.g., 'media').
280 """ 281 """
281 diff_map = analyzer_result_map.CompareToOtherResultMap( 282 diff_map = analyzer_result_map.CompareToOtherResultMap(
282 prev_analyzer_result_map) 283 prev_analyzer_result_map)
283 str = analyzer_result_map.ConvertToString(prev_time, diff_map, bug_anno_map) 284 str = analyzer_result_map.ConvertToString(prev_time, diff_map, bug_anno_map)
284 # Add diff info about skipped/non-skipped test. 285 # Add diff info about skipped/non-skipped test.
285 prev_time = datetime.strptime(prev_time, '%Y-%m-%d-%H') 286 prev_time = datetime.strptime(prev_time, '%Y-%m-%d-%H')
286 prev_time = time.mktime(prev_time.timetuple()) 287 prev_time = time.mktime(prev_time.timetuple())
287 testname_map = {} 288 testname_map = {}
288 for type in ['skip', 'nonskip']: 289 for type in ['skip', 'nonskip']:
289 for i in range(2): 290 for i in range(2):
(...skipping 13 matching lines...) Expand all
303 'LayoutTests%2Fplatform%2Fchromium%2F' 304 'LayoutTests%2Fplatform%2Fchromium%2F'
304 'test_expectations.txt') % (new_rev, old_rev) 305 'test_expectations.txt') % (new_rev, old_rev)
305 str += '<ul><a href="%s">%s->%s</a>\n' % (link, old_rev, new_rev) 306 str += '<ul><a href="%s">%s->%s</a>\n' % (link, old_rev, new_rev)
306 str += '<li>%s</li>\n' % author 307 str += '<li>%s</li>\n' % author
307 str += '<li>%s</li>\n<ul>' % date 308 str += '<li>%s</li>\n<ul>' % date
308 for line in target_lines: 309 for line in target_lines:
309 str += '<li>%s</li>\n' % line 310 str += '<li>%s</li>\n' % line
310 str += '</ul></ul>' 311 str += '</ul></ul>'
311 localtime = time.asctime(time.localtime(time.time())) 312 localtime = time.asctime(time.localtime(time.time()))
312 # TODO(imasaki): remove my name from here. 313 # TODO(imasaki): remove my name from here.
314 subject = 'Layout Test Analyzer Result (%s): %s' % (test_group_name,
315 localtime)
313 SendEmail('imasaki@chromium.org', 'Kenji Imasaki', 316 SendEmail('imasaki@chromium.org', 'Kenji Imasaki',
314 [receiver_email_address], ['Layout Test Analyzer Result'], 317 [receiver_email_address], ['Layout Test Analyzer Result'], subject,
315 'Layout Test Analyzer Result : ' + localtime, str) 318 str)
316 319
317 320
318 def SendEmail(sender_email_address, sender_name, receivers_email_addresses, 321 def SendEmail(sender_email_address, sender_name, receivers_email_addresses,
319 receivers_names, subject, message): 322 receivers_names, subject, message):
320 """Send email using localhost's mail server. 323 """Send email using localhost's mail server.
321 324
322 Args: 325 Args:
323 sender_email_address: sender's email address. 326 sender_email_address: sender's email address.
324 sender_name: sender's name. 327 sender_name: sender's name.
325 receivers_email_addresses: receiver's email addresses. 328 receivers_email_addresses: receiver's email addresses.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 print 'Error: unable to send email' 365 print 'Error: unable to send email'
363 366
364 367
365 def FindLatestTime(time_list): 368 def FindLatestTime(time_list):
366 """Find latest time from |time_list|. 369 """Find latest time from |time_list|.
367 370
368 The current status is compared to the status of the latest file in 371 The current status is compared to the status of the latest file in
369 |RESULT_DIR|. 372 |RESULT_DIR|.
370 373
371 Args: 374 Args:
372 time_list: a list of time string in the form of '2011-10-23-23'. 375 time_list: a list of time string in the form of 'Year-Month-Day-Hour'
376 (e.g., 2011-10-23-23). Strings not in this format are ignored.
373 377
374 Returns: 378 Returns:
375 a string representing latest time among the time_list or None if 379 a string representing latest time among the time_list or None if
376 |time_list| is empty. 380 |time_list| is empty or no valid date string in |time_list|.
377 """ 381 """
378 if not time_list: 382 if not time_list:
379 return None 383 return None
380 latest_date = None 384 latest_date = None
381 for t in time_list: 385 for t in time_list:
382 item_date = datetime.strptime(t, '%Y-%m-%d-%H') 386 try:
383 if latest_date == None or latest_date < item_date: 387 item_date = datetime.strptime(t, '%Y-%m-%d-%H')
384 latest_date = item_date 388 if latest_date == None or latest_date < item_date:
385 return latest_date.strftime('%Y-%m-%d-%H') 389 latest_date = item_date
390 except ValueError:
391 # Do nothing.
392 pass
393 if latest_date:
394 return latest_date.strftime('%Y-%m-%d-%H')
395 else:
396 return None
386 397
387 398
388 def FindLatestResult(result_dir): 399 def FindLatestResult(result_dir):
389 """Find the latest result in |result_dir| and read and return them. 400 """Find the latest result in |result_dir| and read and return them.
390 401
391 This is used for comparison of analyzer result between current analyzer 402 This is used for comparison of analyzer result between current analyzer
392 and most known latest result. 403 and most known latest result.
393 404
394 Args: 405 Args:
395 result_dir: the result directory. 406 result_dir: the result directory.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 list2 = map2[name]['te_info'] 439 list2 = map2[name]['te_info']
429 te_diff = [item for item in list1 if not item in list2] 440 te_diff = [item for item in list1 if not item in list2]
430 if te_diff: 441 if te_diff:
431 name_list.append((name, te_diff)) 442 name_list.append((name, te_diff))
432 else: 443 else:
433 name_list.append((name, v1)) 444 name_list.append((name, v1))
434 return name_list 445 return name_list
435 446
436 return (GetDiffBetweenMapsHelper(map1, map2, lookIntoTestExpectationInfo), 447 return (GetDiffBetweenMapsHelper(map1, map2, lookIntoTestExpectationInfo),
437 GetDiffBetweenMapsHelper(map2, map1, lookIntoTestExpectationInfo)) 448 GetDiffBetweenMapsHelper(map2, map1, lookIntoTestExpectationInfo))
OLDNEW
« no previous file with comments | « media/tools/layout_tests/layouttest_analyzer.py ('k') | media/tools/layout_tests/layouttest_analyzer_helpers_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698