OLD | NEW |
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 from datetime import datetime | 8 from datetime import datetime |
9 from email.mime.multipart import MIMEMultipart | 9 from email.mime.multipart import MIMEMultipart |
10 from email.mime.text import MIMEText | 10 from email.mime.text import MIMEText |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 if 'Bugs' in te_info: | 257 if 'Bugs' in te_info: |
258 for bug in te_info['Bugs']: | 258 for bug in te_info['Bugs']: |
259 if bug not in bug_map: | 259 if bug not in bug_map: |
260 bug_map[bug] = [] | 260 bug_map[bug] = [] |
261 bug_map[bug].append((name, main_te_info)) | 261 bug_map[bug].append((name, main_te_info)) |
262 return bug_map | 262 return bug_map |
263 | 263 |
264 | 264 |
265 def SendStatusEmail(prev_time, analyzer_result_map, prev_analyzer_result_map, | 265 def SendStatusEmail(prev_time, analyzer_result_map, prev_analyzer_result_map, |
266 bug_anno_map, receiver_email_address, test_group_name, | 266 bug_anno_map, receiver_email_address, test_group_name, |
267 appended_text_to_email): | 267 appended_text_to_email, email_only_change_mode): |
268 """Send status email. | 268 """Send status email. |
269 | 269 |
270 Args: | 270 Args: |
271 prev_time: the date string such as '2011-10-09-11'. This format has been | 271 prev_time: the date string such as '2011-10-09-11'. This format has been |
272 used in this analyzer. | 272 used in this analyzer. |
273 analyzer_result_map: current analyzer result. | 273 analyzer_result_map: current analyzer result. |
274 prev_analyzer_result_map: previous analyzer result, which is read from | 274 prev_analyzer_result_map: previous analyzer result, which is read from |
275 a file. | 275 a file. |
276 bug_anno_map: bug annotation map where bug name and annotations are | 276 bug_anno_map: bug annotation map where bug name and annotations are |
277 stored. | 277 stored. |
278 receiver_email_address: receiver's email address. | 278 receiver_email_address: receiver's email address. |
279 test_group_name: string representing the test group name (e.g., 'media'). | 279 test_group_name: string representing the test group name (e.g., 'media'). |
280 appended_text_to_email: a text which is appended at the end of the status | 280 appended_text_to_email: a text which is appended at the end of the status |
281 email. | 281 email. |
| 282 email_only_change_mode: when this is true, the analyzer sends out the |
| 283 status email only when there is change in the analyzer result compared |
| 284 to the last result. When this is false, it sends the email out every |
| 285 time it runs. |
282 """ | 286 """ |
283 diff_map = analyzer_result_map.CompareToOtherResultMap( | 287 diff_map = analyzer_result_map.CompareToOtherResultMap( |
284 prev_analyzer_result_map) | 288 prev_analyzer_result_map) |
| 289 # Do not email when |email_only_change_mode| is true and there is no change |
| 290 # in the result compared to the last result. |
| 291 if (email_only_change_mode and not any(diff_map['whole']) and |
| 292 not any(diff_map['skip']) and not any(diff_map['nonskip'])): |
| 293 return |
285 output_str = analyzer_result_map.ConvertToString(prev_time, | 294 output_str = analyzer_result_map.ConvertToString(prev_time, |
286 diff_map, bug_anno_map) | 295 diff_map, bug_anno_map) |
287 # Add diff info about skipped/non-skipped test. | 296 # Add diff info about skipped/non-skipped test. |
288 prev_time = datetime.strptime(prev_time, '%Y-%m-%d-%H') | 297 prev_time = datetime.strptime(prev_time, '%Y-%m-%d-%H') |
289 prev_time = time.mktime(prev_time.timetuple()) | 298 prev_time = time.mktime(prev_time.timetuple()) |
290 testname_map = {} | 299 testname_map = {} |
291 for test_group in ['skip', 'nonskip']: | 300 for test_group in ['skip', 'nonskip']: |
292 for i in range(2): | 301 for i in range(2): |
293 for (k, _) in diff_map[test_group][i]: | 302 for (k, _) in diff_map[test_group][i]: |
294 testname_map[k] = True | 303 testname_map[k] = True |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 list2 = map2[name]['te_info'] | 452 list2 = map2[name]['te_info'] |
444 te_diff = [item for item in list1 if not item in list2] | 453 te_diff = [item for item in list1 if not item in list2] |
445 if te_diff: | 454 if te_diff: |
446 name_list.append((name, te_diff)) | 455 name_list.append((name, te_diff)) |
447 else: | 456 else: |
448 name_list.append((name, value1)) | 457 name_list.append((name, value1)) |
449 return name_list | 458 return name_list |
450 | 459 |
451 return (GetDiffBetweenMapsHelper(map1, map2, lookIntoTestExpectationInfo), | 460 return (GetDiffBetweenMapsHelper(map1, map2, lookIntoTestExpectationInfo), |
452 GetDiffBetweenMapsHelper(map2, map1, lookIntoTestExpectationInfo)) | 461 GetDiffBetweenMapsHelper(map2, map1, lookIntoTestExpectationInfo)) |
OLD | NEW |