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

Unified Diff: recipe_engine/run.py

Issue 2322093002: Track step nesting in StreamEngine (Reland). (Closed)
Patch Set: Might as well go deeper. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipe_engine/simulation_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/run.py
diff --git a/recipe_engine/run.py b/recipe_engine/run.py
index abceb586b24d5abaaf1d7b90d199c08d35d8c741..7d97e6cad13b975f44753a86aa25dde7f0b54b75 100644
--- a/recipe_engine/run.py
+++ b/recipe_engine/run.py
@@ -297,8 +297,8 @@ class RecipeEngine(object):
* step - uses engine.create_step(...), and previous_step_result.
"""
- ActiveStep = collections.namedtuple('ActiveStep',
- 'step step_result open_step nest_level')
+ ActiveStep = collections.namedtuple('ActiveStep', (
+ 'step', 'step_result', 'open_step', 'nest_level'))
def __init__(self, step_runner, properties, universe_view):
"""See run_steps() for parameter meanings."""
@@ -344,9 +344,13 @@ class RecipeEngine(object):
" with try-finally blocks.")
return self._step_stack[-1].step_result
- def _close_to_level(self, level):
- """Close all open steps that are at least as deep as level."""
- while self._step_stack and level <= self._step_stack[-1].nest_level:
+ def _close_through_level(self, level):
+ """Close all open steps whose nest level is >= the supplied level.
+
+ Args:
+ level (int): the nest level to close through.
+ """
+ while self._step_stack and self._step_stack[-1].nest_level >= level:
cur = self._step_stack.pop()
if cur.step_result:
cur.step_result.presentation.finalize(cur.open_step.stream)
@@ -369,8 +373,8 @@ class RecipeEngine(object):
step_result = None
- nest_level = step.pop('step_nest_level', 0)
- self._close_to_level(nest_level)
+ nest_level = step.get('step_nest_level', 0)
+ self._close_through_level(nest_level)
open_step = self._step_runner.open_step(step)
self._step_stack.append(self.ActiveStep(
@@ -378,8 +382,6 @@ class RecipeEngine(object):
step_result=None,
open_step=open_step,
nest_level=nest_level))
- if nest_level:
- open_step.stream.set_nest_level(nest_level)
step_result = open_step.run()
self._step_stack[-1] = (
@@ -429,7 +431,7 @@ class RecipeEngine(object):
"status_code": 0
}
finally:
- self._close_to_level(0)
+ self._close_through_level(0)
except recipe_api.StepFailure as f:
result = {
# Include "recipe_result" so it doesn't get marked as infra failure.
« no previous file with comments | « no previous file | recipe_engine/simulation_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698