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

Side by Side Diff: media/tools/layout_tests/layouttest_analyzer.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: Adding test name group name in commandline option. 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 """Main functions for the Layout Test Analyzer module.""" 6 """Main functions for the Layout Test Analyzer module."""
7 7
8 import csv 8 import csv
9 from datetime import datetime 9 from datetime import datetime
10 import optparse 10 import optparse
11 import os 11 import os
12 import pickle 12 import pickle
13 import time 13 import time
14 14
15 15
16 from layouttests import LayoutTests 16 from layouttests import LayoutTests
17 import layouttest_analyzer_helpers 17 import layouttest_analyzer_helpers
18 from test_expectations import TestExpectations 18 from test_expectations import TestExpectations
19 from trend_graph import TrendGraph 19 from trend_graph import TrendGraph
20 20
21 # Predefined result directory. 21 # Predefined result directory.
22 RESULT_DIR = 'result' 22 RESULT_DIR = 'result'
23 DEFAULT_ANNO_FILE = os.path.join('anno', 'anno.csv') 23 DEFAULT_ANNO_FILE = os.path.join('anno', 'anno.csv')
24 DEFAULT_GRAPH_FILE = os.path.join('graph', 'graph.html') 24 DEFAULT_GRAPH_FILE = os.path.join('graph', 'graph.html')
25 # Predefined result files for debug. 25 # Predefined result files for debug.
26 CURRENT_RESULT_FILE_FOR_DEBUG = os.path.join(RESULT_DIR, '2011-08-19-21') 26 CURRENT_RESULT_FILE_FOR_DEBUG = os.path.join(RESULT_DIR, '2011-08-19-21')
27 PREV_TIME_FOR_DEBUG = '2011-08-19-11' 27 PREV_TIME_FOR_DEBUG = '2011-08-19-11'
28 28
29 DEFAULT_TEST_GROUP_FILE = os.path.join('testname', 'media.csv')
30 DEFAULT_TEST_GROUP_NAME = 'media'
31
29 32
30 def parse_option(): 33 def parse_option():
31 """Parse command-line options using OptionParser. 34 """Parse command-line options using OptionParser.
32 35
33 Returns: 36 Returns:
34 an object containing all command-line option information. 37 an object containing all command-line option information.
35 """ 38 """
36 option_parser = optparse.OptionParser() 39 option_parser = optparse.OptionParser()
37 40
38 option_parser.add_option('-r', '--receiver-email-address', 41 option_parser.add_option('-r', '--receiver-email-address',
39 dest='receiver_email_address', 42 dest='receiver_email_address',
40 help=('receiver\'s email adddress (defaults to ' 43 help=('receiver\'s email adddress (defaults to '
41 '%default'), 44 '%default'),
42 default='imasaki@chromium.org') 45 default='imasaki@chromium.org')
43 option_parser.add_option('-g', '--debug-mode', dest='debug', 46 option_parser.add_option('-g', '--debug-mode', dest='debug',
44 help=('Debug mode is used when you want to debug ' 47 help=('Debug mode is used when you want to debug '
45 'the analyzer by using local file rather ' 48 'the analyzer by using local file rather '
46 'than getting data from SVN. This shortens ' 49 'than getting data from SVN. This shortens '
47 'the debugging time (off by default)'), 50 'the debugging time (off by default)'),
48 action='store_true', default=False) 51 action='store_true', default=False)
49 option_parser.add_option('-t', '--trend-graph-location', 52 option_parser.add_option('-t', '--trend-graph-location',
50 dest='trend_graph_location', 53 dest='trend_graph_location',
51 help=('trend graph location ', 54 help=('Location of the bug trend file; '
55 'file is expected to be in Google '
56 'Visualization API trend-line format '
52 '(defaults to %default)'), 57 '(defaults to %default)'),
53 default=DEFAULT_GRAPH_FILE) 58 default=DEFAULT_GRAPH_FILE)
54 option_parser.add_option('-a', '--bug-anno-file-location', 59 option_parser.add_option('-a', '--bug-anno-file-location',
55 dest='bug_annotation_file_location', 60 dest='bug_annotation_file_location',
56 help=('Location of the bug annotation file; ' 61 help=('Location of the bug annotation file; '
57 'file is expected to be in CSV format ' 62 'file is expected to be in CSV format '
58 '(default to %default)'), 63 '(default to %default)'),
59 default=DEFAULT_ANNO_FILE) 64 default=DEFAULT_ANNO_FILE)
65 option_parser.add_option('-n', '--test-group-file-location',
66 dest='test_group_file_location',
67 help=('Location of the test group file; '
68 'file is expected to be in CSV format '
69 '(default to %default)'),
70 default=DEFAULT_TEST_GROUP_FILE)
71 option_parser.add_option('-x', '--test-group-name',
72 dest='test_group_name',
73 help=('Name of test group '
74 '(default to %default)'),
75 default=DEFAULT_TEST_GROUP_NAME)
60 return option_parser.parse_args()[0] 76 return option_parser.parse_args()[0]
61 77
62 78
63 def main(): 79 def main():
64 """A main function for the analyzer.""" 80 """A main function for the analyzer."""
65 options = parse_option() 81 options = parse_option()
66 start_time = datetime.now() 82 start_time = datetime.now()
67 83
68 # Do the main analysis. 84 # Do the main analysis.
69 if not options.debug: 85 if not options.debug:
70 layouttests = LayoutTests(csv_file_path=os.path.join('testname', 86 layouttests = LayoutTests(csv_file_path=os.path.join(
dennis_jeffrey 2011/08/30 20:57:48 No need to call "os.path.join()" here, since that'
imasaki1 2011/08/30 21:47:39 Done.
71 'media.csv')) 87 options.test_group_file_location))
72 analyzer_result_map = layouttest_analyzer_helpers.AnalyzerResultMap( 88 analyzer_result_map = layouttest_analyzer_helpers.AnalyzerResultMap(
73 layouttests.JoinWithTestExpectation(TestExpectations())) 89 layouttests.JoinWithTestExpectation(TestExpectations()))
74 (prev_time, prev_analyzer_result_map) = ( 90 (prev_time, prev_analyzer_result_map) = (
75 layouttest_analyzer_helpers.FindLatestResult('result')) 91 layouttest_analyzer_helpers.FindLatestResult('result'))
76 else: 92 else:
77 analyzer_result_map = layouttest_analyzer_helpers.AnalyzerResultMap.Load( 93 analyzer_result_map = layouttest_analyzer_helpers.AnalyzerResultMap.Load(
78 CURRENT_RESULT_FILE_FOR_DEBUG) 94 CURRENT_RESULT_FILE_FOR_DEBUG)
79 prev_time = PREV_TIME_FOR_DEBUG 95 prev_time = PREV_TIME_FOR_DEBUG
80 prev_analyzer_result_map = ( 96 prev_analyzer_result_map = (
81 layouttest_analyzer_helpers.AnalyzerResultMap.Load( 97 layouttest_analyzer_helpers.AnalyzerResultMap.Load(
82 os.path.join(RESULT_DIR, prev_time))) 98 os.path.join(RESULT_DIR, prev_time)))
83 99
84 # Read bug annotations and generate an annotation map used for the status 100 # Read bug annotations and generate an annotation map used for the status
85 # email. 101 # email.
86 anno_map = {} 102 anno_map = {}
87 file_object = open(options.bug_annotation_file_location) 103 file_object = open(options.bug_annotation_file_location)
88 data = csv.reader(file_object) 104 data = csv.reader(file_object)
89 for row in data: 105 for row in data:
90 anno_map[row[0]] = row[1] 106 anno_map[row[0]] = row[1]
91 file_object.close() 107 file_object.close()
92 108
93 layouttest_analyzer_helpers.SendStatusEmail(prev_time, analyzer_result_map, 109 layouttest_analyzer_helpers.SendStatusEmail(prev_time, analyzer_result_map,
94 prev_analyzer_result_map, 110 prev_analyzer_result_map,
95 anno_map, 111 anno_map,
96 options.receiver_email_address) 112 options.receiver_email_address,
113 options.test_group_name)
97 if not options.debug: 114 if not options.debug:
98 # Save the current result. 115 # Save the current result.
99 date = start_time.strftime('%Y-%m-%d-%H') 116 date = start_time.strftime('%Y-%m-%d-%H')
100 file_path = os.path.join(RESULT_DIR, date) 117 file_path = os.path.join(RESULT_DIR, date)
101 analyzer_result_map.Save(file_path) 118 analyzer_result_map.Save(file_path)
102 119
103 # Trend graph update (if specified in the command-line argument). 120 # Trend graph update (if specified in the command-line argument).
104 trend_graph = TrendGraph(options.trend_graph_location) 121 trend_graph = TrendGraph(options.trend_graph_location)
105 datetime_string = start_time.strftime('%Y,%m,%d,%H,%M,%S') 122 datetime_string = start_time.strftime('%Y,%m,%d,%H,%M,%S')
106 # TODO(imasaki): add correct title and text instead of 'undefined'. 123 # TODO(imasaki): add correct title and text instead of 'undefined'.
107 data_map = ( 124 data_map = (
108 {'whole': (str(len(analyzer_result_map.result_map['whole'].keys())), 125 {'whole': (str(len(analyzer_result_map.result_map['whole'].keys())),
109 'undefined', 'undefined'), 126 'undefined', 'undefined'),
110 'skip': (str(len(analyzer_result_map.result_map['skip'].keys())), 127 'skip': (str(len(analyzer_result_map.result_map['skip'].keys())),
111 'undefined', 'undefined'), 128 'undefined', 'undefined'),
112 'nonskip': (str(len(analyzer_result_map.result_map['nonskip'].keys())), 129 'nonskip': (str(len(analyzer_result_map.result_map['nonskip'].keys())),
113 'undefined', 'undefined'), 130 'undefined', 'undefined'),
114 'passingrate': (str(analyzer_result_map.GetPassingRate()), 131 'passingrate': (str(analyzer_result_map.GetPassingRate()),
115 'undefined', 'undefined')}) 132 'undefined', 'undefined')})
116 trend_graph.Update(datetime_string, data_map) 133 trend_graph.Update(datetime_string, data_map)
117 134
118 135
119 if '__main__' == __name__: 136 if '__main__' == __name__:
120 main() 137 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698