| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 from recipe_engine import util as recipe_util | 6 from recipe_engine import util as recipe_util |
| 7 | 7 |
| 8 from .util import GTestResults, TestResults | 8 from .util import GTestResults, TestResults |
| 9 | 9 |
| 10 # TODO(luqui): Destroy this DEPS hack. | 10 # TODO(luqui): Destroy this DEPS hack. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 finally: | 121 finally: |
| 122 with self.m.step.defer_results(): | 122 with self.m.step.defer_results(): |
| 123 for t in failing_tests: | 123 for t in failing_tests: |
| 124 self._summarize_retried_test(caller_api, t) | 124 self._summarize_retried_test(caller_api, t) |
| 125 | 125 |
| 126 def _invalid_test_results(self, test): | 126 def _invalid_test_results(self, test): |
| 127 self.m.tryserver.set_invalid_test_results_tryjob_result() | 127 self.m.tryserver.set_invalid_test_results_tryjob_result() |
| 128 self.m.python.failing_step(test.name, 'TEST RESULTS WERE INVALID') | 128 self.m.python.failing_step(test.name, 'TEST RESULTS WERE INVALID') |
| 129 | 129 |
| 130 def _summarize_retried_test(self, caller_api, test): | 130 def _summarize_retried_test(self, caller_api, test): |
| 131 """Summarizes test results and exits with a failing status if there were new |
| 132 failures.""" |
| 131 if not test.has_valid_results(caller_api, 'without patch'): | 133 if not test.has_valid_results(caller_api, 'without patch'): |
| 132 self._invalid_test_results(test) | 134 self._invalid_test_results(test) |
| 133 | 135 |
| 134 ignored_failures = set(test.failures(caller_api, 'without patch')) | 136 ignored_failures = set(test.failures(caller_api, 'without patch')) |
| 135 new_failures = ( | 137 new_failures = ( |
| 136 set(test.failures(caller_api, 'with patch')) - ignored_failures) | 138 set(test.failures(caller_api, 'with patch')) - ignored_failures) |
| 137 | 139 |
| 138 self.m.tryserver.add_failure_reason({ | 140 self.m.tryserver.add_failure_reason({ |
| 139 'test_name': test.name, | 141 'test_name': test.name, |
| 140 'new_failures': sorted(new_failures), | 142 'new_failures': sorted(new_failures), |
| 141 }) | 143 }) |
| 142 | 144 |
| 145 step_text = self.format_step_text([ |
| 146 ['failures:', new_failures], |
| 147 ['ignored:', ignored_failures] |
| 148 ]) |
| 143 try: | 149 try: |
| 144 self.m.python.inline( | 150 if new_failures: |
| 145 test.name, | 151 self.m.python.failing_step(test.name, step_text) |
| 146 r""" | 152 else: |
| 147 import sys, json | 153 self.m.python.succeeding_step(test.name, step_text) |
| 148 failures = json.load(open(sys.argv[1], 'rb')) | |
| 149 | |
| 150 success = True | |
| 151 | |
| 152 if failures['new']: | |
| 153 success = False | |
| 154 print 'New failures:' | |
| 155 for f in failures['new']: | |
| 156 print f | |
| 157 | |
| 158 if failures['ignored']: | |
| 159 print 'Ignored failures:' | |
| 160 for f in failures['ignored']: | |
| 161 print f | |
| 162 | |
| 163 sys.exit(0 if success else 1) | |
| 164 """, | |
| 165 args=[ | |
| 166 self.m.json.input({ | |
| 167 'new': list(new_failures), | |
| 168 'ignored': list(ignored_failures), | |
| 169 }) | |
| 170 ], | |
| 171 ) | |
| 172 finally: | 154 finally: |
| 173 p = self.m.step.active_result.presentation | |
| 174 | |
| 175 p.step_text += self.format_step_text([ | |
| 176 ['failures:', new_failures], | |
| 177 ['ignored:', ignored_failures] | |
| 178 ]) | |
| 179 | |
| 180 if new_failures: | 155 if new_failures: |
| 181 p.status = self.m.step.FAILURE | |
| 182 self.m.tryserver.set_test_failure_tryjob_result() | 156 self.m.tryserver.set_test_failure_tryjob_result() |
| 183 elif ignored_failures: | 157 elif ignored_failures: |
| 184 p.status = self.m.step.WARNING | 158 self.m.step.active_result.presentation.status = self.m.step.WARNING |
| 185 | 159 |
| 186 @recipe_util.returns_placeholder | 160 @recipe_util.returns_placeholder |
| 187 def test_results(self, add_json_log=True): | 161 def test_results(self, add_json_log=True): |
| 188 """A placeholder which will expand to '/tmp/file'. | 162 """A placeholder which will expand to '/tmp/file'. |
| 189 | 163 |
| 190 The recipe must provide the expected --json-test-results flag. | 164 The recipe must provide the expected --json-test-results flag. |
| 191 | 165 |
| 192 The test_results will be an instance of the TestResults class. | 166 The test_results will be an instance of the TestResults class. |
| 193 """ | 167 """ |
| 194 return TestResultsOutputPlaceholder(self, add_json_log) | 168 return TestResultsOutputPlaceholder(self, add_json_log) |
| 195 | 169 |
| 196 @recipe_util.returns_placeholder | 170 @recipe_util.returns_placeholder |
| 197 def gtest_results(self, add_json_log=True): | 171 def gtest_results(self, add_json_log=True): |
| 198 """A placeholder which will expand to | 172 """A placeholder which will expand to |
| 199 '--test-launcher-summary-output=/tmp/file'. | 173 '--test-launcher-summary-output=/tmp/file'. |
| 200 | 174 |
| 201 Provides the --test-launcher-summary-output flag since --flag=value | 175 Provides the --test-launcher-summary-output flag since --flag=value |
| 202 (i.e. a single token in the command line) is the required format. | 176 (i.e. a single token in the command line) is the required format. |
| 203 | 177 |
| 204 The test_results will be an instance of the GTestResults class. | 178 The test_results will be an instance of the GTestResults class. |
| 205 """ | 179 """ |
| 206 return GTestResultsOutputPlaceholder(self, add_json_log) | 180 return GTestResultsOutputPlaceholder(self, add_json_log) |
| 207 | 181 |
| OLD | NEW |