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

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

Issue 342823004: [Android] Switch long form test result reporting to a gtest-esque format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 | « no previous file | build/android/pylib/base/base_test_result_unittest.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 FAIL = 'FAIL' 10 FAIL = 'FAIL'
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 s = [] 81 s = []
82 for test_type in ResultType.GetTypes(): 82 for test_type in ResultType.GetTypes():
83 if test_type != ResultType.PASS: 83 if test_type != ResultType.PASS:
84 for t in sorted(self._GetType(test_type)): 84 for t in sorted(self._GetType(test_type)):
85 log = t.GetLog() 85 log = t.GetLog()
86 if log: 86 if log:
87 s.append('[%s] %s:' % (test_type, t)) 87 s.append('[%s] %s:' % (test_type, t))
88 s.append(log) 88 s.append(log)
89 return '\n'.join(s) 89 return '\n'.join(s)
90 90
91 def GetLongForm(self): 91 def GetGtestForm(self):
92 """Get the long string representation of this object.""" 92 """Get the gtest string representation of this object."""
93 s = [] 93 s = []
94 s.append('ALL (%d tests)' % len(self._results)) 94 plural = lambda n, s, p: '%d %s' % (n, p if n != 1 else s)
95 for test_type in ResultType.GetTypes(): 95 tests = lambda n: plural(n, 'test', 'tests')
96 tests = sorted(self._GetType(test_type)) 96
97 if test_type == ResultType.PASS: 97 s.append('[==========] %s ran.' % (tests(len(self.GetAll()))))
98 s.append('%s (%d tests)' % (test_type, len(tests))) 98 s.append('[ PASSED ] %s.' % (tests(len(self.GetPass()))))
99 else: 99
100 s.append('%s (%d tests): %s' % (test_type, len(tests), tests)) 100 not_passed = self.GetNotPass()
101 if len(not_passed) > 0:
102 s.append('[ FAILED ] %s, listed below:' % tests(len(self.GetNotPass())))
103 for t in self.GetFail():
104 s.append('[ FAILED ] %s' % str(t))
105 for t in self.GetCrash():
106 s.append('[ FAILED ] %s (CRASHED)' % str(t))
107 for t in self.GetTimeout():
108 s.append('[ FAILED ] %s (TIMEOUT)' % str(t))
109 for t in self.GetUnknown():
110 s.append('[ FAILED ] %s (UNKNOWN)' % str(t))
111 s.append('')
112 s.append(plural(len(not_passed), 'FAILED TEST', 'FAILED TESTS'))
101 return '\n'.join(s) 113 return '\n'.join(s)
102 114
103 def GetShortForm(self): 115 def GetShortForm(self):
104 """Get the short string representation of this object.""" 116 """Get the short string representation of this object."""
105 s = [] 117 s = []
106 s.append('ALL: %d' % len(self._results)) 118 s.append('ALL: %d' % len(self._results))
107 for test_type in ResultType.GetTypes(): 119 for test_type in ResultType.GetTypes():
108 s.append('%s: %d' % (test_type, len(self._GetType(test_type)))) 120 s.append('%s: %d' % (test_type, len(self._GetType(test_type))))
109 return ''.join([x.ljust(15) for x in s]) 121 return ''.join([x.ljust(15) for x in s])
110 122
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 """Get the set of all unknown test results.""" 179 """Get the set of all unknown test results."""
168 return self._GetType(ResultType.UNKNOWN) 180 return self._GetType(ResultType.UNKNOWN)
169 181
170 def GetNotPass(self): 182 def GetNotPass(self):
171 """Get the set of all non-passed test results.""" 183 """Get the set of all non-passed test results."""
172 return self.GetAll() - self.GetPass() 184 return self.GetAll() - self.GetPass()
173 185
174 def DidRunPass(self): 186 def DidRunPass(self):
175 """Return whether the test run was successful.""" 187 """Return whether the test run was successful."""
176 return not self.GetNotPass() 188 return not self.GetNotPass()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/base/base_test_result_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698