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

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: updated comment 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..ddac1f2ce4c6ba3498071ccf054fc0c36674af08 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,14 @@ CONTROL_ANNOTATIONS = {
}
STREAM_ANNOTATIONS = {
+ # CURRENT_TIMESTAMP has one parameter, current Unix timestamp, which in
+ # practice specifies timestamp of the following annotation.
+ # 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 not consider
+ # CURRENT_TIMESTAMP for annotations that follow the annotation which is next
+ # after the CURRENT_TIMESTAMP.
+ 'CURRENT_TIMESTAMP': 1,
'HALT_ON_FAILURE': 0,
'HONOR_ZERO_RETURN_CODE': 0,
'SEED_STEP': 1,
@@ -197,11 +206,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 +220,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 +233,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 +264,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())
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