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

Side by Side Diff: media/tools/layout_tests/layouttest_analyzer.py

Issue 8469017: Support CSV output format for analyzer results. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month 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 sys 12 import sys
13 import time 13 import time
14 14
15 import layouttests 15 import layouttests
16 import layouttest_analyzer_helpers 16 import layouttest_analyzer_helpers
17 from test_expectations import TestExpectations 17 from test_expectations import TestExpectations
18 from trend_graph import TrendGraph 18 from trend_graph import TrendGraph
19 19
20 # Predefined result directory. 20 # Predefined result directory.
21 DEFAULT_RESULT_DIR = 'result' 21 DEFAULT_RESULT_DIR = 'result'
22 DEFAULT_ANNO_FILE = os.path.join('anno', 'anno.csv') 22 DEFAULT_ANNO_FILE = os.path.join('anno', 'anno.csv')
23 DEFAULT_GRAPH_FILE = os.path.join('graph', 'graph.html') 23 DEFAULT_GRAPH_FILE = os.path.join('graph', 'graph.html')
24 DEFAULT_STATS_CSV_FILENAME = 'stats.csv'
25 DEFAULT_ISSUES_CSV_FILENAME = 'issues.csv'
24 # Predefined result files for debug. 26 # Predefined result files for debug.
25 CUR_TIME_FOR_DEBUG = '2011-09-11-19' 27 CUR_TIME_FOR_DEBUG = '2011-09-11-19'
26 CURRENT_RESULT_FILE_FOR_DEBUG = os.path.join(DEFAULT_RESULT_DIR, 28 CURRENT_RESULT_FILE_FOR_DEBUG = os.path.join(DEFAULT_RESULT_DIR,
27 CUR_TIME_FOR_DEBUG) 29 CUR_TIME_FOR_DEBUG)
28 PREV_TIME_FOR_DEBUG = '2011-09-11-18' 30 PREV_TIME_FOR_DEBUG = '2011-09-11-18'
29 31
30 32
31 def ParseOption(): 33 def ParseOption():
32 """Parse command-line options using OptionParser. 34 """Parse command-line options using OptionParser.
33 35
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 """ 191 """
190 anno_map = {} 192 anno_map = {}
191 try: 193 try:
192 file_object = open(bug_annotation_file_location) 194 file_object = open(bug_annotation_file_location)
193 except IOError: 195 except IOError:
194 print 'cannot open annotation file %s. Skipping.' % ( 196 print 'cannot open annotation file %s. Skipping.' % (
195 bug_annotation_file_location) 197 bug_annotation_file_location)
196 else: 198 else:
197 data = csv.reader(file_object) 199 data = csv.reader(file_object)
198 for row in data: 200 for row in data:
199 anno_map[row[0]] = row[1] 201 if len(row) > 1:
202 anno_map[row[0]] = row[1]
200 file_object.close() 203 file_object.close()
201 204
202 appended_text_to_email = '' 205 appended_text_to_email = ''
203 if email_appended_text_file_location: 206 if email_appended_text_file_location:
204 try: 207 try:
205 file_object = open(email_appended_text_file_location) 208 file_object = open(email_appended_text_file_location)
206 except IOError: 209 except IOError:
207 print 'cannot open email appended text file %s. Skipping.' % ( 210 print 'cannot open email appended text file %s. Skipping.' % (
208 email_appended_text_file_location) 211 email_appended_text_file_location)
209 else: 212 else:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 (rev_str, simple_rev_str, rev, rev_date) = ( 269 (rev_str, simple_rev_str, rev, rev_date) = (
267 layouttest_analyzer_helpers.GetRevisionString(prev_time_in_float, 270 layouttest_analyzer_helpers.GetRevisionString(prev_time_in_float,
268 cur_time_in_float, 271 cur_time_in_float,
269 diff_map)) 272 diff_map))
270 email_content = analyzer_result_map.ConvertToString(prev_time, diff_map, 273 email_content = analyzer_result_map.ConvertToString(prev_time, diff_map,
271 anno_map) 274 anno_map)
272 if receiver_email_address: 275 if receiver_email_address:
273 layouttest_analyzer_helpers.SendStatusEmail( 276 layouttest_analyzer_helpers.SendStatusEmail(
274 prev_time, analyzer_result_map, diff_map, anno_map, 277 prev_time, analyzer_result_map, diff_map, anno_map,
275 receiver_email_address, test_group_name, 278 receiver_email_address, test_group_name,
276 appended_text_to_email, email_content, rev_str) 279 appended_text_to_email, email_content, rev_str,
280 email_only_change_mode)
277 if simple_rev_str: 281 if simple_rev_str:
278 simple_rev_str = '\'' + simple_rev_str + '\'' 282 simple_rev_str = '\'' + simple_rev_str + '\''
279 else: 283 else:
280 simple_rev_str = 'undefined' # GViz uses undefined for NONE. 284 simple_rev_str = 'undefined' # GViz uses undefined for NONE.
281 else: 285 else:
282 # Initial result should be written to tread-graph if there are no previous 286 # Initial result should be written to tread-graph if there are no previous
283 # results. 287 # results.
284 result_change = True 288 result_change = True
285 diff_map = None 289 diff_map = None
286 simple_rev_str = 'undefined' 290 simple_rev_str = 'undefined'
291 prev_time = None
dennis_jeffrey 2011/11/11 00:01:36 I think we could remove this line and just put 'No
imasaki1 2011/11/11 00:25:52 Done.
292 email_content = analyzer_result_map.ConvertToString(prev_time, diff_map,
293 anno_map)
287 return (result_change, diff_map, simple_rev_str, rev, rev_date, 294 return (result_change, diff_map, simple_rev_str, rev, rev_date,
288 email_content) 295 email_content)
289 296
290 297
291 def UpdateTrendGraph(start_time, analyzer_result_map, diff_map, simple_rev_str, 298 def UpdateTrendGraph(start_time, analyzer_result_map, diff_map, simple_rev_str,
292 trend_graph_location): 299 trend_graph_location):
293 """Update trend graph in GViz. 300 """Update trend graph in GViz.
294 301
295 Annotate the graph with revision information. 302 Annotate the graph with revision information.
296 303
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 options.test_group_name, 454 options.test_group_name,
448 options.result_directory_location)) 455 options.result_directory_location))
449 (anno_map, appended_text_to_email) = ReadEmailInformation( 456 (anno_map, appended_text_to_email) = ReadEmailInformation(
450 options.bug_annotation_file_location, 457 options.bug_annotation_file_location,
451 options.email_appended_text_file_location) 458 options.email_appended_text_file_location)
452 (result_change, diff_map, simple_rev_str, rev, rev_date, email_content) = ( 459 (result_change, diff_map, simple_rev_str, rev, rev_date, email_content) = (
453 SendEmail(prev_time, prev_analyzer_result_map, analyzer_result_map, 460 SendEmail(prev_time, prev_analyzer_result_map, analyzer_result_map,
454 anno_map, appended_text_to_email, 461 anno_map, appended_text_to_email,
455 options.email_only_change_mode, options.debug, 462 options.email_only_change_mode, options.debug,
456 options.receiver_email_address, options.test_group_name)) 463 options.receiver_email_address, options.test_group_name))
464 # Create CSV texts and save them for bug spreadsheet.
dennis_jeffrey 2011/11/11 00:01:36 I recommend adding a blank line right above this,
imasaki1 2011/11/11 00:25:52 Done.
465 (stats, issues_txt) = analyzer_result_map.ConvertToCSVText(
466 start_time.strftime('%Y-%m-%d-%H'))
467 file_object = open(os.path.join(options.result_directory_location,
468 DEFAULT_STATS_CSV_FILENAME), 'wb')
469 file_object.write(stats)
470 file_object.close()
471 file_object = open(os.path.join(options.result_directory_location,
472 DEFAULT_ISSUES_CSV_FILENAME), 'wb')
473 file_object.write(issues_txt)
474 file_object.close()
457 if not options.debug and (result_change or not prev_analyzer_result_map): 475 if not options.debug and (result_change or not prev_analyzer_result_map):
458 # Save the current result when result is changed or the script is 476 # Save the current result when result is changed or the script is
459 # executed for the first time. 477 # executed for the first time.
460 date = start_time.strftime('%Y-%m-%d-%H') 478 date = start_time.strftime('%Y-%m-%d-%H')
461 file_path = os.path.join(options.result_directory_location, date) 479 file_path = os.path.join(options.result_directory_location, date)
462 analyzer_result_map.Save(file_path) 480 analyzer_result_map.Save(file_path)
463 if result_change or not prev_analyzer_result_map: 481 if result_change or not prev_analyzer_result_map:
464 data_map = UpdateTrendGraph(start_time, analyzer_result_map, diff_map, 482 data_map = UpdateTrendGraph(start_time, analyzer_result_map, diff_map,
465 simple_rev_str, options.trend_graph_location) 483 simple_rev_str, options.trend_graph_location)
466 # Report the result to dashboard. 484 # Report the result to dashboard.
467 if options.dashboard_file_location: 485 if options.dashboard_file_location:
468 UpdateDashboard(options.dashboard_file_location, options.test_group_name, 486 UpdateDashboard(options.dashboard_file_location, options.test_group_name,
469 data_map, layouttests.DEFAULT_LAYOUTTEST_LOCATION, rev, 487 data_map, layouttests.DEFAULT_LAYOUTTEST_LOCATION, rev,
470 rev_date, options.receiver_email_address, 488 rev_date, options.receiver_email_address,
471 email_content) 489 email_content)
472 490
473 491
474 if '__main__' == __name__: 492 if '__main__' == __name__:
475 main() 493 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698