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

Side by Side Diff: build/android/pylib/base/base_test_result.py

Issue 558883003: [Android] Allow instrumentation test skipping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « build/android/PRESUBMIT.py ('k') | build/android/pylib/instrumentation/test_runner.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Module containing base test results classes.""" 5 """Module containing base test results classes."""
6 6
7 class ResultType(object): 7 class ResultType(object):
8 """Class enumerating test types.""" 8 """Class enumerating test types."""
9 PASS = 'PASS' 9 PASS = 'PASS'
10 SKIP = 'SKIP'
10 FAIL = 'FAIL' 11 FAIL = 'FAIL'
11 CRASH = 'CRASH' 12 CRASH = 'CRASH'
12 TIMEOUT = 'TIMEOUT' 13 TIMEOUT = 'TIMEOUT'
13 UNKNOWN = 'UNKNOWN' 14 UNKNOWN = 'UNKNOWN'
14 15
15 @staticmethod 16 @staticmethod
16 def GetTypes(): 17 def GetTypes():
17 """Get a list of all test types.""" 18 """Get a list of all test types."""
18 return [ResultType.PASS, ResultType.FAIL, ResultType.CRASH, 19 return [ResultType.PASS, ResultType.SKIP, ResultType.FAIL,
19 ResultType.TIMEOUT, ResultType.UNKNOWN] 20 ResultType.CRASH, ResultType.TIMEOUT, ResultType.UNKNOWN]
20 21
21 22
22 class BaseTestResult(object): 23 class BaseTestResult(object):
23 """Base class for a single test result.""" 24 """Base class for a single test result."""
24 25
25 def __init__(self, name, test_type, log=''): 26 def __init__(self, name, test_type, log=''):
26 """Construct a BaseTestResult. 27 """Construct a BaseTestResult.
27 28
28 Args: 29 Args:
29 name: Name of the test which defines uniqueness. 30 name: Name of the test which defines uniqueness.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 def GetGtestForm(self): 92 def GetGtestForm(self):
92 """Get the gtest string representation of this object.""" 93 """Get the gtest string representation of this object."""
93 s = [] 94 s = []
94 plural = lambda n, s, p: '%d %s' % (n, p if n != 1 else s) 95 plural = lambda n, s, p: '%d %s' % (n, p if n != 1 else s)
95 tests = lambda n: plural(n, 'test', 'tests') 96 tests = lambda n: plural(n, 'test', 'tests')
96 97
97 s.append('[==========] %s ran.' % (tests(len(self.GetAll())))) 98 s.append('[==========] %s ran.' % (tests(len(self.GetAll()))))
98 s.append('[ PASSED ] %s.' % (tests(len(self.GetPass())))) 99 s.append('[ PASSED ] %s.' % (tests(len(self.GetPass()))))
99 100
100 not_passed = self.GetNotPass() 101 skipped = self.GetSkip()
101 if len(not_passed) > 0: 102 if skipped:
102 s.append('[ FAILED ] %s, listed below:' % tests(len(self.GetNotPass()))) 103 s.append('[ SKIPPED ] Skipped %s, listed below:' % tests(len(skipped)))
103 for t in self.GetFail(): 104 for t in sorted(skipped):
105 s.append('[ SKIPPED ] %s' % str(t))
106
107 all_failures = self.GetFail().union(self.GetCrash(), self.GetTimeout(),
108 self.GetUnknown())
109 if all_failures:
110 s.append('[ FAILED ] %s, listed below:' % tests(len(all_failures)))
111 for t in sorted(self.GetFail()):
104 s.append('[ FAILED ] %s' % str(t)) 112 s.append('[ FAILED ] %s' % str(t))
105 for t in self.GetCrash(): 113 for t in sorted(self.GetCrash()):
106 s.append('[ FAILED ] %s (CRASHED)' % str(t)) 114 s.append('[ FAILED ] %s (CRASHED)' % str(t))
107 for t in self.GetTimeout(): 115 for t in sorted(self.GetTimeout()):
108 s.append('[ FAILED ] %s (TIMEOUT)' % str(t)) 116 s.append('[ FAILED ] %s (TIMEOUT)' % str(t))
109 for t in self.GetUnknown(): 117 for t in sorted(self.GetUnknown()):
110 s.append('[ FAILED ] %s (UNKNOWN)' % str(t)) 118 s.append('[ FAILED ] %s (UNKNOWN)' % str(t))
111 s.append('') 119 s.append('')
112 s.append(plural(len(not_passed), 'FAILED TEST', 'FAILED TESTS')) 120 s.append(plural(len(all_failures), 'FAILED TEST', 'FAILED TESTS'))
113 return '\n'.join(s) 121 return '\n'.join(s)
114 122
115 def GetShortForm(self): 123 def GetShortForm(self):
116 """Get the short string representation of this object.""" 124 """Get the short string representation of this object."""
117 s = [] 125 s = []
118 s.append('ALL: %d' % len(self._results)) 126 s.append('ALL: %d' % len(self._results))
119 for test_type in ResultType.GetTypes(): 127 for test_type in ResultType.GetTypes():
120 s.append('%s: %d' % (test_type, len(self._GetType(test_type)))) 128 s.append('%s: %d' % (test_type, len(self._GetType(test_type))))
121 return ''.join([x.ljust(15) for x in s]) 129 return ''.join([x.ljust(15) for x in s])
122 130
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return self._results.copy() 164 return self._results.copy()
157 165
158 def _GetType(self, test_type): 166 def _GetType(self, test_type):
159 """Get the set of test results with the given test type.""" 167 """Get the set of test results with the given test type."""
160 return set(t for t in self._results if t.GetType() == test_type) 168 return set(t for t in self._results if t.GetType() == test_type)
161 169
162 def GetPass(self): 170 def GetPass(self):
163 """Get the set of all passed test results.""" 171 """Get the set of all passed test results."""
164 return self._GetType(ResultType.PASS) 172 return self._GetType(ResultType.PASS)
165 173
174 def GetSkip(self):
175 """Get the set of all skipped test results."""
176 return self._GetType(ResultType.SKIP)
177
166 def GetFail(self): 178 def GetFail(self):
167 """Get the set of all failed test results.""" 179 """Get the set of all failed test results."""
168 return self._GetType(ResultType.FAIL) 180 return self._GetType(ResultType.FAIL)
169 181
170 def GetCrash(self): 182 def GetCrash(self):
171 """Get the set of all crashed test results.""" 183 """Get the set of all crashed test results."""
172 return self._GetType(ResultType.CRASH) 184 return self._GetType(ResultType.CRASH)
173 185
174 def GetTimeout(self): 186 def GetTimeout(self):
175 """Get the set of all timed out test results.""" 187 """Get the set of all timed out test results."""
176 return self._GetType(ResultType.TIMEOUT) 188 return self._GetType(ResultType.TIMEOUT)
177 189
178 def GetUnknown(self): 190 def GetUnknown(self):
179 """Get the set of all unknown test results.""" 191 """Get the set of all unknown test results."""
180 return self._GetType(ResultType.UNKNOWN) 192 return self._GetType(ResultType.UNKNOWN)
181 193
182 def GetNotPass(self): 194 def GetNotPass(self):
183 """Get the set of all non-passed test results.""" 195 """Get the set of all non-passed test results."""
184 return self.GetAll() - self.GetPass() 196 return self.GetAll() - self.GetPass()
185 197
186 def DidRunPass(self): 198 def DidRunPass(self):
187 """Return whether the test run was successful.""" 199 """Return whether the test run was successful."""
188 return not self.GetNotPass() 200 return not (self.GetNotPass() - self.GetSkip())
201
OLDNEW
« no previous file with comments | « build/android/PRESUBMIT.py ('k') | build/android/pylib/instrumentation/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698