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

Side by Side Diff: build/android/test_result.py

Issue 10693110: [android] Split top-level scripts and libraries from build/android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copyright on __init__.py, removed #! on some pylib/ files. Created 8 years, 5 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
« no previous file with comments | « build/android/test_package_executable.py ('k') | build/android/valgrind_tools.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5
6 import logging
7
8
9 # Language values match constants in Sponge protocol buffer (sponge.proto).
10 JAVA = 5
11 PYTHON = 7
12
13
14 class BaseTestResult(object):
15 """A single result from a unit test."""
16
17 def __init__(self, name, log):
18 self.name = name
19 self.log = log
20
21
22 class SingleTestResult(BaseTestResult):
23 """Result information for a single test.
24
25 Args:
26 full_name: Full name of the test.
27 start_date: Date in milliseconds when the test began running.
28 dur: Duration of the test run in milliseconds.
29 lang: Language of the test (JAVA or PYTHON).
30 log: An optional string listing any errors.
31 error: A tuple of a short error message and a longer version used by Sponge
32 if test resulted in a fail or error. An empty tuple implies a pass.
33 """
34
35 def __init__(self, full_name, start_date, dur, lang, log='', error=()):
36 BaseTestResult.__init__(self, full_name, log)
37 name_pieces = full_name.rsplit('#')
38 if len(name_pieces) > 0:
39 self.test_name = name_pieces[1]
40 self.class_name = name_pieces[0]
41 else:
42 self.class_name = full_name
43 self.test_name = full_name
44 self.start_date = start_date
45 self.dur = dur
46 self.error = error
47 self.lang = lang
48
49
50 class TestResults(object):
51 """Results of a test run."""
52
53 def __init__(self):
54 self.ok = []
55 self.failed = []
56 self.crashed = []
57 self.unknown = []
58 self.disabled = []
59 self.unexpected_pass = []
60 self.timed_out = False
61 self.overall_fail = False
62
63 @staticmethod
64 def FromRun(ok=None, failed=None, crashed=None, timed_out=False,
65 overall_fail=False):
66 ret = TestResults()
67 ret.ok = ok or []
68 ret.failed = failed or []
69 ret.crashed = crashed or []
70 ret.timed_out = timed_out
71 ret.overall_fail = overall_fail
72 return ret
73
74 @staticmethod
75 def FromTestResults(results):
76 """Combines a list of results in a single TestResults object."""
77 ret = TestResults()
78 for t in results:
79 ret.ok += t.ok
80 ret.failed += t.failed
81 ret.crashed += t.crashed
82 ret.unknown += t.unknown
83 ret.disabled += t.disabled
84 ret.unexpected_pass += t.unexpected_pass
85 if t.timed_out:
86 ret.timed_out = True
87 if t.overall_fail:
88 ret.overall_fail = True
89 return ret
90
91 def _Log(self, sorted_list):
92 for t in sorted_list:
93 logging.critical(t.name)
94 if t.log:
95 logging.critical(t.log)
96
97 def GetAllBroken(self):
98 """Returns the all broken tests including failed, crashed, unknown."""
99 return self.failed + self.crashed + self.unknown
100
101 def LogFull(self):
102 """Output all broken tests or 'passed' if none broken"""
103 logging.critical('*' * 80)
104 logging.critical('Final result')
105 if self.failed:
106 logging.critical('Failed:')
107 self._Log(sorted(self.failed))
108 if self.crashed:
109 logging.critical('Crashed:')
110 self._Log(sorted(self.crashed))
111 if self.unknown:
112 logging.critical('Unknown:')
113 self._Log(sorted(self.unknown))
114 if not self.GetAllBroken():
115 logging.critical('Passed')
116 logging.critical('*' * 80)
117
118 # Summarize in the test output.
119 summary_string = 'Summary:\n'
120 summary_string += 'RAN=%d\n' % (len(self.ok) + len(self.failed) +
121 len(self.crashed) + len(self.unknown))
122 summary_string += 'PASSED=%d\n' % (len(self.ok))
123 summary_string += 'FAILED=%d %s\n' % (len(self.failed),
124 [t.name for t in self.failed])
125 summary_string += 'CRASHED=%d %s\n' % (len(self.crashed),
126 [t.name for t in self.crashed])
127 summary_string += 'UNKNOWN=%d %s\n' % (len(self.unknown),
128 [t.name for t in self.unknown])
129 logging.critical(summary_string)
130 return summary_string
OLDNEW
« no previous file with comments | « build/android/test_package_executable.py ('k') | build/android/valgrind_tools.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698