Chromium Code Reviews| Index: media/tools/layout_tests/layouttest_analyzer_helpers.py |
| diff --git a/media/tools/layout_tests/layouttest_analyzer_helpers.py b/media/tools/layout_tests/layouttest_analyzer_helpers.py |
| index 44d4496d9141e277e9034af073bb5eef9b3aeb1f..c5723eec7c47d01acda37b81c675e7a29b61676d 100644 |
| --- a/media/tools/layout_tests/layouttest_analyzer_helpers.py |
| +++ b/media/tools/layout_tests/layouttest_analyzer_helpers.py |
| @@ -11,6 +11,7 @@ from email.mime.text import MIMEText |
| import fileinput |
| import os |
| import pickle |
| +import re |
| import smtplib |
| import socket |
| import sys |
| @@ -132,6 +133,46 @@ class AnalyzerResultMap: |
| 'less than that of "skip"') |
| return 100 - len(self.result_map['nonskip'].keys()) * 100 / delta |
| + def ConvertToCSVText(self, current_time): |
| + """Convert result_map into stats and issues text in CSV format. |
|
dennis_jeffrey
2011/11/11 00:01:36
'result_map' --> |self.result_map|
imasaki1
2011/11/11 00:25:52
Done.
|
| + |
| + Both are used for inputs for Google spreadsheet. |
|
dennis_jeffrey
2011/11/11 00:01:36
nit: 'for inputs' --> 'as inputs'
imasaki1
2011/11/11 00:25:52
Done.
|
| + |
| + Args: |
| + current_time: a string shows current time (e.g, 2011-11-08-16) |
|
dennis_jeffrey
2011/11/11 00:01:36
current_time: a string depicting a time in year-mo
imasaki1
2011/11/11 00:25:52
Done.
|
| + |
| + Returns: |
| + a tuple of stats and issues_txt |
| + stats: analyzer result in CSV format that shows: |
| + (current_time, the number of tests, the number of skipped tests, |
| + the number of failing tests) |
| + For example, |
| + "2011-11-10-15,204,22,12" |
| + issues_txt: issues listed in CSV format that shows: |
|
dennis_jeffrey
2011/11/11 00:01:36
Could this include information for multiple issues
imasaki1
2011/11/11 00:25:52
Done.
|
| + (BUGWK or BUGCR, bug number, the test expectation entry, |
| + the name of the test) |
| + For example, |
| + "71543,TIMEOUT PASS,media/media-element-play-after-eos.html," |
|
dennis_jeffrey
2011/11/11 00:01:36
This example seems to be missing the "BUGWK"/"BUGC
imasaki1
2011/11/11 00:25:52
Done.
|
| + """ |
| + stats = ','.join([current_time, str(len(self.result_map['whole'].keys())), |
| + str(len(self.result_map['skip'].keys())), |
|
dennis_jeffrey
2011/11/11 00:01:36
nit: indent this by 1 more space.
imasaki1
2011/11/11 00:25:52
Done.
|
| + str(len(self.result_map['nonskip'].keys()))]) |
|
dennis_jeffrey
2011/11/11 00:01:36
nit: indent this by 2 more spaces
imasaki1
2011/11/11 00:25:52
Done.
|
| + issues_txt = '' |
| + for (bug_txt, test_info_list) in ( |
|
dennis_jeffrey
2011/11/11 00:01:36
I believe the parens are unnecessary in '(bug_txt,
imasaki1
2011/11/11 00:25:52
Done.
|
| + self.GetListOfBugsForNonSkippedTests().iteritems()): |
|
dennis_jeffrey
2011/11/11 00:01:36
nit: indent this by 2 more spaces
imasaki1
2011/11/11 00:25:52
Done.
|
| + matches = re.match(r'(BUG(CR|WK))(\d+)', bug_txt) |
| + bug_prefix = '' |
|
dennis_jeffrey
2011/11/11 00:01:36
nit: 'bug_prefix' --> 'bug_suffix', since it's the
imasaki1
2011/11/11 00:25:52
Done.
|
| + bug_no = '' |
| + if matches: |
| + bug_prefix = matches.group(1) |
| + bug_no = matches.group(3) |
| + issues_txt += bug_prefix + ',' + bug_no + ',' |
| + for test_info in test_info_list: |
| + (test_name, te_info) = test_info |
|
dennis_jeffrey
2011/11/11 00:01:36
no need for parentheses here
imasaki1
2011/11/11 00:25:52
Done.
|
| + issues_txt += ' '.join(te_info.keys()) + ',' + test_name + ',' |
| + issues_txt += '\n' |
| + return (stats, issues_txt) |
|
dennis_jeffrey
2011/11/11 00:01:36
no need for parentheses here
imasaki1
2011/11/11 00:25:52
Done.
|
| + |
| def ConvertToString(self, prev_time, diff_map, bug_anno_map): |
| """Convert this result to HTML display for email. |
| @@ -144,19 +185,21 @@ class AnalyzerResultMap: |
| Returns: |
| a analyzer result string in HTML format. |
| """ |
| - return_str = ('<b>Statistics (Diff Compared to %s):</b><ul>' |
| - '<li>The number of tests: %d (%s)</li>' |
| - '<li>The number of failing skipped tests: %d (%s)</li>' |
| - '<li>The number of failing non-skipped tests: %d (%s)</li>' |
| - '<li>Passing rate: %d %%</li></ul>') % ( |
| - prev_time, len(self.result_map['whole'].keys()), |
| - AnalyzerResultMap.GetDiffString(diff_map['whole'], 'whole'), |
| - len(self.result_map['skip'].keys()), |
| - AnalyzerResultMap.GetDiffString(diff_map['skip'], 'skip'), |
| - len(self.result_map['nonskip'].keys()), |
| - AnalyzerResultMap.GetDiffString(diff_map['nonskip'], |
| - 'nonskip'), |
| - self.GetPassingRate()) |
| + return_str = '' |
| + if diff_map: |
| + return_str += ('<b>Statistics (Diff Compared to %s):</b><ul>' |
| + '<li>The number of tests: %d (%s)</li>' |
| + '<li>The number of failing skipped tests: %d (%s)</li>' |
| + '<li>The number of failing non-skipped tests: %d (%s)</li>' |
| + '<li>Passing rate: %d %%</li></ul>') % ( |
| + prev_time, len(self.result_map['whole'].keys()), |
| + AnalyzerResultMap.GetDiffString(diff_map['whole'], 'whole'), |
| + len(self.result_map['skip'].keys()), |
| + AnalyzerResultMap.GetDiffString(diff_map['skip'], 'skip'), |
| + len(self.result_map['nonskip'].keys()), |
| + AnalyzerResultMap.GetDiffString(diff_map['nonskip'], |
| + 'nonskip'), |
| + self.GetPassingRate()) |
| return_str += '<b>Current issues about failing non-skipped tests:</b>' |
| for (bug_txt, test_info_list) in ( |
| self.GetListOfBugsForNonSkippedTests().iteritems()): |
| @@ -255,7 +298,8 @@ class AnalyzerResultMap: |
| def SendStatusEmail(prev_time, analyzer_result_map, diff_map, |
| bug_anno_map, receiver_email_address, test_group_name, |
| - appended_text_to_email, email_content, rev_str): |
| + appended_text_to_email, email_content, rev_str, |
| + email_only_change_mode): |
| """Send status email. |
| Args: |
| @@ -285,14 +329,19 @@ def SendStatusEmail(prev_time, analyzer_result_map, diff_map, |
| rev_str: a revision string that contains revision information that is sent |
| out in the status email. It is obtained by calling |
| |GetRevisionString()|. |
| + email_only_change_mode: please refer to |options|. |
| """ |
| if rev_str: |
| email_content += '<br><b>Revision Information:</b>' |
| email_content += rev_str |
| localtime = time.asctime(time.localtime(time.time())) |
| + change_str = '' |
| + if email_only_change_mode: |
| + change_str = 'Status Change' |
|
dennis_jeffrey
2011/11/11 00:01:36
add a space right after the 'e' at the end of this
imasaki1
2011/11/11 00:25:52
Done.
|
| + subject = 'Layout Test Analyzer Result %s (%s): %s' % (change_str, |
|
dennis_jeffrey
2011/11/11 00:01:36
remove the space right after the first '%s'
imasaki1
2011/11/11 00:25:52
Done.
|
| + test_group_name, |
| + localtime) |
| # TODO(imasaki): remove my name from here. |
| - subject = 'Layout Test Analyzer Result (%s): %s' % (test_group_name, |
| - localtime) |
| SendEmail('imasaki@chromium.org', [receiver_email_address], |
| subject, email_content + appended_text_to_email) |