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

Unified Diff: media/tools/layout_tests/layouttest_analyzer.py

Issue 7693018: Intial checkin of layout test analyzer. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Minor modifications. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: media/tools/layout_tests/layouttest_analyzer.py
diff --git a/media/tools/layout_tests/layouttest_analyzer.py b/media/tools/layout_tests/layouttest_analyzer.py
new file mode 100644
index 0000000000000000000000000000000000000000..1b50684b335dc5c1644dba414397569f08672335
--- /dev/null
+++ b/media/tools/layout_tests/layouttest_analyzer.py
@@ -0,0 +1,113 @@
+#!/usr/bin/python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""A Module for LayoutTestAnalyzer main functions."""
dennis_jeffrey 2011/08/24 17:40:47 'Main functions for the Layout Test Analyzer modul
imasaki1 2011/08/25 23:57:03 Done.
+
+import csv
+from datetime import datetime
+import optparse
+import os
+import pickle
+import time
+
+
+from layouttests import LayoutTests
+import layouttest_analyzer_helpers
+from layouttest_analyzer_helpers import AnalyzerResultMap
dennis_jeffrey 2011/08/24 17:40:47 We probably don't need this if you already import
imasaki1 2011/08/25 23:57:03 Done.
+from test_expectations import TestExpectations
+from trend_graph import TrendGraph
+
+# Predefined result directory.
+RESULT_DIR = 'result'
+
+
+def parse_option():
+ """Parse command-line options using OptionParser.
+
+ Returns:
+ options which contains all command-line option information.
dennis_jeffrey 2011/08/24 17:40:47 'options which contains' --> 'an object containing
imasaki1 2011/08/25 23:57:03 Done.
+ """
+ option_parser = optparse.OptionParser()
+
+ option_parser.add_option('-r', '--receiver-email-address',
+ dest='receiver_email_address',
+ help="reciever's email adddress",
dennis_jeffrey 2011/08/24 17:40:47 might want to mention the default in this help str
imasaki1 2011/08/25 23:57:03 Done.
+ default='imasaki@chromium.org')
+ option_parser.add_option('-g', '--debug-mode', dest='debug',
+ help=('Debug mode is used when you want to debug '
+ 'the analyzer by using local file rather '
+ 'than getting data from SVN. This shortens '
+ 'the debugging time.'),
+ action='store_true', default=False)
+ option_parser.add_option('-t', '--trend-graph-location',
+ dest='trend_graph_location',
+ help='trend graph location', metavar='FILE',
dennis_jeffrey 2011/08/24 17:40:47 might want to mention this default in this help st
imasaki1 2011/08/25 23:57:03 Done.
+ default=os.path.join('graph', 'graph.html'))
+ option_parser.add_option('-a', '--bug-anno-file-location',
+ dest='bug_annotation_file_location',
+ help='bug annotation file location in CSV format',
dennis_jeffrey 2011/08/24 17:40:47 might want to mention this default in this help st
imasaki1 2011/08/25 23:57:03 Done.
+ default=os.path.join('anno', 'anno.csv'))
+ (options, _) = option_parser.parse_args()
+ return options
dennis_jeffrey 2011/08/24 17:40:47 maybe combine the above 2 lines into this? return
imasaki1 2011/08/25 23:57:03 Done.
+
+
+def main():
+ """A main function for the analyzer."""
+ options = parse_option()
+ t = datetime.now()
dennis_jeffrey 2011/08/24 17:40:47 maybe use a more descriptive variable name than 't
imasaki1 2011/08/25 23:57:03 Done.
+
+ # Do the main analysis.
+ if not options.debug:
+ layouttests = LayoutTests(csv_file_path=os.path.join('testname',
+ 'media.csv'))
+ test_expectations = TestExpectations()
+ test_info_map = layouttests.JoinWithTestExpectation(test_expectations)
dennis_jeffrey 2011/08/24 17:40:47 Maybe combine the above 2 lines? test_info_map =
imasaki1 2011/08/25 23:57:03 Done.
+ analyzer_result_map = AnalyzerResultMap(test_info_map)
+ (prev_time, prev_analyzer_result_map) = (
+ layouttest_analyzer_helpers.FindLatestResult('result'))
+ else:
+ analyzer_result_map = AnalyzerResultMap.Load(os.path.join(RESULT_DIR,
+ '2011-08-19-21'))
+ prev_time = '2011-08-19-11'
dennis_jeffrey 2011/08/24 17:40:47 you might want to consider making these date folde
imasaki1 2011/08/25 23:57:03 Done.
+ prev_analyzer_result_map = AnalyzerResultMap.Load(os.path.join(RESULT_DIR,
+ '2011-08-19-11'))
dennis_jeffrey 2011/08/24 17:40:47 use "prev_time" instead here. Also fix the indent
imasaki1 2011/08/25 23:57:03 Done.
+
+ # Read bug annotations and generate a annotation map used for the status
dennis_jeffrey 2011/08/24 17:40:47 nit: 'a' --> 'an'
imasaki1 2011/08/25 23:57:03 Done.
+ # email.
+ anno_map = {}
+ file_object = open(options.bug_annotation_file_location)
+ data = csv.reader(file_object)
+ for row in data:
+ anno_map[row[0]] = row[1]
+ file_object.close()
+
+ layouttest_analyzer_helpers.SendStatusEmail(prev_time, analyzer_result_map,
+ prev_analyzer_result_map,
+ anno_map,
+ options.receiver_email_address)
+ if not options.debug:
+ # Save the current result.
+ date = t.strftime('%Y-%m-%d-%H')
+ file_path = os.path.join(RESULT_DIR, date)
+ analyzer_result_map.Save(file_path)
+
+ # Trend graph update (if specified in the command-line argument).
+ trend_graph = TrendGraph(options.trend_graph_location)
+ datetime_string = t.strftime('%Y,%m,%d,%H,%M,%S')
+ # TODO(imasaki): add correct title and text instead of 'undefined'.
+ data_map = (
+ {'whole': (str(len(analyzer_result_map.result_map['whole'].keys())),
+ 'undefined', 'undefined'),
+ 'skip': (str(len(analyzer_result_map.result_map['skip'].keys())),
+ 'undefined', 'undefined'),
+ 'nonskip': (str(len(analyzer_result_map.result_map['nonskip'].keys())),
+ 'undefined', 'undefined'),
+ 'passingrate': (str(analyzer_result_map.GetPassingRate()),
+ 'undefined', 'undefined')})
dennis_jeffrey 2011/08/24 17:40:47 nit: indent this line by 1 more space to make it c
imasaki1 2011/08/25 23:57:03 Done.
+ trend_graph.Update(datetime_string, data_map)
+
+
+if '__main__' == __name__:
+ main()
dennis_jeffrey 2011/08/24 17:40:47 nit: only indent this line 2 spaces, not 4.
imasaki1 2011/08/25 23:57:03 Done.

Powered by Google App Engine
This is Rietveld 408576698