Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: recipe_engine/step_runner.py

Issue 2798053003: introduce recipe_exception in result.proto (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « recipe_engine/run.py ('k') | recipe_engine/unittests/run_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 import calendar 5 import calendar
6 import collections 6 import collections
7 import contextlib 7 import contextlib
8 import datetime 8 import datetime
9 import itertools 9 import itertools
10 import json 10 import json
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 return ReturnOpenStep() 453 return ReturnOpenStep()
454 454
455 def run_recipe(self, universe, recipe, properties): 455 def run_recipe(self, universe, recipe, properties):
456 return self._test_data.depend_on_data.pop(types.freeze((recipe, properties), )) 456 return self._test_data.depend_on_data.pop(types.freeze((recipe, properties), ))
457 457
458 @contextlib.contextmanager 458 @contextlib.contextmanager
459 def run_context(self): 459 def run_context(self):
460 try: 460 try:
461 yield 461 yield
462 except Exception as ex: 462 except Exception as ex:
463 assert type(ex).__name__ != 'RecipeException'
463 with self._test_data.should_raise_exception(ex) as should_raise: 464 with self._test_data.should_raise_exception(ex) as should_raise:
464 if should_raise: 465 if should_raise:
465 raise 466 raise
466 467
467 assert self._test_data.consumed, ( 468 assert self._test_data.consumed, (
468 "Unconsumed test data for steps: %s, (exception %s)" % ( 469 "Unconsumed test data for steps: %s, (exception %s)" % (
469 self._test_data.step_data.keys(), 470 self._test_data.step_data.keys(),
470 self._test_data.expected_exception)) 471 self._test_data.expected_exception))
471 472
472 def _rendered_step_to_dict(self, rs): 473 def _rendered_step_to_dict(self, rs):
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 supplied command, and only uses the |env| kwarg for modifying the environment 727 supplied command, and only uses the |env| kwarg for modifying the environment
727 of the child process. 728 of the child process.
728 """ 729 """
729 saved_path = os.environ['PATH'] 730 saved_path = os.environ['PATH']
730 try: 731 try:
731 if path is not None: 732 if path is not None:
732 os.environ['PATH'] = path 733 os.environ['PATH'] = path
733 yield 734 yield
734 finally: 735 finally:
735 os.environ['PATH'] = saved_path 736 os.environ['PATH'] = saved_path
OLDNEW
« no previous file with comments | « recipe_engine/run.py ('k') | recipe_engine/unittests/run_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698