| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 logging | 6 import logging |
| 7 | 7 |
| 8 | 8 |
| 9 # Language values match constants in Sponge protocol buffer (sponge.proto). | 9 # Language values match constants in Sponge protocol buffer (sponge.proto). |
| 10 JAVA = 5 | 10 JAVA = 5 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 class TestResults(object): | 50 class TestResults(object): |
| 51 """Results of a test run.""" | 51 """Results of a test run.""" |
| 52 | 52 |
| 53 def __init__(self): | 53 def __init__(self): |
| 54 self.ok = [] | 54 self.ok = [] |
| 55 self.failed = [] | 55 self.failed = [] |
| 56 self.crashed = [] | 56 self.crashed = [] |
| 57 self.unknown = [] | 57 self.unknown = [] |
| 58 self.disabled = [] | 58 self.disabled = [] |
| 59 self.unexpected_pass = [] | 59 self.unexpected_pass = [] |
| 60 self.timed_out = False |
| 60 | 61 |
| 61 @staticmethod | 62 @staticmethod |
| 62 def FromOkAndFailed(ok, failed): | 63 def FromOkAndFailed(ok, failed, timed_out=False): |
| 63 ret = TestResults() | 64 ret = TestResults() |
| 64 ret.ok = ok | 65 ret.ok = ok |
| 65 ret.failed = failed | 66 ret.failed = failed |
| 67 ret.timed_out = timed_out |
| 66 return ret | 68 return ret |
| 67 | 69 |
| 68 @staticmethod | 70 @staticmethod |
| 69 def FromTestResults(results): | 71 def FromTestResults(results): |
| 70 """Combines a list of results in a single TestResults object.""" | 72 """Combines a list of results in a single TestResults object.""" |
| 71 ret = TestResults() | 73 ret = TestResults() |
| 72 for t in results: | 74 for t in results: |
| 73 ret.ok += t.ok | 75 ret.ok += t.ok |
| 74 ret.failed += t.failed | 76 ret.failed += t.failed |
| 75 ret.crashed += t.crashed | 77 ret.crashed += t.crashed |
| 76 ret.unknown += t.unknown | 78 ret.unknown += t.unknown |
| 77 ret.disabled += t.disabled | 79 ret.disabled += t.disabled |
| 78 ret.unexpected_pass += t.unexpected_pass | 80 ret.unexpected_pass += t.unexpected_pass |
| 81 if t.timed_out: |
| 82 ret.timed_out = True |
| 79 return ret | 83 return ret |
| 80 | 84 |
| 81 def _Log(self, sorted_list): | 85 def _Log(self, sorted_list): |
| 82 for t in sorted_list: | 86 for t in sorted_list: |
| 83 logging.critical(t.name) | 87 logging.critical(t.name) |
| 84 if t.log: | 88 if t.log: |
| 85 logging.critical(t.log) | 89 logging.critical(t.log) |
| 86 | 90 |
| 87 def GetAllBroken(self): | 91 def GetAllBroken(self): |
| 88 """Returns the all broken tests including failed, crashed, unknown.""" | 92 """Returns the all broken tests including failed, crashed, unknown.""" |
| 89 return self.failed + self.crashed + self.unknown | 93 return self.failed + self.crashed + self.unknown |
| 90 | 94 |
| 91 def LogFull(self): | 95 def LogFull(self): |
| 92 """Output all broken tests or 'passed' if none broken""" | 96 """Output all broken tests or 'passed' if none broken""" |
| 93 logging.critical('*' * 80) | 97 logging.critical('*' * 80) |
| 94 logging.critical('Final result') | 98 logging.critical('Final result') |
| 95 if self.failed: | 99 if self.failed: |
| 96 logging.critical('Failed:') | 100 logging.critical('Failed:') |
| 97 self._Log(sorted(self.failed)) | 101 self._Log(sorted(self.failed)) |
| 98 if self.crashed: | 102 if self.crashed: |
| 99 logging.critical('Crashed:') | 103 logging.critical('Crashed:') |
| 100 self._Log(sorted(self.crashed)) | 104 self._Log(sorted(self.crashed)) |
| 101 if self.unknown: | 105 if self.unknown: |
| 102 logging.critical('Unknown:') | 106 logging.critical('Unknown:') |
| 103 self._Log(sorted(self.unknown)) | 107 self._Log(sorted(self.unknown)) |
| 104 if not self.GetAllBroken(): | 108 if not self.GetAllBroken(): |
| 105 logging.critical('Passed') | 109 logging.critical('Passed') |
| 106 logging.critical('*' * 80) | 110 logging.critical('*' * 80) |
| OLD | NEW |