OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 | 5 |
6 import json | 6 import json |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import time | 9 import time |
10 import traceback | 10 import traceback |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 class TestResults(object): | 47 class TestResults(object): |
48 """Results of a test run.""" | 48 """Results of a test run.""" |
49 | 49 |
50 def __init__(self): | 50 def __init__(self): |
51 self.ok = [] | 51 self.ok = [] |
52 self.failed = [] | 52 self.failed = [] |
53 self.crashed = [] | 53 self.crashed = [] |
54 self.unknown = [] | 54 self.unknown = [] |
55 self.timed_out = False | 55 self.timed_out = False |
56 self.overall_fail = False | 56 self.overall_fail = False |
| 57 self.device_exception = None |
57 | 58 |
58 @staticmethod | 59 @staticmethod |
59 def FromRun(ok=None, failed=None, crashed=None, timed_out=False, | 60 def FromRun(ok=None, failed=None, crashed=None, timed_out=False, |
60 overall_fail=False): | 61 overall_fail=False, device_exception=None): |
61 ret = TestResults() | 62 ret = TestResults() |
62 ret.ok = ok or [] | 63 ret.ok = ok or [] |
63 ret.failed = failed or [] | 64 ret.failed = failed or [] |
64 ret.crashed = crashed or [] | 65 ret.crashed = crashed or [] |
65 ret.timed_out = timed_out | 66 ret.timed_out = timed_out |
66 ret.overall_fail = overall_fail | 67 ret.overall_fail = overall_fail |
| 68 ret.device_exception = device_exception |
67 return ret | 69 return ret |
68 | 70 |
69 @staticmethod | 71 @staticmethod |
70 def FromTestResults(results): | 72 def FromTestResults(results): |
71 """Combines a list of results in a single TestResults object.""" | 73 """Combines a list of results in a single TestResults object.""" |
72 ret = TestResults() | 74 ret = TestResults() |
73 for t in results: | 75 for t in results: |
74 ret.ok += t.ok | 76 ret.ok += t.ok |
75 ret.failed += t.failed | 77 ret.failed += t.failed |
76 ret.crashed += t.crashed | 78 ret.crashed += t.crashed |
(...skipping 25 matching lines...) Expand all Loading... |
102 exc_result = SingleTestResult( | 104 exc_result = SingleTestResult( |
103 full_name='PythonWrapper#' + test_name, | 105 full_name='PythonWrapper#' + test_name, |
104 start_date=start_date_ms, | 106 start_date=start_date_ms, |
105 dur=duration_ms, | 107 dur=duration_ms, |
106 log=(str(exc_type) + ' ' + log_msg)) | 108 log=(str(exc_type) + ' ' + log_msg)) |
107 | 109 |
108 results = TestResults() | 110 results = TestResults() |
109 results.failed.append(exc_result) | 111 results.failed.append(exc_result) |
110 return results | 112 return results |
111 | 113 |
| 114 @staticmethod |
| 115 def DeviceExceptions(results): |
| 116 return set(filter(lambda t: t.device_exception, results)) |
| 117 |
112 def _Log(self, sorted_list): | 118 def _Log(self, sorted_list): |
113 for t in sorted_list: | 119 for t in sorted_list: |
114 logging.critical(t.name) | 120 logging.critical(t.name) |
115 if t.log: | 121 if t.log: |
116 logging.critical(t.log) | 122 logging.critical(t.log) |
117 | 123 |
118 def GetAllBroken(self): | 124 def GetAllBroken(self): |
119 """Returns the all broken tests including failed, crashed, unknown.""" | 125 """Returns the all broken tests including failed, crashed, unknown.""" |
120 return self.failed + self.crashed + self.unknown | 126 return self.failed + self.crashed + self.unknown |
121 | 127 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 return summary_string | 190 return summary_string |
185 | 191 |
186 def PrintAnnotation(self): | 192 def PrintAnnotation(self): |
187 """Print buildbot annotations for test results.""" | 193 """Print buildbot annotations for test results.""" |
188 if self.timed_out: | 194 if self.timed_out: |
189 buildbot_report.PrintWarning() | 195 buildbot_report.PrintWarning() |
190 elif self.failed or self.crashed or self.overall_fail: | 196 elif self.failed or self.crashed or self.overall_fail: |
191 buildbot_report.PrintError() | 197 buildbot_report.PrintError() |
192 else: | 198 else: |
193 print 'Step success!' # No annotation needed | 199 print 'Step success!' # No annotation needed |
OLD | NEW |