Skip to content

Commit

Permalink
Merge branch 'mr/pmderodat/xunit-importer' into 'master'
Browse files Browse the repository at this point in the history
e3-convert-xunit: add support for --gaia-output

See merge request it/e3-testsuite!16
  • Loading branch information
pmderodat committed Jan 10, 2024
2 parents 61ee49c + cdfffae commit ebf7702
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/e3/testsuite/report/xunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import xml.etree.ElementTree as etree

from e3.fs import mkdir
from e3.testsuite.report.gaia import dump_gaia_report
from e3.testsuite.report.index import ReportIndex
from e3.testsuite.result import TestResult, TestStatus
import e3.yaml
Expand Down Expand Up @@ -305,6 +306,12 @@ def convert_main(argv: list[str] | None = None) -> None:
help="Output directory for the converted report. By default, use the"
" current working directory.",
)
parser.add_argument(
"--gaia-output",
action="store_true",
help="Output a GAIA-compatible testsuite report next to the YAML"
" report.",
)
parser.add_argument(
"--xfails",
help="YAML file that describes expected failures. If provided, it must"
Expand All @@ -330,3 +337,6 @@ def convert_main(argv: list[str] | None = None) -> None:
else:
importer.run(path)
index.write()

if args.gaia_output:
dump_gaia_report(index, index.results_dir)
21 changes: 21 additions & 0 deletions tests/tests/test_xunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,24 @@ def write_xml(filename, testsuite_name, *test_names):
index = ReportIndex.read(results_dir)

assert sorted(index.entries) == ["f1.t1", "f1.t2", "f2.t1", "f3.t1"]


def test_gaia(tmp_path):
"""Test GAIA-compatible report creation."""
xml_report = str(tmp_path / "test.xml")
with open(xml_report, "w") as f:
f.write(
"""<?xml version="1.0" encoding="utf-8"?>
<testsuites name="MyTestsuites">
<testsuite name="MyTestsuite">
<testcase name="MyTestcase"></testcase>
</testsuite>
</testsuites>
"""
)

results_dir = tmp_path / "results"
convert_main(["--gaia-output", "-o", str(results_dir), xml_report])

with open(str(results_dir / "results"), "r") as f:
assert f.read() == "MyTestsuite.MyTestcase:OK:\n"

0 comments on commit ebf7702

Please sign in to comment.