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 re | |
9 import time | 10 import time |
10 import traceback | 11 import traceback |
11 | 12 |
12 import buildbot_report | 13 import buildbot_report |
13 import constants | 14 import constants |
14 import flakiness_dashboard_results_uploader | 15 import flakiness_dashboard_results_uploader |
15 | 16 |
16 | 17 |
17 class BaseTestResult(object): | 18 class BaseTestResult(object): |
18 """A single result from a unit test.""" | 19 """A single result from a unit test.""" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 """Returns the all broken tests including failed, crashed, unknown.""" | 127 """Returns the all broken tests including failed, crashed, unknown.""" |
127 return self.failed + self.crashed + self.unknown | 128 return self.failed + self.crashed + self.unknown |
128 | 129 |
129 def _LogToFile(self, test_type, test_suite, build_type): | 130 def _LogToFile(self, test_type, test_suite, build_type): |
130 """Log results to local files which can be used for aggregation later.""" | 131 """Log results to local files which can be used for aggregation later.""" |
131 # TODO(frankf): Report tests that failed to run here too. | 132 # TODO(frankf): Report tests that failed to run here too. |
132 log_file_path = os.path.join(constants.CHROME_DIR, 'out', | 133 log_file_path = os.path.join(constants.CHROME_DIR, 'out', |
133 build_type, 'test_logs') | 134 build_type, 'test_logs') |
134 if not os.path.exists(log_file_path): | 135 if not os.path.exists(log_file_path): |
135 os.mkdir(log_file_path) | 136 os.mkdir(log_file_path) |
136 full_file_name = os.path.join(log_file_path, test_type) | 137 full_file_name = os.path.join( |
138 log_file_path, re.sub('\W', '_', test_type).lower() + '.log') | |
frankf
2012/12/26 18:23:59
how are the files unique after this change?
Isaac (away)
2012/12/26 19:24:14
They make it easier to differentiate the log files
| |
137 if not os.path.exists(full_file_name): | 139 if not os.path.exists(full_file_name): |
138 with open(full_file_name, 'w') as log_file: | 140 with open(full_file_name, 'w') as log_file: |
139 print >> log_file, '\n%s results for %s build %s:' % ( | 141 print >> log_file, '\n%s results for %s build %s:' % ( |
140 test_type, os.environ.get('BUILDBOT_BUILDERNAME'), | 142 test_type, os.environ.get('BUILDBOT_BUILDERNAME'), |
141 os.environ.get('BUILDBOT_BUILDNUMBER')) | 143 os.environ.get('BUILDBOT_BUILDNUMBER')) |
142 logging.info('Writing results to %s.' % full_file_name) | 144 logging.info('Writing results to %s.' % full_file_name) |
143 log_contents = [' %s result : %d tests ran' % (test_suite, | 145 log_contents = [' %s result : %d tests ran' % (test_suite, |
144 len(self.ok) + | 146 len(self.ok) + |
145 len(self.failed) + | 147 len(self.failed) + |
146 len(self.crashed) + | 148 len(self.crashed) + |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 | 249 |
248 if flakiness_server: | 250 if flakiness_server: |
249 self._LogToFlakinessDashboard(test_type, test_package, flakiness_server) | 251 self._LogToFlakinessDashboard(test_type, test_package, flakiness_server) |
250 | 252 |
251 def PrintAnnotation(self): | 253 def PrintAnnotation(self): |
252 """Print buildbot annotations for test results.""" | 254 """Print buildbot annotations for test results.""" |
253 if self.failed or self.crashed or self.overall_fail or self.timed_out: | 255 if self.failed or self.crashed or self.overall_fail or self.timed_out: |
254 buildbot_report.PrintError() | 256 buildbot_report.PrintError() |
255 else: | 257 else: |
256 print 'Step success!' # No annotation needed | 258 print 'Step success!' # No annotation needed |
OLD | NEW |