summaryrefslogtreecommitdiffstats
path: root/media/tools
diff options
context:
space:
mode:
authorimasaki@google.com <imasaki@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 23:36:13 +0000
committerimasaki@google.com <imasaki@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 23:36:13 +0000
commit655fb3f83a68679635d1524c5f9ac7c82cb3e8d7 (patch)
tree770321a8415ef4727437c6de03354bd2d6033601 /media/tools
parentb5b9345b901482b8920e5c72029b0af84ff3694c (diff)
downloadchromium_src-655fb3f83a68679635d1524c5f9ac7c82cb3e8d7.zip
chromium_src-655fb3f83a68679635d1524c5f9ac7c82cb3e8d7.tar.gz
chromium_src-655fb3f83a68679635d1524c5f9ac7c82cb3e8d7.tar.bz2
Add one commandline paramter and one bug fix for the layout test analyzer.
* Bug fix: fix the issue when there is some files with file names other than '%Y-%m-%d-%H' format in result directory. * Add two command-line parameter to choose test group CSV file and test group name. The example of such CSV file can be found in testname/media.csv. The test group name shows up in the status email subject. This is necessary to make this analyzer works for arbitrary test group name. * minor doc change. Review URL: http://codereview.chromium.org/7806008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98883 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/tools')
-rw-r--r--media/tools/layout_tests/layouttest_analyzer.py24
-rw-r--r--media/tools/layout_tests/layouttest_analyzer_helpers.py29
-rw-r--r--media/tools/layout_tests/layouttest_analyzer_helpers_unittest.py12
3 files changed, 51 insertions, 14 deletions
diff --git a/media/tools/layout_tests/layouttest_analyzer.py b/media/tools/layout_tests/layouttest_analyzer.py
index 4e6092f..431a9f3 100644
--- a/media/tools/layout_tests/layouttest_analyzer.py
+++ b/media/tools/layout_tests/layouttest_analyzer.py
@@ -26,6 +26,9 @@ DEFAULT_GRAPH_FILE = os.path.join('graph', 'graph.html')
CURRENT_RESULT_FILE_FOR_DEBUG = os.path.join(RESULT_DIR, '2011-08-19-21')
PREV_TIME_FOR_DEBUG = '2011-08-19-11'
+DEFAULT_TEST_GROUP_FILE = os.path.join('testname', 'media.csv')
+DEFAULT_TEST_GROUP_NAME = 'media'
+
def parse_option():
"""Parse command-line options using OptionParser.
@@ -48,7 +51,9 @@ def parse_option():
action='store_true', default=False)
option_parser.add_option('-t', '--trend-graph-location',
dest='trend_graph_location',
- help=('trend graph location ',
+ help=('Location of the bug trend file; '
+ 'file is expected to be in Google '
+ 'Visualization API trend-line format '
'(defaults to %default)'),
default=DEFAULT_GRAPH_FILE)
option_parser.add_option('-a', '--bug-anno-file-location',
@@ -57,6 +62,17 @@ def parse_option():
'file is expected to be in CSV format '
'(default to %default)'),
default=DEFAULT_ANNO_FILE)
+ option_parser.add_option('-n', '--test-group-file-location',
+ dest='test_group_file_location',
+ help=('Location of the test group file; '
+ 'file is expected to be in CSV format '
+ '(default to %default)'),
+ default=DEFAULT_TEST_GROUP_FILE)
+ option_parser.add_option('-x', '--test-group-name',
+ dest='test_group_name',
+ help=('Name of test group '
+ '(default to %default)'),
+ default=DEFAULT_TEST_GROUP_NAME)
return option_parser.parse_args()[0]
@@ -67,8 +83,7 @@ def main():
# Do the main analysis.
if not options.debug:
- layouttests = LayoutTests(csv_file_path=os.path.join('testname',
- 'media.csv'))
+ layouttests = LayoutTests(csv_file_path=options.test_group_file_location)
analyzer_result_map = layouttest_analyzer_helpers.AnalyzerResultMap(
layouttests.JoinWithTestExpectation(TestExpectations()))
(prev_time, prev_analyzer_result_map) = (
@@ -93,7 +108,8 @@ def main():
layouttest_analyzer_helpers.SendStatusEmail(prev_time, analyzer_result_map,
prev_analyzer_result_map,
anno_map,
- options.receiver_email_address)
+ options.receiver_email_address,
+ options.test_group_name)
if not options.debug:
# Save the current result.
date = start_time.strftime('%Y-%m-%d-%H')
diff --git a/media/tools/layout_tests/layouttest_analyzer_helpers.py b/media/tools/layout_tests/layouttest_analyzer_helpers.py
index f06e9fe..ef5012c 100644
--- a/media/tools/layout_tests/layouttest_analyzer_helpers.py
+++ b/media/tools/layout_tests/layouttest_analyzer_helpers.py
@@ -265,7 +265,7 @@ class AnalyzerResultMap:
def SendStatusEmail(prev_time, analyzer_result_map, prev_analyzer_result_map,
- bug_anno_map, receiver_email_address):
+ bug_anno_map, receiver_email_address, test_group_name):
"""Send status email.
Args:
@@ -277,6 +277,7 @@ def SendStatusEmail(prev_time, analyzer_result_map, prev_analyzer_result_map,
bug_anno_map: bug annotation map where bug name and annotations are
stored.
receiver_email_address: receiver's email address.
+ test_group_name: string representing the test group name (e.g., 'media').
"""
diff_map = analyzer_result_map.CompareToOtherResultMap(
prev_analyzer_result_map)
@@ -310,9 +311,11 @@ def SendStatusEmail(prev_time, analyzer_result_map, prev_analyzer_result_map,
str += '</ul></ul>'
localtime = time.asctime(time.localtime(time.time()))
# TODO(imasaki): remove my name from here.
+ subject = 'Layout Test Analyzer Result (%s): %s' % (test_group_name,
+ localtime)
SendEmail('imasaki@chromium.org', 'Kenji Imasaki',
- [receiver_email_address], ['Layout Test Analyzer Result'],
- 'Layout Test Analyzer Result : ' + localtime, str)
+ [receiver_email_address], ['Layout Test Analyzer Result'], subject,
+ str)
def SendEmail(sender_email_address, sender_name, receivers_email_addresses,
@@ -369,20 +372,28 @@ def FindLatestTime(time_list):
|RESULT_DIR|.
Args:
- time_list: a list of time string in the form of '2011-10-23-23'.
+ time_list: a list of time string in the form of 'Year-Month-Day-Hour'
+ (e.g., 2011-10-23-23). Strings not in this format are ignored.
Returns:
a string representing latest time among the time_list or None if
- |time_list| is empty.
+ |time_list| is empty or no valid date string in |time_list|.
"""
if not time_list:
return None
latest_date = None
for t in time_list:
- item_date = datetime.strptime(t, '%Y-%m-%d-%H')
- if latest_date == None or latest_date < item_date:
- latest_date = item_date
- return latest_date.strftime('%Y-%m-%d-%H')
+ try:
+ item_date = datetime.strptime(t, '%Y-%m-%d-%H')
+ if latest_date == None or latest_date < item_date:
+ latest_date = item_date
+ except ValueError:
+ # Do nothing.
+ pass
+ if latest_date:
+ return latest_date.strftime('%Y-%m-%d-%H')
+ else:
+ return None
def FindLatestResult(result_dir):
diff --git a/media/tools/layout_tests/layouttest_analyzer_helpers_unittest.py b/media/tools/layout_tests/layouttest_analyzer_helpers_unittest.py
index 3d29925..deeb348 100644
--- a/media/tools/layout_tests/layouttest_analyzer_helpers_unittest.py
+++ b/media/tools/layout_tests/layouttest_analyzer_helpers_unittest.py
@@ -15,10 +15,20 @@ class TestLayoutTestAnalyzerHelpers(unittest.TestCase):
def testFindLatestTime(self):
time_list = ['2011-08-18-19', '2011-08-18-22', '2011-08-18-21',
- '2012-01-11-21']
+ '2012-01-11-21', '.foo']
self.assertEquals(layouttest_analyzer_helpers.FindLatestTime(time_list),
'2012-01-11-21')
+ def testFindLatestTimeWithEmptyList(self):
+ time_list = []
+ self.assertEquals(layouttest_analyzer_helpers.FindLatestTime(time_list),
+ None)
+
+ def testFindLatestTimeWithNoValidStringInList(self):
+ time_list = ['.foo1', '232232']
+ self.assertEquals(layouttest_analyzer_helpers.FindLatestTime(time_list),
+ None)
+
def GenerateTestDataWholeAndSkip(self):
"""You should call this method if you want to generate test data."""
file_path = os.path.join('test_data', 'base')