Skip to content
Snippets Groups Projects
Commit 7cf45278 authored by Steffen Hauf's avatar Steffen Hauf
Browse files

Adjust listing format of test reports

parent 0862fccd
No related branches found
No related tags found
1 merge request!35Feat/reproducibility
......@@ -440,6 +440,7 @@ with open("available_notebooks.rst", "w") as f:
# add test results
test_artifact_dir = os.path.realpath("../../tests/artifacts")
from datetime import datetime
from dateutil.parser import parse
from lxml import etree
import tabulate
......@@ -448,8 +449,7 @@ import textwrap
def xml_to_rst_report(xml, git_tag):
e = etree.fromstring(xml.encode())
rst = [".. include:: roles.rst"]
rst += [""]
rst = [""]
rst += ["Test execution for {test_name} on {ex_date}"]
test_name, ex_date = e.get("name").split("-")
ex_date = parse(ex_date)
......@@ -522,18 +522,26 @@ def xml_to_rst_report(xml, git_tag):
rst += textwrap.indent(report, " "*4).split("\n")
rst += [""]
# console output
rst += ["Console Output"]
rst += ["-"*len(rst[-1])]
rst += [""]
do_console = False
for child in e:
if child.tag != "system-out":
continue
rst += [".. code-block:: console"]
rst += textwrap.indent(child.text, " "*4).split("\n")
if child.tag == "system-out" and len(child.text.strip()):
do_console = True
break
if do_console:
# console output
rst += ["Console Output"]
rst += ["-"*len(rst[-1])]
rst += [""]
for child in e:
if child.tag != "system-out":
continue
rst += [".. code-block:: console"]
rst += textwrap.indent(child.text, " "*4).split("\n")
return "\n".join(rst)
......@@ -542,7 +550,8 @@ def sorted_dir(folder):
path = os.path.join(folder, name)
return os.path.getmtime(path)
return sorted(os.listdir(folder), key=getmtime, reverse=True)
sort = sorted(os.listdir(folder), key=getmtime, reverse=True)
return [(s, datetime.fromtimestamp(getmtime(s))) for s in sort]
header = """
Test Results
......@@ -562,10 +571,12 @@ if not os.path.exists("./test_rsts"):
with open("test_results.rst", "w") as f:
f.write(header)
for commit in sorted_dir(test_artifact_dir):
for commit, modtime in sorted_dir(test_artifact_dir):
with open("./test_rsts/{}.rst".format(commit), "w") as fr:
rst = [commit]
rst += ["+"*len(commit)]
rst = [".. include:: roles.rst"]
rst += [""]
rst += ["{} - {}".format(commit[:8], modtime)]
rst += ["+"*len(rst[-1])]
rst += [""]
fr.write("\n".join(rst))
......
Test Results
************
Results are organized by git commit, and sorted descending by date.
Contents:
.. toctree::
:maxdepth: 2
test_rsts/4962d288a1d6e6b6054fc5440c39ac77e5df5a14
test_rsts/91ae7b03d948c11c75b80e5ffdc71e326c7591be
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment