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

Side by Side Diff: webkit/tools/layout_tests/test_output_xml_to_json.py

Issue 545145: Move the layout test scripts into a 'webkitpy' subdirectory in preparation... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: try to de-confuse svn and the try bots Created 10 years, 11 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
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """
7 This is a script for generating JSON from JUnit XML output (generated by
8 google tests with --gtest_output=xml option).
9 """
10 import logging
11 import optparse
12 import os
13 import sys
14 import time
15
16 from xml.dom import minidom
17
18 from layout_package import json_results_generator
19 from layout_package import path_utils
20 from layout_package import test_expectations
21
22 # Builder base URL where we have the archived test results.
23 BUILDER_BASE_URL = "http://build.chromium.org/buildbot/gtest-results/"
24
25
26 class JSONGeneratorFromXML(object):
27
28 def __init__(self, options):
29 self._options = options
30
31 # Check the results directory
32 if not os.path.exists(self._options.results_directory):
33 os.mkdir(self._options.results_directory)
34
35 results_xml_file = None
36 try:
37 results_xml_file = open(self._options.input_results_xml)
38 except IOError, e:
39 logging.fatal("Cannot open file %s",
40 self._options.input_results_xml)
41 sys.exit(1)
42
43 summary = self._ParseTestResultsXML(
44 minidom.parse(results_xml_file).documentElement)
45 results_xml_file.close()
46
47 json_results_generator.JSONResultsGenerator(
48 self._options.builder_name, self._options.build_name,
49 self._options.build_number, self._options.results_directory,
50 self._options.builder_base_url,
51 self._test_timings,
52 self._failures, self._passed_tests, self._skipped_tests,
53 self._tests_list)
54
55 def _ParseTestResultsXML(self, node):
56 self._tests_list = set()
57 self._passed_tests = set()
58 self._skipped_tests = set()
59 self._test_timings = {}
60 self._failures = {}
61
62 testcases = node.getElementsByTagName('testcase')
63 for testcase in testcases:
64 name = testcase.getAttribute('name')
65 classname = testcase.getAttribute('classname')
66 test_name = "%s.%s" % (classname, name)
67
68 status = testcase.getAttribute('status')
69 if status == 'notrun':
70 if name.startswith('DISABLED_'):
71 self._skipped_tests.add(test_name)
72 continue
73
74 failures = testcase.getElementsByTagName('failure')
75 if failures:
76 self._failures[test_name] = test_expectations.TEXT
77 else:
78 self._passed_tests.add(test_name)
79
80 self._test_timings[test_name] = float(
81 testcase.getAttribute('time'))
82 self._tests_list.add(test_name)
83
84
85 def main(options, args):
86 """Parse the tests results and generate JSON files.
87
88 Args:
89 options: a dictionary of command line options
90 args: a list of sub directories or files to test
91 """
92
93 if not options.test_type:
94 logging.error("--test-type needs to be specified.")
95 sys.exit(1)
96
97 canon_test_type = options.test_type.replace("-", "_")
98 if not options.input_results_xml:
99 options.input_results_xml = "%s.xml" % (canon_test_type)
100 if not options.builder_base_url:
101 options.builder_base_url = "%s%s/" % (BUILDER_BASE_URL,
102 options.test_type)
103
104 JSONGeneratorFromXML(options)
105
106 return
107
108 if '__main__' == __name__:
109 option_parser = optparse.OptionParser()
110 option_parser.add_option("", "--test-type", default="",
111 help="Test type that generated the results XML,"
112 " e.g. unit-tests.")
113 option_parser.add_option("", "--results-directory", default="./",
114 help="Output results directory source dir.")
115 option_parser.add_option("", "--input-results-xml", default="",
116 help="Test results xml file (input for us)."
117 " default is TEST_TYPE.xml")
118 option_parser.add_option("", "--builder-base-url", default="",
119 help=("A URL where we have the archived test "
120 "results. (default=%sTEST_TYPE_results/)"
121 % BUILDER_BASE_URL))
122 option_parser.add_option("", "--builder-name",
123 default="DUMMY_BUILDER_NAME",
124 help="The name of the builder shown on the "
125 "waterfall running this script e.g. WebKit.")
126 option_parser.add_option("", "--build-name",
127 default="DUMMY_BUILD_NAME",
128 help="The name of the builder used in its path, "
129 "e.g. webkit-rel.")
130 option_parser.add_option("", "--build-number",
131 default="DUMMY_BUILD_NUMBER",
132 help="The build number of the builder running"
133 "this script.")
134 options, args = option_parser.parse_args()
135 main(options, args)
OLDNEW
« no previous file with comments | « webkit/tools/layout_tests/test_output_formatter.sh ('k') | webkit/tools/layout_tests/test_types/fuzzy_image_diff.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698