summaryrefslogtreecommitdiff
path: root/piglit-summary-html.py
diff options
context:
space:
mode:
authorChad Versace <chad@chad-versace.us>2011-07-12 07:18:53 -0700
committerChad Versace <chad@chad-versace.us>2011-07-14 10:25:34 -0700
commitb2ae931c5891a35aa3ddd22159b24e0d532e3b3d (patch)
tree6868805a52fdce7770997ed2cd7bb2b58a25237a /piglit-summary-html.py
parent0a9773ea4d2a795fb0ff77fa92f41dd08af81be0 (diff)
framework: Replace custom serialization format with json
The results file produced by piglit-run.py contains a serialized TestrunResult, and the serialization format was horridly homebrew. This commit replaces that insanity with json. Benefits: - Net loss of 113 lines of code (ignoring comments and empty lines). - By using the json module in the Python standard library, serializing and unserializing is nearly as simple as `json.dump(object, file)` and `json.load(object, file)`. - By using a format that is easy to manipulate, it is now simple to extend Piglit to allow users to embed custom data into the results file. As a side effect, the summary file is no longer needed, so it is no longer produced. Reviewed-by: Paul Berry <stereotype441@gmail.com> Signed-off-by: Chad Versace <chad@chad-versace.us>
Diffstat (limited to 'piglit-summary-html.py')
-rwxr-xr-xpiglit-summary-html.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/piglit-summary-html.py b/piglit-summary-html.py
index 4e9423749..d00e11e28 100755
--- a/piglit-summary-html.py
+++ b/piglit-summary-html.py
@@ -88,8 +88,8 @@ def buildDetailValue(detail):
items = items + ResultListItem % { 'detail': buildDetailValue(d) }
return ResultList % { 'items': items }
- elif type(detail) == str and detail[0:3] == '@@@':
- return ResultMString % { 'detail': cgi.escape(detail[3:]) }
+ elif isinstance(detail, str) or isinstance(detail, unicode):
+ return ResultMString % { 'detail': cgi.escape(detail) }
return cgi.escape(str(detail))
@@ -97,7 +97,9 @@ def buildDetailValue(detail):
def buildDetails(testResult):
details = []
for name in testResult:
- if type(name) != str or name == 'result':
+ assert(isinstance(name, basestring))
+
+ if name == 'result':
continue
value = buildDetailValue(testResult[name])
@@ -133,7 +135,13 @@ def writeResultHtml(test, testResult, filename):
writefile(filename, Result % locals())
def writeTestrunHtml(testrun, filename):
- detaildict = dict(filter(lambda item: item[0] in testrun.globalkeys, testrun.__dict__.items()))
+ detail_keys = [
+ key
+ for key in testrun.__dict__.keys()
+ if key in testrun.serialized_keys
+ if key != 'tests'
+ ]
+ detaildict = dict([(k, testrun.__dict__[k]) for k in detail_keys])
details = buildDetails(detaildict)
name = testrun.name
codename = testrun.codename
@@ -281,7 +289,7 @@ def parse_listfile(filename):
return eval(code)
def loadresult(descr, OptionPreferSummary):
- result = core.loadTestResults(descr[0], OptionPreferSummary)
+ result = core.loadTestResults(descr[0])
if len(descr) > 1:
result.__dict__.update(descr[1])
return result