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

Unified Diff: scripts/common/annotator.py

Issue 2050703003: Add CURRENT_TIMESTAMP annotation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 4 years, 6 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/common/unittests/annotator_test.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 8fcb5ebc02ba7e2aa3554c2c54cafb7ae9155f85..2a39275759b7351ca90d2f0c5dd9ce212f068d70 100755
--- a/scripts/common/annotator.py
+++ b/scripts/common/annotator.py
@@ -6,6 +6,7 @@
import os
import sys
+import time
import traceback
# These are maps of annotation key -> number of expected arguments.
@@ -32,6 +33,13 @@ CONTROL_ANNOTATIONS = {
}
STREAM_ANNOTATIONS = {
+ # CURRENT_TIMESTAMP has one parameter, Unix timestamp, which specifies
+ # current time. The following annotation MUST be emitted immediately,
+ # however there is no requirement for the annotation after the next one
+ # to be emitted immediately. Annotation parsers must treat CURRENT_TIMESTAMP
+ # annotation as a decorator for the next annotation only, not for all
+ # following annotations until next CURRENT_TIMESTAMP.
+ 'CURRENT_TIMESTAMP': 1,
'HALT_ON_FAILURE': 0,
'HONOR_ZERO_RETURN_CODE': 0,
'SEED_STEP': 1,
@@ -197,11 +205,11 @@ class StructuredAnnotationStep(StepCommands, StepControlCommands):
self.control = StepControlCommands(self.stream, self.flush_before)
self.emitted_logs = set()
-
def __enter__(self):
return self.step_started()
def step_started(self):
+ self.annotation_stream.emit_current_timestamp()
self.control.step_started()
return self
@@ -211,6 +219,7 @@ class StructuredAnnotationStep(StepCommands, StepControlCommands):
if exc_type:
self.step_exception_occured(exc_type, exc_value, tb)
+ self.annotation_stream.emit_current_timestamp()
self.control.step_closed()
self.annotation_stream.current_step = ''
return not exc_type
@@ -223,6 +232,7 @@ class StructuredAnnotationStep(StepCommands, StepControlCommands):
def step_ended(self):
self.annotation_stream.step_cursor(self.annotation_stream.current_step)
+ self.annotation_stream.emit_current_timestamp()
self.control.step_closed()
self.annotation_stream.current_step = ''
@@ -253,10 +263,15 @@ class StructuredAnnotationStream(AnnotationPrinter):
def __init__(self, stream=sys.stdout,
flush_before=sys.stderr,
- seed_steps=None): # pylint: disable=W0613
+ seed_steps=None, # pylint: disable=W0613
+ time_fn=None):
super(StructuredAnnotationStream, self).__init__(stream=stream,
flush_before=flush_before)
self.current_step = ''
+ self.time_fn = time_fn or time.time
+
+ def emit_current_timestamp(self):
+ self.current_timestamp(self.time_fn())
nodir 2016/06/08 17:42:23 current_timestamp method is generated dynamically
def step(self, name):
"""Provide a context with which to execute a step."""
« no previous file with comments | « no previous file | scripts/common/unittests/annotator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698