mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-11 16:00:57 +00:00
tests/ui: use the generated reports to create index.html
instead of the pytest reports, because it was quite painful
This commit is contained in:
parent
87d032a8dd
commit
a1a56813fe
@ -26,7 +26,7 @@ from trezorlib.transport import enumerate_devices, get_transport
|
||||
|
||||
from . import ui_tests
|
||||
from .device_handler import BackgroundDeviceHandler
|
||||
from .ui_tests import get_test_name, report
|
||||
from .ui_tests import report
|
||||
|
||||
|
||||
def get_device():
|
||||
@ -152,21 +152,8 @@ def pytest_sessionstart(session):
|
||||
|
||||
|
||||
def pytest_sessionfinish(session, exitstatus):
|
||||
if session.config.getoption("ui") != "test":
|
||||
return
|
||||
|
||||
reporter = session.config.pluginmanager.get_plugin("terminalreporter")
|
||||
# intentionally set(), because there are multiple stages for one test in the TestReport items
|
||||
test_names = {"passed": set(), "failed": set()}
|
||||
for status, test in reporter.stats.items():
|
||||
if status in ("deselected", "warnings"):
|
||||
continue
|
||||
if status in ("passed", "failed"):
|
||||
# iterate through the stages to get the test name
|
||||
for t in test:
|
||||
test_names[status].add(get_test_name(t.nodeid))
|
||||
|
||||
report.index(sorted(list(test_names["passed"])), sorted(list(test_names["failed"])))
|
||||
if session.config.getoption("ui") == "test":
|
||||
report.index()
|
||||
|
||||
|
||||
def pytest_terminal_summary(terminalreporter, exitstatus, config):
|
||||
|
@ -52,18 +52,18 @@ def _write(fixture_test_path, doc, filename):
|
||||
return fixture_test_path / filename
|
||||
|
||||
|
||||
def _report_links(tests, status):
|
||||
if status not in ("failed", "passed"):
|
||||
raise ValueError("Different status than failed/passed is not yet supported.")
|
||||
def _report_links(tests):
|
||||
tests = list(tests)
|
||||
if not tests:
|
||||
i("None!")
|
||||
return
|
||||
with table(border=1):
|
||||
with tr():
|
||||
th("Link to report")
|
||||
for test in tests:
|
||||
for test in sorted(tests):
|
||||
with tr():
|
||||
td(a(test, href="%s/%s.html" % (status, test)))
|
||||
path = test.relative_to(REPORTS_PATH)
|
||||
td(a(test.name, href=path))
|
||||
|
||||
|
||||
def clear_dir():
|
||||
@ -74,7 +74,10 @@ def clear_dir():
|
||||
(REPORTS_PATH / "passed").mkdir()
|
||||
|
||||
|
||||
def index(passed_tests, failed_tests):
|
||||
def index():
|
||||
passed_tests = (REPORTS_PATH / "passed").iterdir()
|
||||
failed_tests = (REPORTS_PATH / "failed").iterdir()
|
||||
|
||||
title = "UI Test report " + datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
doc = dominate.document(title=title)
|
||||
|
||||
@ -87,10 +90,10 @@ def index(passed_tests, failed_tests):
|
||||
hr()
|
||||
|
||||
h2("Failed", style="color: red;")
|
||||
_report_links(failed_tests, "failed")
|
||||
_report_links(failed_tests)
|
||||
|
||||
h2("Passed", style="color: green;")
|
||||
_report_links(passed_tests, "passed")
|
||||
_report_links(passed_tests)
|
||||
|
||||
return _write(REPORTS_PATH, doc, "index.html")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user