From 838e008a386d8bb2ea37eb29c0508ba20f01a973 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 13 Oct 2024 16:50:48 +0200 Subject: [PATCH 1/4] Reenable test results merging. This reverts commit d5cbbf7ee28106336db4657bcb51efcb6282c04b. --- .github/workflows/Pipeline.yml | 76 +++++++++++++++++----------------- doc/requirements.txt | 2 +- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index f0a6a459..b47c293b 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -165,13 +165,13 @@ jobs: secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} -# PublishTestResults: -# uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@dev -# needs: -# - UnitTestingParams -# - UnitTesting -# with: -# merged_junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} + PublishTestResults: + uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@dev + needs: + - UnitTestingParams + - UnitTesting + with: + merged_junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} # VerifyDocs: # uses: pyTooling/Actions/.github/workflows/VerifyDocs.yml@r1 @@ -180,27 +180,27 @@ jobs: # with: # python_version: ${{ needs.UnitTestingParams.outputs.python_version }} -# HTMLDocumentation: -# uses: pyTooling/Actions/.github/workflows/SphinxDocumentation.yml@r1 -# needs: -# - UnitTestingParams -## - PublishTestResults -# - PublishCoverageResults -## - VerifyDocs -# with: -# python_version: ${{ needs.UnitTestingParams.outputs.python_version }} -# unittest_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}-ubuntu-native-3.12 -## coverage_json_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }} -# html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} -# latex_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_latex }} + HTMLDocumentation: + uses: pyTooling/Actions/.github/workflows/SphinxDocumentation.yml@r1 + needs: + - UnitTestingParams + - PublishTestResults + - PublishCoverageResults +# - VerifyDocs + with: + python_version: ${{ needs.UnitTestingParams.outputs.python_version }} + unittest_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}-ubuntu-native-3.12 + coverage_json_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }} + html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} + latex_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_latex }} IntermediateCleanUp: uses: pyTooling/Actions/.github/workflows/IntermediateCleanUp.yml@r1 needs: - UnitTestingParams - PublishCoverageResults -# - PublishTestResults -# - HTMLDocumentation + - PublishTestResults + - HTMLDocumentation with: sqlite_coverage_artifacts_prefix: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}- xml_unittest_artifacts_prefix: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}- @@ -215,18 +215,18 @@ jobs: # latex_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_latex }} # pdf_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_pdf }} -# PublishToGitHubPages: -# uses: pyTooling/Actions/.github/workflows/PublishToGitHubPages.yml@r1 -# needs: -# - UnitTestingParams -# - HTMLDocumentation -## - PDFDocumentation -# - PublishCoverageResults -# - StaticTypeCheck -# with: -# doc: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} -# coverage: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }} -# typing: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} + PublishToGitHubPages: + uses: pyTooling/Actions/.github/workflows/PublishToGitHubPages.yml@r1 + needs: + - UnitTestingParams + - HTMLDocumentation +# - PDFDocumentation + - PublishCoverageResults + - StaticTypeCheck + with: + doc: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} + coverage: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }} + typing: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} ReleasePage: uses: pyTooling/Actions/.github/workflows/Release.yml@r1 @@ -234,7 +234,7 @@ jobs: needs: - Package - AppTesting -# - PublishToGitHubPages + - PublishToGitHubPages PublishOnPyPI: uses: pyTooling/Actions/.github/workflows/PublishOnPyPI.yml@r1 @@ -255,11 +255,11 @@ jobs: - UnitTestingParams - UnitTesting - StaticTypeCheck -# - HTMLDocumentation + - HTMLDocumentation # - PDFDocumentation -# - PublishTestResults + - PublishTestResults - PublishCoverageResults -# - PublishToGitHubPages + - PublishToGitHubPages # - PublishOnPyPI - IntermediateCleanUp with: diff --git a/doc/requirements.txt b/doc/requirements.txt index d037edef..b8a94613 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -6,7 +6,7 @@ ruamel.yaml ~= 0.18.6 setuptools ~= 75.1 # Enforce latest version on ReadTheDocs -sphinx ~= 8.0, <8.1 +sphinx ~= 8.0 docutils ~= 0.21 # ReadTheDocs Theme From b496ae0fe2a9317dfaf119b69f218c8546d5e6ed Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 13 Oct 2024 22:27:52 +0200 Subject: [PATCH 2/4] Allow writing all dialects. --- pyEDAA/Reports/CLI/Unittesting.py | 74 +++++++++++++++---- pyEDAA/Reports/__init__.py | 2 +- run.ps1 | 2 +- .../JUnit/pyGHDL/pyGHDL-Ubuntu-24.04-3.12.xml | 1 + .../data/JUnit/pyGHDL/pyGHDL-Ubuntu-3.12.xml | 1 + .../data/JUnit/pyGHDL/pyGHDL-Windows-3.12.xml | 1 + .../JUnit/pyGHDL/pyGHDL-Winodws-2022-3.12.xml | 1 + 7 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 tests/data/JUnit/pyGHDL/pyGHDL-Ubuntu-24.04-3.12.xml create mode 100644 tests/data/JUnit/pyGHDL/pyGHDL-Ubuntu-3.12.xml create mode 100644 tests/data/JUnit/pyGHDL/pyGHDL-Windows-3.12.xml create mode 100644 tests/data/JUnit/pyGHDL/pyGHDL-Winodws-2022-3.12.xml diff --git a/pyEDAA/Reports/CLI/Unittesting.py b/pyEDAA/Reports/CLI/Unittesting.py index 06631f11..43a844c3 100644 --- a/pyEDAA/Reports/CLI/Unittesting.py +++ b/pyEDAA/Reports/CLI/Unittesting.py @@ -107,7 +107,7 @@ def _open(self, task: str) -> ju_TestsuiteSummary: from pyEDAA.Reports.Unittesting.JUnit.PyTestJUnit import Document docClass = Document else: - raise UnittestException(f"Unsupported JUnit XML dialect for input: '{dataFormat}'") + raise UnittestException(f"Unsupported JUnit XML dialect for input: '{dataFormat}-{dialect}'") self.WriteVerbose(f" Reading {file}") return docClass(file, parse=True) @@ -141,7 +141,7 @@ def _merge(self, testsuiteSummary: MergedTestsuiteSummary, task: str) -> None: elif dialect == "pytest": self._mergePyTestJUnit(testsuiteSummary, foundFiles) else: - self.WriteError(f"Unsupported JUnit XML dialect for merging: '{dataFormat}'") + self.WriteError(f"Unsupported JUnit XML dialect for merging: '{dataFormat}-{dialect}'") else: self.WriteError(f"Unsupported unit testing report dataFormat for merging: '{dataFormat}'") else: @@ -375,25 +375,73 @@ def _output(self, testsuiteSummary: TestsuiteSummary, task: str): outputFile = Path(parts[1]) if format == "junit": if dialect == "ant": - self._outputAntJUnit(testsuiteSummary, outputFile) - # elif dialect == "ctest": - # self._outputCTestJUnit(testsuiteSummary, outputFile) - # elif dialect == "gtest": - # self._outputGoogleTestJUnit(testsuiteSummary, outputFile) - # elif dialect == "pytest": - # self._outputPyTestJUnit(testsuiteSummary, outputFile) + self._outputAntJUnit4(testsuiteSummary, outputFile) + elif dialect == "ctest": + self._outputCTestJUnit(testsuiteSummary, outputFile) + elif dialect == "gtest": + self._outputGoogleTestJUnit(testsuiteSummary, outputFile) + elif dialect == "pytest": + self._outputPyTestJUnit(testsuiteSummary, outputFile) else: - self.WriteError(f"Unsupported JUnit XML dialect for writing: '{format}'") + self.WriteError(f"Unsupported JUnit XML dialect for writing: '{format}-{dialect}'") else: self.WriteError(f"Unsupported unit testing report format for writing: '{format}'") else: self.WriteError(f"Syntax error: '{task}'") - def _outputAntJUnit(self, testsuiteSummary: TestsuiteSummary, file: Path): + def _outputAntJUnit4(self, testsuiteSummary: TestsuiteSummary, file: Path): from pyEDAA.Reports.Unittesting.JUnit.AntJUnit4 import Document, UnittestException self.WriteNormal(f"Writing merged unit test summaries to file ...") - self.WriteVerbose(f" Common Data Model -> OUT (JUnit): {file}") + self.WriteVerbose(f" Common Data Model -> OUT (Ant+JUnit4): {file}") + + junitDocument = Document.FromTestsuiteSummary(file, testsuiteSummary) + try: + junitDocument.Write(regenerate=True, overwrite=True) + except UnittestException as ex: + self.WriteError(str(ex)) + if ex.__cause__ is not None: + self.WriteError(f" {ex.__cause__}") + + self.WriteNormal(f"Output written to '{file}' in Ant+JUnit4 format.") + + def _outputCTestJUnit(self, testsuiteSummary: TestsuiteSummary, file: Path): + from pyEDAA.Reports.Unittesting.JUnit.CTestJUnit import Document, UnittestException + + self.WriteNormal(f"Writing merged unit test summaries to file ...") + self.WriteVerbose(f" Common Data Model -> OUT (CTest-JUnit): {file}") + + junitDocument = Document.FromTestsuiteSummary(file, testsuiteSummary) + try: + junitDocument.Write(regenerate=True, overwrite=True) + except UnittestException as ex: + self.WriteError(str(ex)) + if ex.__cause__ is not None: + self.WriteError(f" {ex.__cause__}") + + self.WriteNormal(f"Output written to '{file}' in CTest-JUnit format.") + + def _outputGoogleTestJUnit(self, testsuiteSummary: TestsuiteSummary, file: Path): + from pyEDAA.Reports.Unittesting.JUnit.GoogleTestJUnit import Document, UnittestException + + self.WriteNormal(f"Writing merged unit test summaries to file ...") + self.WriteVerbose(f" Common Data Model -> OUT (GoogleTest-JUnit): {file}") + + junitDocument = Document.FromTestsuiteSummary(file, testsuiteSummary) + try: + junitDocument.Write(regenerate=True, overwrite=True) + except UnittestException as ex: + self.WriteError(str(ex)) + if ex.__cause__ is not None: + self.WriteError(f" {ex.__cause__}") + + self.WriteNormal(f"Output written to '{file}' in GoogleTest-JUnit format.") + + def _outputPyTestJUnit(self, testsuiteSummary: TestsuiteSummary, file: Path): + from pyEDAA.Reports.Unittesting.JUnit.PyTestJUnit import Document, UnittestException + + self.WriteNormal(f"Writing merged unit test summaries to file ...") + self.WriteVerbose(f" Common Data Model -> OUT (pyTest-JUnit): {file}") junitDocument = Document.FromTestsuiteSummary(file, testsuiteSummary) try: @@ -403,4 +451,4 @@ def _outputAntJUnit(self, testsuiteSummary: TestsuiteSummary, file: Path): if ex.__cause__ is not None: self.WriteError(f" {ex.__cause__}") - self.WriteNormal(f"Output written to '{file}' in Ant-JUnit format.") + self.WriteNormal(f"Output written to '{file}' in pyTest-JUnit format.") diff --git a/pyEDAA/Reports/__init__.py b/pyEDAA/Reports/__init__.py index 48092ba3..24ac9eec 100644 --- a/pyEDAA/Reports/__init__.py +++ b/pyEDAA/Reports/__init__.py @@ -35,7 +35,7 @@ __email__ = "Paebbels@gmail.com" __copyright__ = "2021-2024, Electronic Design Automation Abstraction (EDA²)" __license__ = "Apache License, Version 2.0" -__version__ = "0.13.1" +__version__ = "0.14.0" __keywords__ = ["Reports", "Abstract Model", "Data Model", "Unit Testing", "Testcase", "Testsuite", "OSVVM", "YAML", "XML"] from enum import Enum diff --git a/run.ps1 b/run.ps1 index e4ef1626..c1cad93e 100644 --- a/run.ps1 +++ b/run.ps1 @@ -97,7 +97,7 @@ if ($install) { Write-Host -ForegroundColor Cyan "[ADMIN][UNINSTALL] Uninstalling $PackageName ..." py -3.12 -m pip uninstall -y $PackageName Write-Host -ForegroundColor Cyan "[ADMIN][INSTALL] Installing $PackageName from wheel ..." - py -3.12 -m pip install .\dist\$PackageName-0.13.1-py3-none-any.whl + py -3.12 -m pip install .\dist\$PackageName-0.14.0-py3-none-any.whl Write-Host -ForegroundColor Cyan "[ADMIN][INSTALL] Closing window in 5 seconds ..." Start-Sleep -Seconds 5 diff --git a/tests/data/JUnit/pyGHDL/pyGHDL-Ubuntu-24.04-3.12.xml b/tests/data/JUnit/pyGHDL/pyGHDL-Ubuntu-24.04-3.12.xml new file mode 100644 index 00000000..98691262 --- /dev/null +++ b/tests/data/JUnit/pyGHDL/pyGHDL-Ubuntu-24.04-3.12.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/data/JUnit/pyGHDL/pyGHDL-Ubuntu-3.12.xml b/tests/data/JUnit/pyGHDL/pyGHDL-Ubuntu-3.12.xml new file mode 100644 index 00000000..62aec127 --- /dev/null +++ b/tests/data/JUnit/pyGHDL/pyGHDL-Ubuntu-3.12.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/data/JUnit/pyGHDL/pyGHDL-Windows-3.12.xml b/tests/data/JUnit/pyGHDL/pyGHDL-Windows-3.12.xml new file mode 100644 index 00000000..386b8336 --- /dev/null +++ b/tests/data/JUnit/pyGHDL/pyGHDL-Windows-3.12.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/data/JUnit/pyGHDL/pyGHDL-Winodws-2022-3.12.xml b/tests/data/JUnit/pyGHDL/pyGHDL-Winodws-2022-3.12.xml new file mode 100644 index 00000000..ce7c6156 --- /dev/null +++ b/tests/data/JUnit/pyGHDL/pyGHDL-Winodws-2022-3.12.xml @@ -0,0 +1 @@ + \ No newline at end of file From 524bcdd4bbacecdb9c732ae04cf0a3ad84312502 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 13 Oct 2024 23:34:05 +0200 Subject: [PATCH 3/4] Reduced code duplications due to dialects. --- pyEDAA/Reports/CLI/Unittesting.py | 215 +++++-------------- pyEDAA/Reports/Unittesting/JUnit/__init__.py | 5 +- pyEDAA/Reports/Unittesting/OSVVM.py | 7 +- pyEDAA/Reports/Unittesting/__init__.py | 8 +- tests/unit/Unittesting/Examples/OSVVM.py | 4 +- 5 files changed, 60 insertions(+), 179 deletions(-) diff --git a/pyEDAA/Reports/CLI/Unittesting.py b/pyEDAA/Reports/CLI/Unittesting.py index 43a844c3..18183845 100644 --- a/pyEDAA/Reports/CLI/Unittesting.py +++ b/pyEDAA/Reports/CLI/Unittesting.py @@ -1,13 +1,13 @@ from argparse import Namespace from pathlib import Path -from typing import List, Tuple +from typing import List, Tuple, Type from pyTooling.MetaClasses import ExtendedType from pyTooling.Attributes.ArgParse import CommandHandler from pyTooling.Attributes.ArgParse.ValuedFlag import LongValuedFlag from pyEDAA.Reports.Unittesting import UnittestException, TestsuiteKind, TestsuiteSummary, Testsuite, Testcase -from pyEDAA.Reports.Unittesting import MergedTestsuiteSummary +from pyEDAA.Reports.Unittesting import Document, MergedTestsuiteSummary from pyEDAA.Reports.Unittesting.JUnit import JUnitReaderMode, TestsuiteSummary as ju_TestsuiteSummary @@ -93,24 +93,29 @@ def _open(self, task: str) -> ju_TestsuiteSummary: if dataFormat == "junit": if dialect == "ant": from pyEDAA.Reports.Unittesting.JUnit.AntJUnit4 import Document - docClass = Document + + documentClass = Document elif dialect == "any": from pyEDAA.Reports.Unittesting.JUnit import Document - docClass = Document + + documentClass = Document elif dialect == "ctest": from pyEDAA.Reports.Unittesting.JUnit.CTestJUnit import Document - docClass = Document + + documentClass = Document elif dialect == "gtest": from pyEDAA.Reports.Unittesting.JUnit.GoogleTestJUnit import Document - docClass = Document + + documentClass = Document elif dialect == "pytest": from pyEDAA.Reports.Unittesting.JUnit.PyTestJUnit import Document - docClass = Document + + documentClass = Document else: raise UnittestException(f"Unsupported JUnit XML dialect for input: '{dataFormat}-{dialect}'") self.WriteVerbose(f" Reading {file}") - return docClass(file, parse=True) + return documentClass(file, parse=True) else: raise UnittestException(f"Unsupported unit testing report dataFormat for input: '{dataFormat}'") else: @@ -131,15 +136,25 @@ def _merge(self, testsuiteSummary: MergedTestsuiteSummary, task: str) -> None: if dataFormat == "junit": if dialect == "ant": - self._mergeAntJUnit(testsuiteSummary, foundFiles) + from pyEDAA.Reports.Unittesting.JUnit.AntJUnit4 import Document + + self._mergeJUnit(testsuiteSummary, Document, foundFiles, "Ant+JUnit4") elif dialect == "any": - self._mergeAnyJUnit(testsuiteSummary, foundFiles) + from pyEDAA.Reports.Unittesting.JUnit import Document + + self._mergeJUnit(testsuiteSummary, Document, foundFiles, "Any-JUnit") elif dialect == "ctest": - self._mergeCTestJUnit(testsuiteSummary, foundFiles) + from pyEDAA.Reports.Unittesting.JUnit.CTestJUnit import Document + + self._mergeJUnit(testsuiteSummary, Document, foundFiles, "CTest-JUnit") elif dialect == "gtest": - self._mergeGoogleTestJUnit(testsuiteSummary, foundFiles) + from pyEDAA.Reports.Unittesting.JUnit.GoogleTestJUnit import Document + + self._mergeJUnit(testsuiteSummary, Document, foundFiles, "GoogleTest-JUnit") elif dialect == "pytest": - self._mergePyTestJUnit(testsuiteSummary, foundFiles) + from pyEDAA.Reports.Unittesting.JUnit.PyTestJUnit import Document + + self._mergeJUnit(testsuiteSummary, Document, foundFiles, "pyTest-JUnit") else: self.WriteError(f"Unsupported JUnit XML dialect for merging: '{dataFormat}-{dialect}'") else: @@ -147,109 +162,19 @@ def _merge(self, testsuiteSummary: MergedTestsuiteSummary, task: str) -> None: else: self.WriteError(f"Syntax error: '{task}'") - def _mergeAntJUnit(self, testsuiteSummary: MergedTestsuiteSummary, foundFiles: Tuple[Path, ...]) -> None: - from pyEDAA.Reports.Unittesting.JUnit.AntJUnit4 import Document - - self.WriteNormal(f"Reading {len(foundFiles)} Ant-JUnit unit test summary files ...") - - junitDocuments: List[Document] = [] - for file in foundFiles: - self.WriteVerbose(f" Reading {file}") - try: - junitDocuments.append(Document(file, analyzeAndConvert=True, readerMode=JUnitReaderMode.DecoupleTestsuiteHierarchyAndTestcaseClassName)) - except UnittestException as ex: - self.WriteError(ex) - - if len(junitDocuments) == 0: - self.WriteCritical("None of the Ant-JUnit files were successfully read.") - return - - self.WriteNormal(f"Merging unit test summary files into a single data model ...") - for summary in junitDocuments: - self.WriteVerbose(f" merging {summary.Path}") - testsuiteSummary.Merge(summary.ToTestsuiteSummary()) - - def _mergeAnyJUnit(self, testsuiteSummary: MergedTestsuiteSummary, foundFiles: Tuple[Path, ...]) -> None: - from pyEDAA.Reports.Unittesting.JUnit import Document - - self.WriteNormal(f"Reading {len(foundFiles)} (generic) JUnit unit test summary files ...") - - junitDocuments: List[Document] = [] - for file in foundFiles: - self.WriteVerbose(f" Reading {file}") - try: - junitDocuments.append(Document(file, analyzeAndConvert=True, readerMode=JUnitReaderMode.DecoupleTestsuiteHierarchyAndTestcaseClassName)) - except UnittestException as ex: - self.WriteError(ex) - - if len(junitDocuments) == 0: - self.WriteCritical("None of the (generic) JUnit files were successfully read.") - return - - self.WriteNormal(f"Merging unit test summary files into a single data model ...") - for summary in junitDocuments: - self.WriteVerbose(f" merging {summary.Path}") - testsuiteSummary.Merge(summary.ToTestsuiteSummary()) - - def _mergeCTestJUnit(self, testsuiteSummary: MergedTestsuiteSummary, foundFiles: Tuple[Path, ...]) -> None: - from pyEDAA.Reports.Unittesting.JUnit.CTestJUnit import Document - - self.WriteNormal(f"Reading {len(foundFiles)} CTest-JUnit unit test summary files ...") - - junitDocuments: List[Document] = [] - for file in foundFiles: - self.WriteVerbose(f" Reading {file}") - try: - junitDocuments.append(Document(file, analyzeAndConvert=True, readerMode=JUnitReaderMode.DecoupleTestsuiteHierarchyAndTestcaseClassName)) - except UnittestException as ex: - self.WriteError(ex) - - if len(junitDocuments) == 0: - self.WriteCritical("None of the CTest-JUnit files were successfully read.") - return - - self.WriteNormal(f"Merging unit test summary files into a single data model ...") - for summary in junitDocuments: - self.WriteVerbose(f" merging {summary.Path}") - testsuiteSummary.Merge(summary.ToTestsuiteSummary()) - - def _mergeGoogleTestJUnit(self, testsuiteSummary: MergedTestsuiteSummary, foundFiles: Tuple[Path, ...]) -> None: - from pyEDAA.Reports.Unittesting.JUnit.GoogleTestJUnit import Document - - self.WriteNormal(f"Reading {len(foundFiles)} GoogleTest-JUnit unit test summary files ...") - - junitDocuments: List[Document] = [] - for file in foundFiles: - self.WriteVerbose(f" Reading {file}") - try: - junitDocuments.append(Document(file, analyzeAndConvert=True, readerMode=JUnitReaderMode.DecoupleTestsuiteHierarchyAndTestcaseClassName)) - except UnittestException as ex: - self.WriteError(ex) - - if len(junitDocuments) == 0: - self.WriteCritical("None of the GoogleTest-JUnit files were successfully read.") - return - - self.WriteNormal(f"Merging unit test summary files into a single data model ...") - for summary in junitDocuments: - self.WriteVerbose(f" merging {summary.Path}") - testsuiteSummary.Merge(summary.ToTestsuiteSummary()) + def _mergeJUnit(self, testsuiteSummary: MergedTestsuiteSummary, documentClass: Type[Document], foundFiles: Tuple[Path, ...], dialect: str) -> None: + self.WriteNormal(f"Reading {len(foundFiles)} {dialect} unit test summary files ...") - def _mergePyTestJUnit(self, testsuiteSummary: MergedTestsuiteSummary, foundFiles: Tuple[Path, ...]) -> None: - from pyEDAA.Reports.Unittesting.JUnit.PyTestJUnit import Document - - self.WriteNormal(f"Reading {len(foundFiles)} pytest-JUnit unit test summary files ...") - - junitDocuments: List[Document] = [] + junitDocuments: List[documentClass] = [] for file in foundFiles: self.WriteVerbose(f" Reading {file}") try: - junitDocuments.append(Document(file, analyzeAndConvert=True, readerMode=JUnitReaderMode.DecoupleTestsuiteHierarchyAndTestcaseClassName)) + junitDocuments.append(documentClass(file, analyzeAndConvert=True, readerMode=JUnitReaderMode.DecoupleTestsuiteHierarchyAndTestcaseClassName)) except UnittestException as ex: self.WriteError(ex) if len(junitDocuments) == 0: - self.WriteCritical("None of the pytest-JUnit files were successfully read.") + self.WriteCritical(f"None of the {dialect} files were successfully read.") return self.WriteNormal(f"Merging unit test summary files into a single data model ...") @@ -375,13 +300,21 @@ def _output(self, testsuiteSummary: TestsuiteSummary, task: str): outputFile = Path(parts[1]) if format == "junit": if dialect == "ant": - self._outputAntJUnit4(testsuiteSummary, outputFile) + from pyEDAA.Reports.Unittesting.JUnit.AntJUnit4 import Document, UnittestException + + self._outputJUnit(testsuiteSummary, Document, outputFile, "Ant+JUnit4") elif dialect == "ctest": - self._outputCTestJUnit(testsuiteSummary, outputFile) + from pyEDAA.Reports.Unittesting.JUnit.CTestJUnit import Document, UnittestException + + self._outputJUnit(testsuiteSummary, Document, outputFile, "CTest-JUnit") elif dialect == "gtest": - self._outputGoogleTestJUnit(testsuiteSummary, outputFile) + from pyEDAA.Reports.Unittesting.JUnit.GoogleTestJUnit import Document, UnittestException + + self._outputJUnit(testsuiteSummary, Document, outputFile, "GoogleTest-JUnit") elif dialect == "pytest": - self._outputPyTestJUnit(testsuiteSummary, outputFile) + from pyEDAA.Reports.Unittesting.JUnit.PyTestJUnit import Document, UnittestException + + self._outputJUnit(testsuiteSummary, Document, outputFile, "pyTest-JUnit") else: self.WriteError(f"Unsupported JUnit XML dialect for writing: '{format}-{dialect}'") else: @@ -389,61 +322,11 @@ def _output(self, testsuiteSummary: TestsuiteSummary, task: str): else: self.WriteError(f"Syntax error: '{task}'") - def _outputAntJUnit4(self, testsuiteSummary: TestsuiteSummary, file: Path): - from pyEDAA.Reports.Unittesting.JUnit.AntJUnit4 import Document, UnittestException - - self.WriteNormal(f"Writing merged unit test summaries to file ...") - self.WriteVerbose(f" Common Data Model -> OUT (Ant+JUnit4): {file}") - - junitDocument = Document.FromTestsuiteSummary(file, testsuiteSummary) - try: - junitDocument.Write(regenerate=True, overwrite=True) - except UnittestException as ex: - self.WriteError(str(ex)) - if ex.__cause__ is not None: - self.WriteError(f" {ex.__cause__}") - - self.WriteNormal(f"Output written to '{file}' in Ant+JUnit4 format.") - - def _outputCTestJUnit(self, testsuiteSummary: TestsuiteSummary, file: Path): - from pyEDAA.Reports.Unittesting.JUnit.CTestJUnit import Document, UnittestException - - self.WriteNormal(f"Writing merged unit test summaries to file ...") - self.WriteVerbose(f" Common Data Model -> OUT (CTest-JUnit): {file}") - - junitDocument = Document.FromTestsuiteSummary(file, testsuiteSummary) - try: - junitDocument.Write(regenerate=True, overwrite=True) - except UnittestException as ex: - self.WriteError(str(ex)) - if ex.__cause__ is not None: - self.WriteError(f" {ex.__cause__}") - - self.WriteNormal(f"Output written to '{file}' in CTest-JUnit format.") - - def _outputGoogleTestJUnit(self, testsuiteSummary: TestsuiteSummary, file: Path): - from pyEDAA.Reports.Unittesting.JUnit.GoogleTestJUnit import Document, UnittestException - - self.WriteNormal(f"Writing merged unit test summaries to file ...") - self.WriteVerbose(f" Common Data Model -> OUT (GoogleTest-JUnit): {file}") - - junitDocument = Document.FromTestsuiteSummary(file, testsuiteSummary) - try: - junitDocument.Write(regenerate=True, overwrite=True) - except UnittestException as ex: - self.WriteError(str(ex)) - if ex.__cause__ is not None: - self.WriteError(f" {ex.__cause__}") - - self.WriteNormal(f"Output written to '{file}' in GoogleTest-JUnit format.") - - def _outputPyTestJUnit(self, testsuiteSummary: TestsuiteSummary, file: Path): - from pyEDAA.Reports.Unittesting.JUnit.PyTestJUnit import Document, UnittestException - + def _outputJUnit(self, testsuiteSummary: TestsuiteSummary, documentClass: Type[Document], file: Path, dialect: str): self.WriteNormal(f"Writing merged unit test summaries to file ...") - self.WriteVerbose(f" Common Data Model -> OUT (pyTest-JUnit): {file}") + self.WriteVerbose(f" Common Data Model -> OUT ({dialect}): {file}") - junitDocument = Document.FromTestsuiteSummary(file, testsuiteSummary) + junitDocument = documentClass.FromTestsuiteSummary(file, testsuiteSummary) try: junitDocument.Write(regenerate=True, overwrite=True) except UnittestException as ex: @@ -451,4 +334,4 @@ def _outputPyTestJUnit(self, testsuiteSummary: TestsuiteSummary, file: Path): if ex.__cause__ is not None: self.WriteError(f" {ex.__cause__}") - self.WriteNormal(f"Output written to '{file}' in pyTest-JUnit format.") + self.WriteNormal(f"Output written to '{file}' in {dialect} format.") diff --git a/pyEDAA/Reports/Unittesting/JUnit/__init__.py b/pyEDAA/Reports/Unittesting/JUnit/__init__.py index 416973c4..4bdae87f 100644 --- a/pyEDAA/Reports/Unittesting/JUnit/__init__.py +++ b/pyEDAA/Reports/Unittesting/JUnit/__init__.py @@ -1190,14 +1190,11 @@ class Document(TestsuiteSummary, ut_Document): def __init__(self, xmlReportFile: Path, analyzeAndConvert: bool = False, readerMode: JUnitReaderMode = JUnitReaderMode.Default): super().__init__("Unprocessed JUnit XML file") - ut_Document.__init__(self, xmlReportFile) self._readerMode = readerMode self._xmlDocument = None - if analyzeAndConvert: - self.Analyze() - self.Convert() + ut_Document.__init__(self, xmlReportFile, analyzeAndConvert) @classmethod def FromTestsuiteSummary(cls, xmlReportFile: Path, testsuiteSummary: ut_TestsuiteSummary): diff --git a/pyEDAA/Reports/Unittesting/OSVVM.py b/pyEDAA/Reports/Unittesting/OSVVM.py index 46260cef..20231d6f 100644 --- a/pyEDAA/Reports/Unittesting/OSVVM.py +++ b/pyEDAA/Reports/Unittesting/OSVVM.py @@ -94,15 +94,12 @@ class TestsuiteSummary(ut_TestsuiteSummary): class BuildSummaryDocument(TestsuiteSummary, Document): _yamlDocument: Nullable[YAML] - def __init__(self, yamlReportFile: Path, parse: bool = False) -> None: + def __init__(self, yamlReportFile: Path, analyzeAndConvert: bool = False) -> None: super().__init__("Unprocessed OSVVM YAML file") - Document.__init__(self, yamlReportFile) self._yamlDocument = None - if parse: - self.Analyze() - self.Convert() + Document.__init__(self, yamlReportFile, analyzeAndConvert) def Analyze(self) -> None: """ diff --git a/pyEDAA/Reports/Unittesting/__init__.py b/pyEDAA/Reports/Unittesting/__init__.py index 60618212..8d2ebe4c 100644 --- a/pyEDAA/Reports/Unittesting/__init__.py +++ b/pyEDAA/Reports/Unittesting/__init__.py @@ -1630,12 +1630,16 @@ class Document(metaclass=ExtendedType, mixin=True): _analysisDuration: float #: TODO: replace by Timer; should be timedelta? _modelConversion: float #: TODO: replace by Timer; should be timedelta? - def __init__(self, path: Path): - self._path = path + def __init__(self, reportFile: Path, analyzeAndConvert: bool = False): + self._path = reportFile self._analysisDuration = -1.0 self._modelConversion = -1.0 + if analyzeAndConvert: + self.Analyze() + self.Convert() + @readonly def Path(self) -> Path: """ diff --git a/tests/unit/Unittesting/Examples/OSVVM.py b/tests/unit/Unittesting/Examples/OSVVM.py index 914e4829..587e0c8e 100644 --- a/tests/unit/Unittesting/Examples/OSVVM.py +++ b/tests/unit/Unittesting/Examples/OSVVM.py @@ -89,7 +89,7 @@ def test_OsvvmLibraries(self) -> None: print() yamlPath = Path("tests/data/OSVVM/OSVVMLibraries_OsvvmLibraries.yml") - doc = BuildSummaryDocument(yamlPath, parse=True) + doc = BuildSummaryDocument(yamlPath, analyzeAndConvert=True) print("=" * 40) tree = doc.ToTree() @@ -113,7 +113,7 @@ def test_RunAllTests(self) -> None: print() yamlPath = Path("tests/data/OSVVM/OSVVMLibraries_RunAllTests.yml") - doc = BuildSummaryDocument(yamlPath, parse=True) + doc = BuildSummaryDocument(yamlPath, analyzeAndConvert=True) print("=" * 40) tree = doc.ToTree() From 13938616d10ecef1f82b8acfc7ed32569f1880cd Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 14 Oct 2024 00:10:58 +0200 Subject: [PATCH 4/4] Disable test result publishing. --- .github/workflows/Pipeline.yml | 20 ++++++++++---------- doc/requirements.txt | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index b47c293b..7aa5457f 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -165,13 +165,13 @@ jobs: secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} - PublishTestResults: - uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@dev - needs: - - UnitTestingParams - - UnitTesting - with: - merged_junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} +# PublishTestResults: +# uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@dev +# needs: +# - UnitTestingParams +# - UnitTesting +# with: +# merged_junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} # VerifyDocs: # uses: pyTooling/Actions/.github/workflows/VerifyDocs.yml@r1 @@ -184,7 +184,7 @@ jobs: uses: pyTooling/Actions/.github/workflows/SphinxDocumentation.yml@r1 needs: - UnitTestingParams - - PublishTestResults +# - PublishTestResults - PublishCoverageResults # - VerifyDocs with: @@ -199,7 +199,7 @@ jobs: needs: - UnitTestingParams - PublishCoverageResults - - PublishTestResults +# - PublishTestResults - HTMLDocumentation with: sqlite_coverage_artifacts_prefix: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}- @@ -257,7 +257,7 @@ jobs: - StaticTypeCheck - HTMLDocumentation # - PDFDocumentation - - PublishTestResults +# - PublishTestResults - PublishCoverageResults - PublishToGitHubPages # - PublishOnPyPI diff --git a/doc/requirements.txt b/doc/requirements.txt index b8a94613..df742831 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -6,11 +6,11 @@ ruamel.yaml ~= 0.18.6 setuptools ~= 75.1 # Enforce latest version on ReadTheDocs -sphinx ~= 8.0 +sphinx ~= 8.1 docutils ~= 0.21 # ReadTheDocs Theme -sphinx_rtd_theme ~= 3.0.0 +sphinx_rtd_theme ~= 3.0 # Sphinx Extenstions #sphinxcontrib-actdiag>=0.8.5