Allow build without test results

This commit is contained in:
southerntofu 2022-02-23 20:42:56 +01:00
parent b8524e51f0
commit 951100528a
1 changed files with 13 additions and 4 deletions

View File

@ -1,13 +1,17 @@
{% macro pipeline(directory, name) %}
<h2 id="{{ name }}">{{ name }}</h2>
{% set latest = [] %}
{% set data = [] %}
{% set_global latest = [] %}
{% set_global data = [] %}
{% for impl in config.extra.tests.pipelines[name].impl %}
{# Don't forget to trim() to remove confusing trailing newline #}
{% set_global latest = latest | concat(with=load_data(path="static/"~config.extra.tests.directory~"/"~impl.name~"/latest")|trim()) %}
{% set_global data = data | concat(with=load_data(path="static/"~config.extra.tests.directory~"/"~impl.name~"/results.toml")) %}
{# First check if data exists before concatenating #}
{% set loaded = load_data(path="static/"~config.extra.tests.directory~"/"~impl.name~"/latest", required=false) %}
{% if loaded %}{% set_global latest = latest | concat(with=loaded|trim()) %}{% endif %}
{% set loaded = load_data(path="static/"~config.extra.tests.directory~"/"~impl.name~"/results.toml", required=false) %}
{% if loaded %}{% set_global data = data | concat(with=loaded) %}{% endif %}
{% endfor %}
{% if data and latest %}
<table>
<tr>
<th>Test</th>
@ -55,4 +59,9 @@
</details>
{% endfor %}
{% endfor %}
{% else %}
{% set impls = config.extra.tests.pipelines[name].impl|map(attribute="name")|join(sep=",") %}{% set impls = "{" ~ impls ~ "}" %}
<h3>No test data to display from "static/{{ config.extra.tests.directory }}/{{ impls }}/{latest,results.toml}.</h3>
{% endif %}
{% endmacro pipeline %}