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

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

Issue 8364020: Upstream: Test scripts for Android (phase 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync again Created 9 years, 2 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') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
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
4 # found in the LICENSE file.
5
6
7 import logging
8
9
10 # Language values match constants in Sponge protocol buffer (sponge.proto).
11 JAVA = 5
12 PYTHON = 7
13
14
15 class BaseTestResult(object):
16 """A single result from a unit test."""
17
18 def __init__(self, name, log):
19 self.name = name
20 self.log = log
21
22
23 class SingleTestResult(BaseTestResult):
24 """Result information for a single test.
25
26 Args:
27 full_name: Full name of the test.
28 start_date: Date in milliseconds when the test began running.
29 dur: Duration of the test run in milliseconds.
30 lang: Language of the test (JAVA or PYTHON).
31 log: An optional string listing any errors.
32 error: A tuple of a short error message and a longer version used by Sponge
33 if test resulted in a fail or error. An empty tuple implies a pass.
34 """
35
36 def __init__(self, full_name, start_date, dur, lang, log='', error=()):
37 BaseTestResult.__init__(self, full_name, log)
38 name_pieces = full_name.rsplit('#')
39 if len(name_pieces) > 0:
40 self.test_name = name_pieces[1]
41 self.class_name = name_pieces[0]
42 else:
43 self.class_name = full_name
44 self.test_name = full_name
45 self.start_date = start_date
46 self.dur = dur
47 self.error = error
48 self.lang = lang
49
50
51 class TestResults(object):
52 """Results of a test run."""
53
54 def __init__(self):
55 self.ok = []
56 self.failed = []
57 self.crashed = []
58 self.unknown = []
59 self.disabled = []
60 self.unexpected_pass = []
61
62 @staticmethod
63 def FromOkAndFailed(ok, failed):
64 ret = TestResults()
65 ret.ok = ok
66 ret.failed = failed
67 return ret
68
69 @staticmethod
70 def FromTestResults(results):
71 """Combines a list of results in a single TestResults object."""
72 ret = TestResults()
73 for t in results:
74 ret.ok += t.ok
75 ret.failed += t.failed
76 ret.crashed += t.crashed
77 ret.unknown += t.unknown
78 ret.disabled += t.disabled
79 ret.unexpected_pass += t.unexpected_pass
80 return ret
81
82 def _Log(self, sorted_list):
83 for t in sorted_list:
84 logging.critical(t.name)
85 if t.log:
86 logging.critical(t.log)
87
88 def GetAllBroken(self):
89 """Returns the all broken tests including failed, crashed, unknown."""
90 return self.failed + self.crashed + self.unknown
91
92 def LogFull(self):
93 """Output all broken tests or 'passed' if none broken"""
94 logging.critical('*' * 80)
95 logging.critical('Final result')
96 if self.failed:
97 logging.critical('Failed:')
98 self._Log(sorted(self.failed))
99 if self.crashed:
100 logging.critical('Crashed:')
101 self._Log(sorted(self.crashed))
102 if self.unknown:
103 logging.critical('Unknown:')
104 self._Log(sorted(self.unknown))
105 if not self.GetAllBroken():
106 logging.critical('Passed')
107 logging.critical('*' * 80)
OLDNEW
« no previous file with comments | « build/android/test_package_executable.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698