[LNT] r212740 - Support update for Reports
Chris Matthews
cmatthews5 at apple.com
Thu Jul 10 09:59:57 PDT 2014
Author: cmatthews
Date: Thu Jul 10 11:59:57 2014
New Revision: 212740
URL: http://llvm.org/viewvc/llvm-project?rev=212740&view=rev
Log:
Support update for Reports
Both multisample and LNT report need ways to update reports. This patch
adds some simple functionality to update a report with new samples,
while keeping the metadata correctly in sync.
Modified:
lnt/trunk/lnt/testing/__init__.py
Modified: lnt/trunk/lnt/testing/__init__.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/__init__.py?rev=212740&r1=212739&r2=212740&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/__init__.py (original)
+++ lnt/trunk/lnt/testing/__init__.py Thu Jul 10 11:59:57 2014
@@ -45,6 +45,15 @@ class Report:
for t in self.tests:
assert isinstance(t, TestSamples)
+ def update_report(self, new_samples):
+ """Add extra samples to this report, and update
+ the end time.
+ """
+ self.check()
+ self.tests.extend(new_samples)
+ self.run.update_endtime()
+ self.check()
+
def render(self, indent=4):
# Note that we specifically override the encoding to avoid the
# possibility of encoding errors. Clients which care about the text
@@ -100,6 +109,11 @@ class Run:
raise ValueError("'__report_version__' key is reserved")
self.info['__report_version__'] = str(current_version)
+ def update_endtime(self, end_time=None):
+ if end_time is None:
+ end_time = datetime.datetime.utcnow()
+ self.end_time = normalize_time(end_time)
+
def render(self):
return { 'Start Time' : self.start_time,
'End Time' : self.end_time,
@@ -144,6 +158,12 @@ class TestSamples:
'Info' : self.info,
'Data' : self.data }
+
+ def __repr__(self):
+ # TODO remove this
+ return "TestSample({}): {} - {}".format(self.name,
+ self.data,
+ self.info)
###
# Report Versioning
More information about the llvm-commits
mailing list