| 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..26e18e6f1d70df602f14b26958636d2af5b963e1
|
| --- /dev/null
|
| +++ b/media/tools/layout_tests/layouttest_analyzer.py
|
| @@ -0,0 +1,89 @@
|
| +#!/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."""
|
| +
|
| +import csv
|
| +from datetime import datetime
|
| +import optparse
|
| +import os
|
| +import time
|
| +import pickle
|
| +
|
| +from layouttests import LayoutTests
|
| +from test_expectations import TestExpectations
|
| +import layouttest_analyzer_helpers
|
| +from layouttest_analyzer_helpers import AnalyzerResultMap
|
| +
|
| +# 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.
|
| +DEBUG = False
|
| +
|
| +# Pre-defined default dirs.
|
| +RESULT_DIR = 'result'
|
| +ANNOTATION_DIR = 'anno'
|
| +
|
| +
|
| +def parse_option():
|
| + """Parse command line options using OptionParser.
|
| +
|
| + Returns:
|
| + (options, args) tuple which contains options
|
| + """
|
| + option_parser = optparse.OptionParser()
|
| +
|
| + option_parser.add_option("-r",
|
| + "--receiver-email-address",
|
| + dest="receiver_email_address",
|
| + help="reciever's email adddress",
|
| + default='imasaki@chromium.org')
|
| + (options, _) = option_parser.parse_args()
|
| + return options
|
| +
|
| +
|
| +def main():
|
| + """A main function for the analyzer."""
|
| + options = parse_option()
|
| +
|
| + if not DEBUG:
|
| + layouttests = LayoutTests(csv_file_path=os.path.join('testname',
|
| + 'media.csv'))
|
| + test_expectations = TestExpectations()
|
| + test_info_map = layouttests.JoinWithTestExpectation(test_expectations)
|
| + 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'
|
| + prev_analyzer_result_map = AnalyzerResultMap.Load(os.path.join(RESULT_DIR,
|
| + '2011-08-19-11'))
|
| +
|
| + # Read annotations.
|
| + anno_map = {}
|
| + file_path = os.path.join(ANNOTATION_DIR, 'anno.csv')
|
| + file_object = open(file_path)
|
| + 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 DEBUG:
|
| + # Save the current result.
|
| + t = datetime.now()
|
| + date = t.strftime("%Y-%m-%d-%H")
|
| + file_path = os.path.join(RESULT_DIR, date)
|
| + file_object = open(file_path, "wb")
|
| + pickle.dump(analyzer_result_map, file_object)
|
| + file_object.close()
|
| +
|
| +
|
| +if '__main__' == __name__:
|
| + main()
|
|
|