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 import threading | 7 import threading |
8 | 8 |
9 | 9 |
10 class ResultType(object): | 10 class ResultType(object): |
(...skipping 24 matching lines...) Expand all Loading... |
35 duration: Time it took for the test to run in milliseconds. | 35 duration: Time it took for the test to run in milliseconds. |
36 log: An optional string listing any errors. | 36 log: An optional string listing any errors. |
37 """ | 37 """ |
38 assert name | 38 assert name |
39 assert test_type in ResultType.GetTypes() | 39 assert test_type in ResultType.GetTypes() |
40 self._name = name | 40 self._name = name |
41 self._test_type = test_type | 41 self._test_type = test_type |
42 self._duration = duration | 42 self._duration = duration |
43 self._log = log | 43 self._log = log |
44 self._tombstones = None | 44 self._tombstones = None |
45 self._logcat_url = None | |
46 | 45 |
47 def __str__(self): | 46 def __str__(self): |
48 return self._name | 47 return self._name |
49 | 48 |
50 def __repr__(self): | 49 def __repr__(self): |
51 return self._name | 50 return self._name |
52 | 51 |
53 def __cmp__(self, other): | 52 def __cmp__(self, other): |
54 # pylint: disable=W0212 | 53 # pylint: disable=W0212 |
55 return cmp(self._name, other._name) | 54 return cmp(self._name, other._name) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 def GetLog(self): | 88 def GetLog(self): |
90 """Get the test log.""" | 89 """Get the test log.""" |
91 return self._log | 90 return self._log |
92 | 91 |
93 def SetTombstones(self, tombstones): | 92 def SetTombstones(self, tombstones): |
94 self._tombstones = tombstones | 93 self._tombstones = tombstones |
95 | 94 |
96 def GetTombstones(self): | 95 def GetTombstones(self): |
97 return self._tombstones | 96 return self._tombstones |
98 | 97 |
99 def SetLogcatUrl(self, logcat_url): | |
100 self._logcat_url = logcat_url | |
101 | |
102 def GetLogcatUrl(self): | |
103 return self._logcat_url | |
104 | |
105 class TestRunResults(object): | 98 class TestRunResults(object): |
106 """Set of results for a test run.""" | 99 """Set of results for a test run.""" |
107 | 100 |
108 def __init__(self): | 101 def __init__(self): |
109 self._results = set() | 102 self._results = set() |
110 self._results_lock = threading.RLock() | 103 self._results_lock = threading.RLock() |
111 | 104 |
112 def GetLogs(self): | 105 def GetLogs(self): |
113 """Get the string representation of all test logs.""" | 106 """Get the string representation of all test logs.""" |
114 with self._results_lock: | 107 with self._results_lock: |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return self._GetType(ResultType.UNKNOWN) | 227 return self._GetType(ResultType.UNKNOWN) |
235 | 228 |
236 def GetNotPass(self): | 229 def GetNotPass(self): |
237 """Get the set of all non-passed test results.""" | 230 """Get the set of all non-passed test results.""" |
238 return self.GetAll() - self.GetPass() | 231 return self.GetAll() - self.GetPass() |
239 | 232 |
240 def DidRunPass(self): | 233 def DidRunPass(self): |
241 """Return whether the test run was successful.""" | 234 """Return whether the test run was successful.""" |
242 return not self.GetNotPass() - self.GetSkip() | 235 return not self.GetNotPass() - self.GetSkip() |
243 | 236 |
OLD | NEW |