Skip to content

Commit

Permalink
v0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels authored Oct 13, 2024
2 parents e01defd + 1393861 commit c06ff23
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 170 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/Pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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 }}-
Expand All @@ -215,26 +215,26 @@ 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
if: startsWith(github.ref, 'refs/tags')
needs:
- Package
- AppTesting
# - PublishToGitHubPages
- PublishToGitHubPages

PublishOnPyPI:
uses: pyTooling/Actions/.github/workflows/PublishOnPyPI.yml@r1
Expand All @@ -255,11 +255,11 @@ jobs:
- UnitTestingParams
- UnitTesting
- StaticTypeCheck
# - HTMLDocumentation
- HTMLDocumentation
# - PDFDocumentation
# - PublishTestResults
- PublishCoverageResults
# - PublishToGitHubPages
- PublishToGitHubPages
# - PublishOnPyPI
- IntermediateCleanUp
with:
Expand Down
4 changes: 2 additions & 2 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ ruamel.yaml ~= 0.18.6
setuptools ~= 75.1

# Enforce latest version on ReadTheDocs
sphinx ~= 8.0, <8.1
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
Expand Down
179 changes: 55 additions & 124 deletions pyEDAA/Reports/CLI/Unittesting.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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}'")
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:
Expand All @@ -131,125 +136,45 @@ 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}'")
self.WriteError(f"Unsupported JUnit XML dialect for merging: '{dataFormat}-{dialect}'")
else:
self.WriteError(f"Unsupported unit testing report dataFormat for merging: '{dataFormat}'")
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 _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 ...")
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 ...")

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 ...")
Expand Down Expand Up @@ -375,32 +300,38 @@ 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)
from pyEDAA.Reports.Unittesting.JUnit.AntJUnit4 import Document, UnittestException

self._outputJUnit(testsuiteSummary, Document, outputFile, "Ant+JUnit4")
elif dialect == "ctest":
from pyEDAA.Reports.Unittesting.JUnit.CTestJUnit import Document, UnittestException

self._outputJUnit(testsuiteSummary, Document, outputFile, "CTest-JUnit")
elif dialect == "gtest":
from pyEDAA.Reports.Unittesting.JUnit.GoogleTestJUnit import Document, UnittestException

self._outputJUnit(testsuiteSummary, Document, outputFile, "GoogleTest-JUnit")
elif dialect == "pytest":
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}'")
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):
from pyEDAA.Reports.Unittesting.JUnit.AntJUnit4 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 (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:
self.WriteError(str(ex))
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 {dialect} format.")
5 changes: 1 addition & 4 deletions pyEDAA/Reports/Unittesting/JUnit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 2 additions & 5 deletions pyEDAA/Reports/Unittesting/OSVVM.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
Loading

0 comments on commit c06ff23

Please sign in to comment.