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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 def _Log(self, sorted_list): | 118 def _Log(self, sorted_list): |
119 for t in sorted_list: | 119 for t in sorted_list: |
120 logging.critical(t.name) | 120 logging.critical(t.name) |
121 if t.log: | 121 if t.log: |
122 logging.critical(t.log) | 122 logging.critical(t.log) |
123 | 123 |
124 def GetAllBroken(self): | 124 def GetAllBroken(self): |
125 """Returns the all broken tests including failed, crashed, unknown.""" | 125 """Returns the all broken tests including failed, crashed, unknown.""" |
126 return self.failed + self.crashed + self.unknown | 126 return self.failed + self.crashed + self.unknown |
127 | 127 |
128 def LogFull(self, test_group, test_suite, build_type): | 128 def LogFull(self, test_group, test_suite, build_type, tests_to_run): |
129 """Output broken test logs, summarize in a log file and the test output.""" | 129 """Output broken test logs, summarize in a log file and the test output.""" |
130 # Output all broken tests or 'passed' if none broken. | 130 # Output all broken tests or 'passed' if none broken. |
131 logging.critical('*' * 80) | 131 logging.critical('*' * 80) |
132 logging.critical('Final result') | 132 logging.critical('Final result') |
133 if self.failed: | 133 if self.failed: |
134 logging.critical('Failed:') | 134 logging.critical('Failed:') |
135 self._Log(sorted(self.failed)) | 135 self._Log(sorted(self.failed)) |
136 if self.crashed: | 136 if self.crashed: |
137 logging.critical('Crashed:') | 137 logging.critical('Crashed:') |
138 self._Log(sorted(self.crashed)) | 138 self._Log(sorted(self.crashed)) |
(...skipping 30 matching lines...) Expand all Loading... |
169 print >> log_file, ''.join(log_contents) | 169 print >> log_file, ''.join(log_contents) |
170 content = {'test_group': test_group, | 170 content = {'test_group': test_group, |
171 'ok': [t.name for t in self.ok], | 171 'ok': [t.name for t in self.ok], |
172 'failed': [t.name for t in self.failed], | 172 'failed': [t.name for t in self.failed], |
173 'crashed': [t.name for t in self.failed], | 173 'crashed': [t.name for t in self.failed], |
174 'unknown': [t.name for t in self.unknown],} | 174 'unknown': [t.name for t in self.unknown],} |
175 with open(os.path.join(log_file_path, 'results.json'), 'a') as json_file: | 175 with open(os.path.join(log_file_path, 'results.json'), 'a') as json_file: |
176 print >> json_file, json.dumps(content) | 176 print >> json_file, json.dumps(content) |
177 | 177 |
178 # Summarize in the test output. | 178 # Summarize in the test output. |
179 summary_string = 'Summary:\n' | 179 summary = ['Summary:\n'] |
180 summary_string += 'RAN=%d\n' % (len(self.ok) + len(self.failed) + | 180 summary += ['TESTS_TO_RUN=%d\n' % (len(tests_to_run))] |
181 len(self.crashed) + len(self.unknown)) | 181 num_tests_ran = (len(self.ok) + len(self.failed) + |
182 summary_string += 'PASSED=%d\n' % (len(self.ok)) | 182 len(self.crashed) + len(self.unknown)) |
183 summary_string += 'FAILED=%d %s\n' % (len(self.failed), | 183 tests_passed = [t.name for t in self.ok] |
184 [t.name for t in self.failed]) | 184 tests_failed = [t.name for t in self.failed] |
185 summary_string += 'CRASHED=%d %s\n' % (len(self.crashed), | 185 tests_crashed = [t.name for t in self.crashed] |
186 [t.name for t in self.crashed]) | 186 tests_unknown = [t.name for t in self.unknown] |
187 summary_string += 'UNKNOWN=%d %s\n' % (len(self.unknown), | 187 summary += ['RAN=%d\n' % (num_tests_ran), |
188 [t.name for t in self.unknown]) | 188 'PASSED=%d\n' % len(tests_passed), |
| 189 'FAILED=%d %s\n' % (len(tests_failed), tests_failed), |
| 190 'CRASHED=%d %s\n' % (len(tests_crashed), tests_crashed), |
| 191 'UNKNOWN=%d %s\n' % (len(tests_unknown), tests_unknown)] |
| 192 if num_tests_ran != len(tests_to_run): |
| 193 # Add the list of tests we failed to run. |
| 194 tests_failed_to_run = list(set(tests_to_run) - set(tests_passed) - |
| 195 set(tests_failed) - set(tests_crashed) - |
| 196 set(tests_unknown)) |
| 197 summary += ['FAILED_TO_RUN=%d %s\n' % (len(tests_failed_to_run), |
| 198 tests_failed_to_run)] |
| 199 summary_string = ''.join(summary) |
189 logging.critical(summary_string) | 200 logging.critical(summary_string) |
190 return summary_string | 201 return summary_string |
191 | 202 |
192 def PrintAnnotation(self): | 203 def PrintAnnotation(self): |
193 """Print buildbot annotations for test results.""" | 204 """Print buildbot annotations for test results.""" |
194 if self.timed_out: | 205 if self.failed or self.crashed or self.overall_fail or self.timed_out: |
195 buildbot_report.PrintWarning() | |
196 elif self.failed or self.crashed or self.overall_fail: | |
197 buildbot_report.PrintError() | 206 buildbot_report.PrintError() |
198 else: | 207 else: |
199 print 'Step success!' # No annotation needed | 208 print 'Step success!' # No annotation needed |
OLD | NEW |