File: global_report.py

package info (click to toggle)
blender 4.3.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 309,564 kB
  • sloc: cpp: 2,385,210; python: 330,236; ansic: 280,972; xml: 2,446; sh: 972; javascript: 317; makefile: 170
file content (82 lines) | stat: -rwxr-xr-x 2,520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# SPDX-FileCopyrightText: 2019-2022 Blender Authors
#
# SPDX-License-Identifier: Apache-2.0

# Generate a HTML page that links to all test reports.

import glob
import os
import pathlib


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>
    <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">
</head>
<body>
    <div class="container">
        <br/>
        <h1>{title}</h1>
        <nav aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item active" aria-current="page">Test Reports</li></ol></nav>
        {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"

    relpath = os.path.relpath(filepath, output_dir)

    html = """
        <span class="{status}">&#11044;</span>
        <a href="{relpath}">{name}</a><br/>
        """ . format(status=status,
                     name=name,
                     relpath=relpath)

    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)