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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 if recipe_module: | 375 if recipe_module: |
376 break | 376 break |
377 else: | 377 else: |
378 s.step_text('recipe not found') | 378 s.step_text('recipe not found') |
379 s.step_failure() | 379 s.step_failure() |
380 return MakeStepsRetval(2, None) | 380 return MakeStepsRetval(2, None) |
381 | 381 |
382 properties = factory_properties.copy() | 382 properties = factory_properties.copy() |
383 properties.update(build_properties) | 383 properties.update(build_properties) |
384 stream.emit('Running recipe with %s' % (properties,)) | 384 stream.emit('Running recipe with %s' % (properties,)) |
385 steps = recipe_module.GenSteps(api(recipe_module.DEPS, | 385 steps = recipe_module.GenSteps(api(MODULE_DIRS, |
386 mod_dirs=MODULE_DIRS, | 386 recipe_module.DEPS, |
387 properties=properties, | 387 properties=properties, |
388 step_history=step_history)) | 388 step_history=step_history)) |
389 assert inspect.isgenerator(steps) | 389 assert inspect.isgenerator(steps) |
390 | 390 |
391 # Execute annotator.py with steps if specified. | 391 # Execute annotator.py with steps if specified. |
392 # annotator.py handles the seeding, execution, and annotation of each step. | 392 # annotator.py handles the seeding, execution, and annotation of each step. |
393 failed = False | 393 failed = False |
394 | 394 |
395 test_mode = test_data is not None | 395 test_mode = test_data is not None |
396 | 396 |
397 for step in ensure_sequence_of_steps(steps): | 397 for step in ensure_sequence_of_steps(steps): |
398 if failed and not step.get('always_run', False): | 398 if failed and not step.get('always_run', False): |
399 step_result = StepData(step, None) | 399 step_result = StepData(step, None) |
400 step_history[step['name']] = step_result | 400 step_history[step['name']] = step_result |
401 continue | 401 continue |
402 | 402 |
403 test_data_item = test_data.pop(step['name'], {}) if test_mode else None | 403 test_data_item = None |
| 404 mock_fn = step.pop('mock_fn', None) |
| 405 if test_mode: |
| 406 test_data_item = mock_fn() if mock_fn else {} |
| 407 test_data_item.update(test_data.pop(step['name'], {})) |
| 408 |
404 placeholders = render_step(step, test_data_item) | 409 placeholders = render_step(step, test_data_item) |
405 | 410 |
406 assert step['name'] not in step_history, ( | 411 assert step['name'] not in step_history, ( |
407 'Step "%s" is already in step_history!' % step['name']) | 412 'Step "%s" is already in step_history!' % step['name']) |
408 | 413 |
409 callback = step_callback(step, step_history, placeholders, test_data_item) | 414 callback = step_callback(step, step_history, placeholders, test_data_item) |
410 | 415 |
411 if not test_mode: | 416 if not test_mode: |
412 step_result = annotator.run_step( | 417 step_result = annotator.run_step( |
413 stream, followup_fn=callback, **step) | 418 stream, followup_fn=callback, **step) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 456 |
452 def shell_main(argv): | 457 def shell_main(argv): |
453 if UpdateScripts(): | 458 if UpdateScripts(): |
454 return subprocess.call([sys.executable] + argv) | 459 return subprocess.call([sys.executable] + argv) |
455 else: | 460 else: |
456 return main(argv) | 461 return main(argv) |
457 | 462 |
458 | 463 |
459 if __name__ == '__main__': | 464 if __name__ == '__main__': |
460 sys.exit(shell_main(sys.argv)) | 465 sys.exit(shell_main(sys.argv)) |
OLD | NEW |