2023-08-15 16:20:26 +02:00
|
|
|
# SPDX-FileCopyrightText: 2019-2022 Blender Authors
|
2023-06-15 05:09:04 +02:00
|
|
|
#
|
2022-02-10 23:07:11 +01:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2022-02-09 13:25:53 +01:00
|
|
|
|
2019-05-09 13:45:46 +02:00
|
|
|
# Generate a HTML page that links to all test reports.
|
|
|
|
|
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
import pathlib
|
|
|
|
|
2020-10-02 02:10:01 +02:00
|
|
|
|
2019-05-09 13:45:46 +02:00
|
|
|
def _write_html(output_dir):
|
|
|
|
combined_reports = ""
|
|
|
|
|
|
|
|
# Gather intermediate data for all tests and combine into one HTML file.
|
|
|
|
categories = sorted(glob.glob(os.path.join(output_dir, "report", "*")))
|
|
|
|
|
|
|
|
for category in categories:
|
|
|
|
category_name = os.path.basename(category)
|
|
|
|
combined_reports += "<h3>" + category_name + "</h3>\n"
|
|
|
|
|
|
|
|
reports = sorted(glob.glob(os.path.join(category, "*.data")))
|
|
|
|
for filename in reports:
|
|
|
|
filepath = os.path.join(output_dir, filename)
|
|
|
|
combined_reports += pathlib.Path(filepath).read_text()
|
|
|
|
|
|
|
|
combined_reports += "<br/>\n"
|
|
|
|
|
|
|
|
html = """
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>{title}</title>
|
|
|
|
<style>
|
|
|
|
.ok {{ color: green; }}
|
|
|
|
.failed {{ color: red; }}
|
|
|
|
.none {{ color: #999; }}
|
|
|
|
</style>
|
2019-06-25 19:48:14 +02:00
|
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
2019-05-09 13:45:46 +02:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="container">
|
|
|
|
<br/>
|
2019-06-25 19:48:14 +02:00
|
|
|
<h1>{title}</h1>
|
2020-10-28 16:19:03 +01:00
|
|
|
<nav aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item active" aria-current="page">Test Reports</li></ol></nav>
|
2019-05-09 13:45:46 +02:00
|
|
|
{combined_reports}
|
|
|
|
<br/>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
""" . format(title="Blender Test Reports",
|
|
|
|
combined_reports=combined_reports)
|
|
|
|
|
|
|
|
filepath = os.path.join(output_dir, "report.html")
|
|
|
|
pathlib.Path(filepath).write_text(html)
|
|
|
|
|
|
|
|
|
|
|
|
def add(output_dir, category, name, filepath, failed=None):
|
|
|
|
# Write HTML for single test.
|
|
|
|
if failed is None:
|
|
|
|
status = "none"
|
|
|
|
elif failed:
|
|
|
|
status = "failed"
|
|
|
|
else:
|
|
|
|
status = "ok"
|
|
|
|
|
|
|
|
html = """
|
|
|
|
<span class="{status}">⬤</span>
|
|
|
|
<a href="file://{filepath}">{name}</a><br/>
|
|
|
|
""" . format(status=status,
|
|
|
|
name=name,
|
|
|
|
filepath=filepath)
|
|
|
|
|
|
|
|
dirpath = os.path.join(output_dir, "report", category)
|
|
|
|
os.makedirs(dirpath, exist_ok=True)
|
|
|
|
filepath = os.path.join(dirpath, name + ".data")
|
|
|
|
pathlib.Path(filepath).write_text(html)
|
|
|
|
|
|
|
|
# Combined into HTML, each time so we can see intermediate results
|
|
|
|
# while tests are still running.
|
|
|
|
_write_html(output_dir)
|