| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 """Entry point for fully-annotated builds. | 6 """Entry point for fully-annotated builds. |
| 7 | 7 |
| 8 This script is part of the effort to move all builds to annotator-based | 8 This script is part of the effort to move all builds to annotator-based |
| 9 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() | 9 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() |
| 10 found in scripts/master/factory/annotator_factory.py executes a single | 10 found in scripts/master/factory/annotator_factory.py executes a single |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 status_mapping.get(self.status, lambda: None)() | 170 status_mapping.get(self.status, lambda: None)() |
| 171 | 171 |
| 172 | 172 |
| 173 class StepData(object): | 173 class StepData(object): |
| 174 def __init__(self, step, retcode): | 174 def __init__(self, step, retcode): |
| 175 self._retcode = retcode | 175 self._retcode = retcode |
| 176 self._step = step | 176 self._step = step |
| 177 | 177 |
| 178 self._presentation = StepPresentation() | 178 self._presentation = StepPresentation() |
| 179 self.abort_reason = None |
| 179 | 180 |
| 180 @property | 181 @property |
| 181 def step(self): | 182 def step(self): |
| 182 return copy.deepcopy(self._step) | 183 return copy.deepcopy(self._step) |
| 183 | 184 |
| 184 @property | 185 @property |
| 185 def retcode(self): | 186 def retcode(self): |
| 186 return self._retcode | 187 return self._retcode |
| 187 | 188 |
| 188 @property | 189 @property |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 279 |
| 279 step_history[step['name']] = step_result | 280 step_history[step['name']] = step_result |
| 280 annotator_step.annotation_stream.step_cursor(step['name']) | 281 annotator_step.annotation_stream.step_cursor(step['name']) |
| 281 if step_result.retcode != 0 and test_data_item is None: | 282 if step_result.retcode != 0 and test_data_item is None: |
| 282 # To avoid cluttering the expectations, don't emit this in testmode. | 283 # To avoid cluttering the expectations, don't emit this in testmode. |
| 283 annotator_step.emit('step returned non-zero exit code: %d' % | 284 annotator_step.emit('step returned non-zero exit code: %d' % |
| 284 step_result.retcode) | 285 step_result.retcode) |
| 285 | 286 |
| 286 call_placeholders(step_result, placeholders, test_data_item) | 287 call_placeholders(step_result, placeholders, test_data_item) |
| 287 | 288 |
| 288 if followup_fn: | 289 try: |
| 289 followup_fn(step_result) | 290 if followup_fn: |
| 291 followup_fn(step_result) |
| 292 except recipe_api.RecipeAbort as e: |
| 293 step_result.abort_reason = str(e) |
| 290 | 294 |
| 291 step_result.presentation.finalize(annotator_step) | 295 step_result.presentation.finalize(annotator_step) |
| 292 return step_result | 296 return step_result |
| 293 if followup_fn: | 297 if followup_fn: |
| 294 _inner.__name__ = followup_fn.__name__ | 298 _inner.__name__ = followup_fn.__name__ |
| 295 | 299 |
| 296 return _inner | 300 return _inner |
| 297 | 301 |
| 298 | 302 |
| 299 def get_args(argv): | 303 def get_args(argv): |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 with stream.step(step['name']) as s: | 419 with stream.step(step['name']) as s: |
| 416 s.stream = cStringIO.StringIO() | 420 s.stream = cStringIO.StringIO() |
| 417 step_result = callback(s, test_data_item.pop('$R', 0)) | 421 step_result = callback(s, test_data_item.pop('$R', 0)) |
| 418 lines = filter(None, s.stream.getvalue().splitlines()) | 422 lines = filter(None, s.stream.getvalue().splitlines()) |
| 419 if lines: | 423 if lines: |
| 420 # Note that '~' sorts after 'z' so that this will be last on each | 424 # Note that '~' sorts after 'z' so that this will be last on each |
| 421 # step. Also use _step to get access to the mutable step dictionary. | 425 # step. Also use _step to get access to the mutable step dictionary. |
| 422 # pylint: disable=W0212 | 426 # pylint: disable=W0212 |
| 423 step_result._step['~followup_annotations'] = lines | 427 step_result._step['~followup_annotations'] = lines |
| 424 | 428 |
| 429 if step_result.abort_reason: |
| 430 stream.emit('Aborted: %s' % step_result.abort_reason) |
| 431 test_data = {} # Dump the rest of the test data |
| 432 break |
| 433 |
| 425 # TODO(iannucci): Pull this failure calculation into callback. | 434 # TODO(iannucci): Pull this failure calculation into callback. |
| 426 failed = annotator.update_build_failure(failed, step_result.retcode, **step) | 435 failed = annotator.update_build_failure(failed, step_result.retcode, **step) |
| 427 | 436 |
| 428 assert not test_mode or test_data == {}, ( | 437 assert not test_mode or test_data == {}, ( |
| 429 "Unconsumed test data! %s" % (test_data,)) | 438 "Unconsumed test data! %s" % (test_data,)) |
| 430 | 439 |
| 431 return MakeStepsRetval(0 if not failed else 1, step_history) | 440 return MakeStepsRetval(0 if not failed else 1, step_history) |
| 432 | 441 |
| 433 | 442 |
| 434 def UpdateScripts(): | 443 def UpdateScripts(): |
| (...skipping 16 matching lines...) Expand all Loading... |
| 451 | 460 |
| 452 def shell_main(argv): | 461 def shell_main(argv): |
| 453 if UpdateScripts(): | 462 if UpdateScripts(): |
| 454 return subprocess.call([sys.executable] + argv) | 463 return subprocess.call([sys.executable] + argv) |
| 455 else: | 464 else: |
| 456 return main(argv) | 465 return main(argv) |
| 457 | 466 |
| 458 | 467 |
| 459 if __name__ == '__main__': | 468 if __name__ == '__main__': |
| 460 sys.exit(shell_main(sys.argv)) | 469 sys.exit(shell_main(sys.argv)) |
| OLD | NEW |