| OLD | NEW |
| 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 | 7 |
| 8 class ResultType(object): | 8 class ResultType(object): |
| 9 """Class enumerating test types.""" | 9 """Class enumerating test types.""" |
| 10 PASS = 'PASS' | 10 PASS = 'PASS' |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 """Set of results for a test run.""" | 66 """Set of results for a test run.""" |
| 67 def __init__(self): | 67 def __init__(self): |
| 68 self._results = set() | 68 self._results = set() |
| 69 | 69 |
| 70 def GetLogs(self): | 70 def GetLogs(self): |
| 71 """Get the string representation of all test logs.""" | 71 """Get the string representation of all test logs.""" |
| 72 s = [] | 72 s = [] |
| 73 for test_type in ResultType.GetTypes(): | 73 for test_type in ResultType.GetTypes(): |
| 74 if test_type != ResultType.PASS: | 74 if test_type != ResultType.PASS: |
| 75 for t in sorted(self._GetType(test_type)): | 75 for t in sorted(self._GetType(test_type)): |
| 76 s.append('[%s] %s:' % (test_type, t)) | 76 log = t.GetLog() |
| 77 s.append(t.GetLog()) | 77 if log: |
| 78 s.append('[%s] %s:' % (test_type, t)) |
| 79 s.append(log) |
| 78 return '\n'.join(s) | 80 return '\n'.join(s) |
| 79 | 81 |
| 80 def GetLongForm(self): | 82 def GetLongForm(self): |
| 81 """Get the long string representation of this object.""" | 83 """Get the long string representation of this object.""" |
| 82 s = [] | 84 s = [] |
| 83 s.append('ALL (%d tests)' % len(self._results)) | 85 s.append('ALL (%d tests)' % len(self._results)) |
| 84 for test_type in ResultType.GetTypes(): | 86 for test_type in ResultType.GetTypes(): |
| 85 tests = sorted(self._GetType(test_type)) | 87 tests = sorted(self._GetType(test_type)) |
| 86 if test_type == ResultType.PASS: | 88 if test_type == ResultType.PASS: |
| 87 s.append('%s (%d tests)' % (test_type, len(tests))) | 89 s.append('%s (%d tests)' % (test_type, len(tests))) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 """Get the set of all unknown test results.""" | 158 """Get the set of all unknown test results.""" |
| 157 return self._GetType(ResultType.UNKNOWN) | 159 return self._GetType(ResultType.UNKNOWN) |
| 158 | 160 |
| 159 def GetNotPass(self): | 161 def GetNotPass(self): |
| 160 """Get the set of all non-passed test results.""" | 162 """Get the set of all non-passed test results.""" |
| 161 return self.GetAll() - self.GetPass() | 163 return self.GetAll() - self.GetPass() |
| 162 | 164 |
| 163 def DidRunPass(self): | 165 def DidRunPass(self): |
| 164 """Return whether the test run was successful.""" | 166 """Return whether the test run was successful.""" |
| 165 return not self.GetNotPass() | 167 return not self.GetNotPass() |
| OLD | NEW |