From cdfffae46e115b85e7b941f2d0f0348757d7bd25 Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Mon, 8 Jan 2024 15:24:26 +0100 Subject: [PATCH] e3-convert-xunit: add support for --gaia-output This option will allow production scripts to create a GAIA-compatible report right after the completion of testsuites that produce xUnit reports. --- src/e3/testsuite/report/xunit.py | 10 ++++++++++ tests/tests/test_xunit.py | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/e3/testsuite/report/xunit.py b/src/e3/testsuite/report/xunit.py index b55e8a6..e0e1507 100644 --- a/src/e3/testsuite/report/xunit.py +++ b/src/e3/testsuite/report/xunit.py @@ -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 @@ -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" @@ -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) diff --git a/tests/tests/test_xunit.py b/tests/tests/test_xunit.py index dc581c0..681ad19 100644 --- a/tests/tests/test_xunit.py +++ b/tests/tests/test_xunit.py @@ -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( + """ + + + + + + """ + ) + + 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"