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

Unified Diff: scripts/common/annotator.py

Issue 15270004: Add step generator protocol, remove annotated_checkout, remove script. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Address comments and change expected json output format Created 7 years, 7 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 | scripts/slave/annotated_checkout.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/common/annotator.py
diff --git a/scripts/common/annotator.py b/scripts/common/annotator.py
index e0fc657c3d470443c23bf929c192cbd43539b7b0..bca5f3f1700cd66b18d203d72b7e6692fddedab4 100755
--- a/scripts/common/annotator.py
+++ b/scripts/common/annotator.py
@@ -361,7 +361,7 @@ def _run_step(stream, build_failure,
Returns new value for build_failure.
"""
if skip or (build_failure and not always_run):
- return build_failure
+ return build_failure, None
# For error reporting.
step_dict = locals().copy()
@@ -375,6 +375,7 @@ def _run_step(stream, build_failure,
return line.replace('@@@', '###')
filter_obj = AnnotationFilter()
+ ret = None
try:
with stream.step(name) as s:
ret = chromium_utils.RunCommand(command=map(str, cmd),
@@ -390,7 +391,27 @@ def _run_step(stream, build_failure,
# File wasn't found, error has been already reported to stream.
build_failure = True
- return build_failure
+ return build_failure, ret
+
+
+def run_steps(steps, build_failure):
+ for step in steps:
+ error = _validate_step(step)
+ if error:
+ print 'Invalid step - %s\n%s' % (error, json.dumps(step, indent=2))
+ sys.exit(1)
+
+ seed_steps = []
+ for step in steps:
+ seed_steps.append(step['name'])
+ seed_steps.extend(step.get('seed_steps', []))
+
+ stream = StructuredAnnotationStream(seed_steps=seed_steps)
+ ret_codes = []
+ for step in steps:
+ build_failure, ret = _run_step(stream, build_failure, **step)
+ ret_codes.append(ret)
+ return build_failure, ret_codes
def main():
@@ -410,17 +431,7 @@ def main():
with open(args[0], 'rb') as f:
steps.extend(json.load(f))
- for step in steps:
- error = _validate_step(step)
- if error:
- print 'Invalid step - %s\n%s' % (error, json.dumps(step, indent=2))
- return 1
-
- stream = StructuredAnnotationStream(seed_steps=[s['name'] for s in steps])
- build_failure = False
- for step in steps:
- build_failure = _run_step(stream, build_failure, **step)
- return 1 if build_failure else 0
+ return 1 if run_steps(steps, False)[0] else 0
if __name__ == '__main__':
« no previous file with comments | « no previous file | scripts/slave/annotated_checkout.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698