| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Generic presubmit checks that can be reused by other presubmit checks.""" | 6 """Generic presubmit checks that can be reused by other presubmit checks.""" |
| 7 | 7 |
| 8 | 8 |
| 9 ### Description checks | 9 ### Description checks |
| 10 | 10 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 message_type = output_api.PresubmitNotifyResult | 162 message_type = output_api.PresubmitNotifyResult |
| 163 tests_suite = [] | 163 tests_suite = [] |
| 164 outputs = [] | 164 outputs = [] |
| 165 for unit_test in unit_tests: | 165 for unit_test in unit_tests: |
| 166 try: | 166 try: |
| 167 tests_suite.extend(_RunPythonUnitTests_LoadTests(input_api, unit_test)) | 167 tests_suite.extend(_RunPythonUnitTests_LoadTests(input_api, unit_test)) |
| 168 except ImportError: | 168 except ImportError: |
| 169 outputs.append(message_type("Failed to load %s" % unit_test, | 169 outputs.append(message_type("Failed to load %s" % unit_test, |
| 170 long_text=input_api.traceback.format_exc())) | 170 long_text=input_api.traceback.format_exc())) |
| 171 | 171 |
| 172 results = input_api.unittest.TextTestRunner(verbosity=0).run( | 172 buffer = input_api.cStringIO.StringIO() |
| 173 results = input_api.unittest.TextTestRunner(stream=buffer, verbosity=0).run( |
| 173 input_api.unittest.TestSuite(tests_suite)) | 174 input_api.unittest.TestSuite(tests_suite)) |
| 174 if not results.wasSuccessful(): | 175 if not results.wasSuccessful(): |
| 175 outputs.append(message_type("%d unit tests failed." % | 176 outputs.append(message_type("%d unit tests failed." % |
| 176 (len(results.failures) + len(results.errors)))) | 177 (len(results.failures) + len(results.errors)), |
| 178 long_text=buffer.getvalue())) |
| 177 return outputs | 179 return outputs |
| OLD | NEW |