Commit d9f87269 authored by Dylan Baker's avatar Dylan Baker

framework: small refactor of test_result page generation

Previously each value of a dictionary was pulled out and passed one by
one to mako, that results in a lot of values being passed. With this
patch the dictionary is passed and the keys are pulled out in the mako.
This is much cleaner and easier to read.

v2: - fix dmesg is list problem by altering the dictionary
Signed-off-by: Dylan Baker's avatarDylan Baker <baker.dylan.c@gmail.com>
Reviewed-by: Ilia Mirkin's avatarIlia Mirkin <imirkin@alum.mit.edu>
parent f8983c59
...@@ -400,28 +400,14 @@ class Summary: ...@@ -400,28 +400,14 @@ class Summary:
if not path.exists(temp_path): if not path.exists(temp_path):
os.makedirs(temp_path) os.makedirs(temp_path)
dmesg = value.get('dmesg', 'None') if isinstance(value.get('dmesg'), list):
if isinstance(dmesg, list): value['dmesg'] = "\n".join(value['dmesg'])
dmesg = "\n".join(dmesg)
with open(path.join(destination, each.name, key + ".html"), with open(path.join(destination, each.name, key + ".html"),
'w') as out: 'w') as out:
out.write(testfile.render( out.write(testfile.render(
testname=key, testname=key,
status=value.get('result', 'None'), value=value,
# Returning a NoneType (instaed of 'None') prevents
# this field from being generated.setting the
# environment to run tests is ugly, and should
# disapear at somepoint
env=value.get('environment', None),
returncode=value.get('returncode', 'None'),
time=value.get('time', 'None'),
info=value.get('info', None), # deprecated
out=value.get('out', 'None'),
err=value.get('err', 'None'),
traceback=value.get('traceback', 'None'),
command=value.get('command', 'None'),
dmesg=dmesg,
css=path.relpath(result_css, temp_path), css=path.relpath(result_css, temp_path),
index=path.relpath(index, temp_path))) index=path.relpath(index, temp_path)))
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<h1>Results for ${testname}</h1> <h1>Results for ${testname}</h1>
<h2>Overview</h2> <h2>Overview</h2>
<div> <div>
<p><b>Result:</b> ${status}</p> <p><b>Result:</b> ${value.get('status', 'None')}</p>
</div> </div>
<p><a href="${index}">Back to summary</a></p> <p><a href="${index}">Back to summary</a></p>
<h2>Details</h2> <h2>Details</h2>
...@@ -22,57 +22,59 @@ ...@@ -22,57 +22,59 @@
</tr> </tr>
<tr> <tr>
<td>Returncode</td> <td>Returncode</td>
<td>${returncode}</td> <td>${value.get('returncode', 'None')}</td>
</tr> </tr>
<tr> <tr>
<td>Time</td> <td>Time</td>
<td>${time}</b> <td>${value.get('time', 'None')}</b>
</tr> </tr>
## Info is deprecated and may disapear someday ## Info is deprecated and may disapear someday
% if info is not None: % if value.get('info') is not None:
<tr> <tr>
<td>Info</td> <td>Info</td>
<td> <td>
<pre>${info | h}</pre> <pre>${value.get('info') | h}</pre>
</td> </td>
</tr> </tr>
% endif % endif
<tr> <tr>
<td>Stdout</td> <td>Stdout</td>
<td> <td>
<pre>${out | h}</pre> <pre>${value.get('out', 'None') | h}</pre>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Stderr</td> <td>Stderr</td>
<td> <td>
<pre>${err | h}</pre> <pre>${value.get('err', 'None') | h}</pre>
</td> </td>
</tr> </tr>
% if env: % if value.get('env') is not None:
<tr> <tr>
<td>Environment</td> <td>Environment</td>
<td> <td>
<pre>${env | h}</pre> <pre>${value.get('env') | h}</pre>
</td> </td>
</tr> </tr>
% endif % endif
<tr> <tr>
<td>Command</td> <td>Command</td>
<td> <td>
</pre>${command}</pre> </pre>${value.get('command', 'None')}</pre>
</td> </td>
</tr> </tr>
% if value.get('traceback') is not None:
<tr> <tr>
<td>Traceback</td> <td>Traceback</td>
<td> <td>
<pre>${traceback | h}</pre> <pre>${value.get('traceback') | h}</pre>
</td> </td>
</tr> </tr>
% endif
<tr> <tr>
<td>dmesg</td> <td>dmesg</td>
<td> <td>
<pre>${dmesg | h}</pre> <pre>${value.get('dmesg', 'None') | h}</pre>
</td> </td>
</tr> </tr>
</table> </table>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment