-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for subresults flavor in junit report plugin
Define an experimental junit flavor for subresults.
- Loading branch information
Showing
5 changed files
with
207 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<!-- | ||
This schema extends the `default` flavor and adds support for tmt | ||
subresults. It allows multiple occurrences of testsuite elements inside a | ||
<testsuites>. | ||
The <testsuite> is mapped to `tmt.Result` and the <testcase> is mapped to | ||
`tmt.SubResult`. | ||
--> | ||
|
||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
|
||
<xs:element name="failure"> | ||
<xs:complexType mixed="true"> | ||
<xs:attribute name="type" type="xs:string" use="required"/> | ||
<xs:attribute name="message" type="xs:string" use="required"/> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="error"> | ||
<xs:complexType mixed="true"> | ||
<xs:attribute name="type" type="xs:string" use="required"/> | ||
<xs:attribute name="message" type="xs:string" use="required"/> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="skipped"> | ||
<xs:complexType mixed="true"> | ||
<xs:attribute name="type" type="xs:string" use="required"/> | ||
<xs:attribute name="message" type="xs:string" use="required"/> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:element name="system-err" type="xs:string"/> | ||
<xs:element name="system-out" type="xs:string"/> | ||
|
||
<xs:element name="properties"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element ref="property" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="property"> | ||
<xs:complexType> | ||
<xs:attribute name="name" type="xs:string" use="required"/> | ||
<xs:attribute name="value" type="xs:string" use="required"/> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="testcase"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element ref="skipped" minOccurs="0" maxOccurs="1"/> | ||
<xs:element ref="error" minOccurs="0" maxOccurs="1"/> | ||
<xs:element ref="failure" minOccurs="0" maxOccurs="1"/> | ||
<xs:element ref="system-out" minOccurs="0" maxOccurs="1"/> | ||
<xs:element ref="system-err" minOccurs="0" maxOccurs="1"/> | ||
<xs:element ref="properties" minOccurs="0" maxOccurs="1"/> | ||
</xs:sequence> | ||
<xs:attribute name="name" type="xs:string" use="required"/> | ||
<xs:attribute name="time" type="xs:float" use="optional"/> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="testsuite"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element ref="testcase" minOccurs="0" maxOccurs="unbounded"/> | ||
|
||
<!-- TODO: These should not be probably allowed | ||
<xs:element ref="system-out" minOccurs="0" maxOccurs="1"/> | ||
<xs:element ref="system-err" minOccurs="0" maxOccurs="1"/> | ||
--> | ||
</xs:sequence> | ||
<xs:attribute name="name" type="xs:string" use="required"/> | ||
<xs:attribute name="tests" type="xs:string" use="required"/> | ||
<xs:attribute name="failures" type="xs:string" use="required"/> | ||
<xs:attribute name="errors" type="xs:string" use="required"/> | ||
<xs:attribute name="disabled" type="xs:string" use="required"/> | ||
<xs:attribute name="skipped" type="xs:string" use="required"/> | ||
<xs:attribute name="time" type="xs:float" use="required"/> | ||
<xs:attribute name="timestamp" type="xs:string" use="required"/> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="testsuites"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element ref="testsuite" minOccurs="0" maxOccurs="unbounded"/> | ||
<xs:element ref="properties" minOccurs="0" maxOccurs="1"/> | ||
</xs:sequence> | ||
<xs:attribute name="time" type="xs:float" use="required"/> | ||
<xs:attribute name="tests" type="xs:string" use="optional"/> | ||
<xs:attribute name="failures" type="xs:string" use="optional"/> | ||
<xs:attribute name="disabled" type="xs:string" use="optional"/> | ||
<xs:attribute name="errors" type="xs:string" use="optional"/> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{% extends "_base.xml.j2" %} | ||
|
||
{# | ||
This flavor changes the level of `<testsuite>` and `<testcase>` tags. The | ||
`tmt.Result` becomes ``<testsuite>`` instead of ``testcase`` and | ||
``<testcase>`` tags become ``tmt.SubResult``. | ||
#} | ||
|
||
{% block content %} | ||
<testsuites disabled="0" errors="{{ RESULTS.errored | length }}" failures="{{ RESULTS.failed | length }}" tests="{{ RESULTS | length }}" time="{{ RESULTS.duration }}"> | ||
|
||
{% block testsuites %} | ||
{% for result in RESULTS %} | ||
{% set main_log = result.log | first | read_log %} | ||
{% set main_log_failures = main_log | failures | e %} | ||
{% set main_test_duration = result.duration | duration_to_seconds %} | ||
|
||
{# TODO: Fix the test counts in testsuite tag #} | ||
{# TODO: Also fix the counts because now with an additional testcase for parent results, the counts will not match. #} | ||
|
||
<testsuite name="{{ result.name | trim | e }}" disabled="0" errors="{{ result.subresult.errored | length }}" failures="{{ result.subresult.failed | length }}" skipped="{{ result.subresult.skipped | length }}" tests="{{ result.subresult | length }}" time="{{ main_test_duration }}" timestamp="{{ result.start_time }}"> | ||
|
||
{# | ||
Always include a `testcase` representing the main result. | ||
The `error/failure/skipped` tags must not exists inside a | ||
`testsuite`, they are only allowed inside of a `testcase`. | ||
#} | ||
<testcase name="{{ result.name | e }}" {% if result_test_duration %}time="{{ result_test_duration }}"{% endif %}> | ||
{% if result.result.value == 'error' or result.result.value == 'warn' %} | ||
<error type="error" message="{{ result.result.value | e }}">{{ main_log_failures }}</error> | ||
{% elif result.result.value == 'fail' %} | ||
<failure type="failure" message="{{ result.result.value | e }}">{{ main_log_failures }}</failure> | ||
{% elif result.result.value == 'info' %} | ||
<skipped type="skipped" message="{{ result.result.value | e }}">{{ main_log_failures }}</skipped> | ||
{% endif %} | ||
|
||
{% if INCLUDE_OUTPUT_LOG and main_log %} | ||
<system-out>{{ main_log | e }}</system-out> | ||
{% endif %} | ||
</testcase> | ||
|
||
{% for subresult in result.subresult %} | ||
{% set subresult_log = subresult.log | first | read_log %} | ||
{% set subresult_log_failures = main_log | failures | e %} | ||
{% set subresult_test_duration = subresult.duration | duration_to_seconds %} | ||
|
||
<testcase name="{{ subresult.name | e }}" {% if subresult_test_duration %}time="{{ subresult_test_duration }}"{% endif %}> | ||
{% if subresult.result.value == 'error' or subresult.result.value == 'warn' %} | ||
<error type="error" message="{{ subresult.result.value | e }}">{{ subresult_log_failures }}</error> | ||
{% elif subresult.result.value == 'fail' %} | ||
<failure type="failure" message="{{ subresult.result.value | e }}">{{ subresult_log_failures }}</failure> | ||
{% elif subresult.result.value == 'info' %} | ||
<skipped type="skipped" message="{{ subresult.result.value | e }}">{{ subresult_log_failures }}</skipped> | ||
{% endif %} | ||
|
||
{% if INCLUDE_OUTPUT_LOG and subresult_log %} | ||
<system-out>{{ subresult_log | e }}</system-out> | ||
{% endif %} | ||
</testcase> | ||
{% endfor %} | ||
|
||
{# Optionally add the result properties #} | ||
{% if result.properties is defined %} | ||
{% with properties=result.properties %} | ||
{% include "includes/_properties.xml.j2" %} | ||
{% endwith %} | ||
{% endif %} | ||
</testsuite> | ||
{% endfor %} | ||
{% endblock %} | ||
|
||
{# Optionally include the properties section in testsuites tag #} | ||
{% if RESULTS.properties is defined %} | ||
{% with properties=RESULTS.properties %} | ||
{% include "includes/_properties.xml.j2" %} | ||
{% endwith %} | ||
{% endif %} | ||
|
||
</testsuites> | ||
{% endblock %} |