| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api |
| 6 | 6 |
| 7 | 7 |
| 8 class TestResultsApi(recipe_api.RecipeApi): | 8 class TestResultsApi(recipe_api.RecipeApi): |
| 9 """Recipe module to upload gtest json results to test-results server.""" | 9 """Recipe module to upload gtest json results to test-results server.""" |
| 10 | 10 |
| 11 # TODO(estaab): Make test_results_server a configuration value. | |
| 12 def upload(self, gtest_results_file, test_type, chrome_revision, | 11 def upload(self, gtest_results_file, test_type, chrome_revision, |
| 13 test_results_server, downgrade_error_to_warning=True): | 12 test_results_server=None, downgrade_error_to_warning=True): |
| 14 """Upload gtest results json to test-results. | 13 """Upload gtest results json to test-results. |
| 15 | 14 |
| 16 Args: | 15 Args: |
| 17 gtest_results_file: Path to file containing gtest json. | 16 gtest_results_file: Path to file containing gtest json. |
| 18 test_type: Test type string, e.g. webkit_tests. | 17 test_type: Test type string, e.g. webkit_tests. |
| 19 test_results_server: Server where results should be uploaded. | 18 test_results_server: Server where results should be uploaded. |
| 20 downgrade_error_to_warning: If True, treat a failure to upload as a | 19 downgrade_error_to_warning: If True, treat a failure to upload as a |
| 21 warning. | 20 warning. |
| 22 | 21 |
| 23 Returns: | 22 Returns: |
| 24 The step result. | 23 The step result. |
| 25 """ | 24 """ |
| 26 try: | 25 try: |
| 27 self.m.python( | 26 return self.m.python( |
| 28 name='Upload to test-results [%s]' % test_type, | 27 name='Upload to test-results [%s]' % test_type, |
| 29 script=self.resource('upload_gtest_test_results.py'), | 28 script=self.resource('upload_gtest_test_results.py'), |
| 30 args=['--input-gtest-json', gtest_results_file, | 29 args=['--input-gtest-json', gtest_results_file, |
| 31 '--master-name', self.m.properties['mastername'], | 30 '--master-name', self.m.properties['mastername'], |
| 32 '--builder-name', self.m.properties['buildername'], | 31 '--builder-name', self.m.properties['buildername'], |
| 33 '--build-number', self.m.properties['buildnumber'], | 32 '--build-number', self.m.properties['buildnumber'], |
| 34 '--test-type', test_type, | 33 '--test-type', test_type, |
| 35 '--test-results-server', test_results_server, | 34 '--test-results-server', |
| 35 test_results_server or self.c.test_results_server, |
| 36 '--chrome-revision', chrome_revision]) | 36 '--chrome-revision', chrome_revision]) |
| 37 finally: | 37 except self.m.step.StepFailure as f: |
| 38 step_result = self.m.step.active_result | 38 if downgrade_error_to_warning: |
| 39 if (downgrade_error_to_warning and | 39 f.result.presentation.status = self.m.step.WARNING |
| 40 step_result.presentation.status == self.m.step.FAILURE): | 40 return f.result |
| 41 step_result.presentation.status = self.m.step.WARNING | |
| 42 return step_result | |
| 43 | |
| OLD | NEW |