Skip to content

Commit

Permalink
Merge pull request #1462 from bernt-matthias/topic/minimal-md
Browse files Browse the repository at this point in the history
Add option to create a minimal markdown test report
  • Loading branch information
mvdbeek authored Jul 4, 2024
2 parents f47965e + 0a7a87b commit 8f939e7
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion planemo/galaxy/test/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def handle_reports(ctx, structured_data, kwds):
except Exception as e:
exceptions.append(e)

for report_type in ["html", "markdown", "text", "xunit", "junit", "allure"]:
for report_type in ["html", "markdown", "markdown_minimal", "text", "xunit", "junit", "allure"]:
try:
_handle_test_output_file(ctx, report_type, structured_data, kwds)
except Exception as e:
Expand Down
7 changes: 7 additions & 0 deletions planemo/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,13 @@ def test_report_options():
help=("Output test report (Markdown style - for humans & " "computers)"),
default=None,
),
planemo_option(
"--test_output_markdown_minimal",
type=click.Path(file_okay=True, resolve_path=True),
use_global_config=True,
help=("Output test report (Minimal markdown style - jost the table)"),
default=None,
),
planemo_option(
"--test_output_xunit",
type=click.Path(file_okay=True, resolve_path=True),
Expand Down
46 changes: 46 additions & 0 deletions planemo/reports/report_markdown_minimal.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% from 'macros.tmpl' import render_invocation_details, render_invocation_messages, render_job_parameters, render_steps %}
{% if title %}
# {{ execution_type }} {{ title }}

{% endif %}
## {{ execution_type }} Summary
{% set state = namespace(found=false) %}
{% set state.success = raw_data.results.total - raw_data.results.errors - raw_data.results.failures - raw_data.results.skips | default(0) %}
{% set state.error = raw_data.results.errors | default(0) %}
{% set state.failure = raw_data.results.failures | default(0) %}
{% set state.skipped = raw_data.results.skipped | default(0) %}

{% if raw_data.results.total %}
<div class="progress">
<div class="progress-bar progress-bar-success" style="width: {{ (state.success / raw_data.results.total) * 100 }}%" aria-valuenow="{{ state.success }}" aria-valuemin="0" aria-valuemax="{{ raw_data.results.total }}" data-toggle="tooltip" title="{{state.success}} Passed">
</div>
<div class="progress-bar progress-bar-warning" style="width: {{ (state.skipped / raw_data.results.total) * 100 }}%" aria-valuenow="{{ state.skipped }}" aria-valuemin="0" aria-valuemax="{{ raw_data.results.total }}" data-toggle="tooltip" title="{{state.skipped}} Skipped">
</div>
<div class="progress-bar progress-bar-danger" style="width: {{ ((state.error + state.failure) / raw_data.results.total) * 100 }}%" aria-valuenow="{{ state.error + state.failure }}" aria-valuemin="0" aria-valuemax="{{ raw_data.results.total }}" title="{{state.error + state.failure}} Failed or Errored">
</div>
</div>
{% endif %}

| {{ execution_type }} State | Count |
| ---------- | ----- |
| Total | {{ raw_data.results.total | default(0) }} |
| Passed | {{ state.success }} |
| Error | {{ state.error }} |
| Failure | {{ state.failure }} |
| Skipped | {{ state.skipped }} |

{% for status, desc in {'error': 'Errored', 'failure': 'Failed', 'success': 'Passed'}.items() if state[status]%}
{% set expanded = "open" if status in ("error", "failure") else "" %}
<details {{ expanded }}><summary>{{ desc }} {{ execution_type }}s</summary>
{% for test in raw_data.tests %}
{% if test.data.status == status %}
{% if test.data.status == 'success' %}
* <summary class="light-green">&#9989; {{ test.id|replace("#","# ") }}</summary>
{% else %}
* <summary class="light-red">&#10060; {{ test.id|replace("#","# ") }}</summary>
{% endif %}
{% endif %}
{% endfor %}

</details>
{% endfor %}
16 changes: 16 additions & 0 deletions tests/test_cmd_test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,19 @@ def test_allure(self):
assert os.path.exists(results_path)
assert os.path.isdir(results_path)
assert len(os.listdir(results_path))

def test_markdown(self):
with self._isolate() as f:
json_path = os.path.join(TEST_DATA_DIR, "issue381.json")
results_path = os.path.join(f, "markdown_results")
self._check_exit_code(["test_reports", "--test_output_markdown", results_path, json_path], exit_code=0)
assert os.path.exists(results_path)

# Run minimal version
minimal_results_path = os.path.join(f, "minimal_markdown_results")
self._check_exit_code(
["test_reports", "--test_output_markdown_minimal", minimal_results_path, json_path], exit_code=0
)
assert os.path.exists(minimal_results_path)
# Make sure minimal markdown is compacted
assert os.path.getsize(minimal_results_path) < os.path.getsize(results_path)

0 comments on commit 8f939e7

Please sign in to comment.