SmokeCrossFit 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smokecrossfit-0.0.0/.github/workflows/ci.yml +95 -0
- smokecrossfit-0.0.0/.gitignore +182 -0
- smokecrossfit-0.0.0/PKG-INFO +197 -0
- smokecrossfit-0.0.0/README.md +190 -0
- smokecrossfit-0.0.0/SmokeCrossFit.egg-info/PKG-INFO +197 -0
- smokecrossfit-0.0.0/SmokeCrossFit.egg-info/SOURCES.txt +48 -0
- smokecrossfit-0.0.0/SmokeCrossFit.egg-info/dependency_links.txt +1 -0
- smokecrossfit-0.0.0/SmokeCrossFit.egg-info/top_level.txt +1 -0
- smokecrossfit-0.0.0/crossfit/__init__.py +17 -0
- smokecrossfit-0.0.0/crossfit/bin/tools/jacococli.jar +0 -0
- smokecrossfit-0.0.0/crossfit/commands/__init__.py +3 -0
- smokecrossfit-0.0.0/crossfit/commands/command.py +86 -0
- smokecrossfit-0.0.0/crossfit/commands/command_builder.py +176 -0
- smokecrossfit-0.0.0/crossfit/executors/__init__.py +5 -0
- smokecrossfit-0.0.0/crossfit/executors/executor.py +46 -0
- smokecrossfit-0.0.0/crossfit/executors/executor_factory.py +8 -0
- smokecrossfit-0.0.0/crossfit/executors/local_executor.py +95 -0
- smokecrossfit-0.0.0/crossfit/models/__init__.py +5 -0
- smokecrossfit-0.0.0/crossfit/models/command_models.py +31 -0
- smokecrossfit-0.0.0/crossfit/models/executor_models.py +6 -0
- smokecrossfit-0.0.0/crossfit/models/tool_models.py +14 -0
- smokecrossfit-0.0.0/crossfit/refs/__init__.py +9 -0
- smokecrossfit-0.0.0/crossfit/tools/__init__.py +7 -0
- smokecrossfit-0.0.0/crossfit/tools/dotnet_coverage.py +77 -0
- smokecrossfit-0.0.0/crossfit/tools/jacoco.py +105 -0
- smokecrossfit-0.0.0/crossfit/tools/tool.py +90 -0
- smokecrossfit-0.0.0/crossfit/tools/tool_factory.py +20 -0
- smokecrossfit-0.0.0/pyproject.toml +15 -0
- smokecrossfit-0.0.0/requirements.txt +16 -0
- smokecrossfit-0.0.0/setup.cfg +4 -0
- smokecrossfit-0.0.0/testing/conftest.py +19 -0
- smokecrossfit-0.0.0/testing/helpers/command/f1.txt +0 -0
- smokecrossfit-0.0.0/testing/helpers/tools/dotnetcoverage/classfiles/.gitkeep +0 -0
- smokecrossfit-0.0.0/testing/helpers/tools/dotnetcoverage/s1.cobertura.xml +9 -0
- smokecrossfit-0.0.0/testing/helpers/tools/dotnetcoverage/s2.cobertura.xml +9 -0
- smokecrossfit-0.0.0/testing/helpers/tools/dotnetcoverage/sourcecode/.gitkeep +0 -0
- smokecrossfit-0.0.0/testing/helpers/tools/dotnetcoverage/sourcecode/Dummy.cs +1 -0
- smokecrossfit-0.0.0/testing/helpers/tools/jacoco/classfiles/.gitkeep +0 -0
- smokecrossfit-0.0.0/testing/helpers/tools/jacoco/f1.exec +0 -0
- smokecrossfit-0.0.0/testing/helpers/tools/jacoco/f2.exec +0 -0
- smokecrossfit-0.0.0/testing/helpers/tools/jacoco/sourcecode/.gitkeep +0 -0
- smokecrossfit-0.0.0/testing/sanity/test_dotnet_coverage.py +63 -0
- smokecrossfit-0.0.0/testing/sanity/test_jacoco.py +103 -0
- smokecrossfit-0.0.0/testing/unit-tests/command_tests/test_command.py +147 -0
- smokecrossfit-0.0.0/testing/unit-tests/command_tests/test_command_builder.py +313 -0
- smokecrossfit-0.0.0/testing/unit-tests/executors_tests/test_executor.py +232 -0
- smokecrossfit-0.0.0/testing/unit-tests/executors_tests/test_local_executor.py +389 -0
- smokecrossfit-0.0.0/testing/unit-tests/tools_tests/test_dotnet_coverage.py +107 -0
- smokecrossfit-0.0.0/testing/unit-tests/tools_tests/test_jacoco.py +130 -0
- smokecrossfit-0.0.0/testing/unit-tests/tools_tests/test_tool.py +203 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
name: CI/CD
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["*"]
|
|
6
|
+
tags:
|
|
7
|
+
- "v*"
|
|
8
|
+
pull_request:
|
|
9
|
+
branches: [master]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
unit-tests:
|
|
13
|
+
name: Unit Tests
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
|
|
23
|
+
- name: Cache pip dependencies
|
|
24
|
+
uses: actions/cache@v4
|
|
25
|
+
with:
|
|
26
|
+
path: ~/.cache/pip
|
|
27
|
+
key: ${{ runner.os }}-pip-test-${{ hashFiles('requirements.txt') }}
|
|
28
|
+
restore-keys: |
|
|
29
|
+
${{ runner.os }}-pip-test-
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: |
|
|
33
|
+
python -m pip install --upgrade pip
|
|
34
|
+
pip install -r requirements.txt
|
|
35
|
+
pip install -e .
|
|
36
|
+
|
|
37
|
+
- name: Run unit tests
|
|
38
|
+
run: pytest testing/unit-tests -v --tb=short
|
|
39
|
+
|
|
40
|
+
build:
|
|
41
|
+
name: Build distributions
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
needs: [unit-tests]
|
|
44
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
with:
|
|
48
|
+
fetch-depth: 0
|
|
49
|
+
|
|
50
|
+
- name: Set up Python
|
|
51
|
+
uses: actions/setup-python@v5
|
|
52
|
+
with:
|
|
53
|
+
python-version: "3.12"
|
|
54
|
+
|
|
55
|
+
- name: Install build tooling
|
|
56
|
+
run: |
|
|
57
|
+
python -m pip install --upgrade pip
|
|
58
|
+
pip install build twine
|
|
59
|
+
|
|
60
|
+
- name: Build sdist and wheel
|
|
61
|
+
run: python -m build
|
|
62
|
+
|
|
63
|
+
- name: Validate distributions
|
|
64
|
+
run: twine check dist/*
|
|
65
|
+
|
|
66
|
+
- name: Upload dist artifacts
|
|
67
|
+
uses: actions/upload-artifact@v4
|
|
68
|
+
with:
|
|
69
|
+
name: dist
|
|
70
|
+
path: dist/*
|
|
71
|
+
if-no-files-found: error
|
|
72
|
+
|
|
73
|
+
publish-pypi:
|
|
74
|
+
name: Publish to PyPI (Trusted Publishing)
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
needs: [build]
|
|
77
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
78
|
+
permissions:
|
|
79
|
+
id-token: write
|
|
80
|
+
contents: read
|
|
81
|
+
environment:
|
|
82
|
+
name: pypi
|
|
83
|
+
url: https://pypi.org/
|
|
84
|
+
|
|
85
|
+
steps:
|
|
86
|
+
- name: Download dist artifacts
|
|
87
|
+
uses: actions/download-artifact@v4
|
|
88
|
+
with:
|
|
89
|
+
name: dist
|
|
90
|
+
path: dist
|
|
91
|
+
|
|
92
|
+
- name: Publish to PyPI
|
|
93
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
94
|
+
with:
|
|
95
|
+
packages-dir: dist
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
############################
|
|
2
|
+
# OS (macOS)
|
|
3
|
+
############################
|
|
4
|
+
.DS_Store
|
|
5
|
+
.AppleDouble
|
|
6
|
+
.LSOverride
|
|
7
|
+
Icon?
|
|
8
|
+
._*
|
|
9
|
+
.Spotlight-V100
|
|
10
|
+
.Trashes
|
|
11
|
+
|
|
12
|
+
############################
|
|
13
|
+
# Python bytecode / cache
|
|
14
|
+
############################
|
|
15
|
+
__pycache__/
|
|
16
|
+
*.py[cod]
|
|
17
|
+
*$py.class
|
|
18
|
+
*.pyo
|
|
19
|
+
|
|
20
|
+
############################
|
|
21
|
+
# C extensions
|
|
22
|
+
############################
|
|
23
|
+
*.so
|
|
24
|
+
|
|
25
|
+
############################
|
|
26
|
+
# Virtual environments
|
|
27
|
+
############################
|
|
28
|
+
.venv/
|
|
29
|
+
venv/
|
|
30
|
+
env/
|
|
31
|
+
ENV/
|
|
32
|
+
env.bak/
|
|
33
|
+
venv.bak/
|
|
34
|
+
|
|
35
|
+
############################
|
|
36
|
+
# Packaging / build
|
|
37
|
+
############################
|
|
38
|
+
build/
|
|
39
|
+
dist/
|
|
40
|
+
develop-eggs/
|
|
41
|
+
eggs/
|
|
42
|
+
.eggs/
|
|
43
|
+
lib/
|
|
44
|
+
lib64/
|
|
45
|
+
parts/
|
|
46
|
+
sdist/
|
|
47
|
+
var/
|
|
48
|
+
wheels/
|
|
49
|
+
share/python-wheels/
|
|
50
|
+
*.egg-info/
|
|
51
|
+
.installed.cfg
|
|
52
|
+
*.egg
|
|
53
|
+
MANIFEST
|
|
54
|
+
|
|
55
|
+
############################
|
|
56
|
+
# PyInstaller
|
|
57
|
+
############################
|
|
58
|
+
*.manifest
|
|
59
|
+
*.spec
|
|
60
|
+
|
|
61
|
+
############################
|
|
62
|
+
# Logs
|
|
63
|
+
############################
|
|
64
|
+
*.log
|
|
65
|
+
pip-log.txt
|
|
66
|
+
pip-delete-this-directory.txt
|
|
67
|
+
|
|
68
|
+
############################
|
|
69
|
+
# Testing / coverage
|
|
70
|
+
############################
|
|
71
|
+
htmlcov/
|
|
72
|
+
.tox/
|
|
73
|
+
.nox/
|
|
74
|
+
.coverage
|
|
75
|
+
.coverage.*
|
|
76
|
+
.cache
|
|
77
|
+
nosetests.xml
|
|
78
|
+
coverage.xml
|
|
79
|
+
*.cover
|
|
80
|
+
*.py,cover
|
|
81
|
+
.hypothesis/
|
|
82
|
+
.pytest_cache/
|
|
83
|
+
cover/
|
|
84
|
+
|
|
85
|
+
############################
|
|
86
|
+
# Jupyter
|
|
87
|
+
############################
|
|
88
|
+
.ipynb_checkpoints/
|
|
89
|
+
|
|
90
|
+
############################
|
|
91
|
+
# IPython
|
|
92
|
+
############################
|
|
93
|
+
profile_default/
|
|
94
|
+
ipython_config.py
|
|
95
|
+
|
|
96
|
+
############################
|
|
97
|
+
# Django
|
|
98
|
+
############################
|
|
99
|
+
local_settings.py
|
|
100
|
+
db.sqlite3
|
|
101
|
+
db.sqlite3-journal
|
|
102
|
+
|
|
103
|
+
############################
|
|
104
|
+
# Flask
|
|
105
|
+
############################
|
|
106
|
+
instance/
|
|
107
|
+
.webassets-cache
|
|
108
|
+
|
|
109
|
+
############################
|
|
110
|
+
# Scrapy
|
|
111
|
+
############################
|
|
112
|
+
.scrapy
|
|
113
|
+
|
|
114
|
+
############################
|
|
115
|
+
# Sphinx docs
|
|
116
|
+
############################
|
|
117
|
+
docs/_build/
|
|
118
|
+
|
|
119
|
+
############################
|
|
120
|
+
# PyBuilder
|
|
121
|
+
############################
|
|
122
|
+
.pybuilder/
|
|
123
|
+
target/
|
|
124
|
+
|
|
125
|
+
############################
|
|
126
|
+
# Static type checkers
|
|
127
|
+
############################
|
|
128
|
+
.mypy_cache/
|
|
129
|
+
.dmypy.json
|
|
130
|
+
dmypy.json
|
|
131
|
+
.pyre/
|
|
132
|
+
.pytype/
|
|
133
|
+
|
|
134
|
+
############################
|
|
135
|
+
# Cython
|
|
136
|
+
############################
|
|
137
|
+
cython_debug/
|
|
138
|
+
|
|
139
|
+
############################
|
|
140
|
+
# Dependency managers
|
|
141
|
+
############################
|
|
142
|
+
.pdm.toml
|
|
143
|
+
__pypackages__/
|
|
144
|
+
|
|
145
|
+
# Uncomment if you don't want lock files:
|
|
146
|
+
# Pipfile.lock
|
|
147
|
+
# poetry.lock
|
|
148
|
+
# pdm.lock
|
|
149
|
+
|
|
150
|
+
############################
|
|
151
|
+
# Celery
|
|
152
|
+
############################
|
|
153
|
+
celerybeat-schedule
|
|
154
|
+
celerybeat.pid
|
|
155
|
+
|
|
156
|
+
############################
|
|
157
|
+
# IDEs / Editors
|
|
158
|
+
############################
|
|
159
|
+
# PyCharm / JetBrains
|
|
160
|
+
.idea/
|
|
161
|
+
*.iml
|
|
162
|
+
|
|
163
|
+
# VS Code (optional)
|
|
164
|
+
.vscode/
|
|
165
|
+
|
|
166
|
+
# Spyder
|
|
167
|
+
.spyderproject
|
|
168
|
+
.spyproject
|
|
169
|
+
|
|
170
|
+
# Rope
|
|
171
|
+
.ropeproject
|
|
172
|
+
|
|
173
|
+
############################
|
|
174
|
+
# Project specific
|
|
175
|
+
############################
|
|
176
|
+
testing/**/output/
|
|
177
|
+
|
|
178
|
+
############################
|
|
179
|
+
# Environment files
|
|
180
|
+
############################
|
|
181
|
+
.env
|
|
182
|
+
.env.*
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: SmokeCrossFit
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: A unified interface for various code coverage tools (JaCoCo, dotnet-coverage)
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# CrossFit Coverage Tools
|
|
9
|
+
|
|
10
|
+
CrossFit is a Python package designed to provide a unified interface for various code coverage tools. It wraps the functionality of different coverage CLI tools, allowing developers to use a consistent API regardless of which underlying tool they prefer.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
To install CrossFit, run:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install crossfit
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
Before using CrossFit, ensure you have the following installed:
|
|
23
|
+
|
|
24
|
+
1. Python 3.7 or higher
|
|
25
|
+
2. Java Runtime Environment (JRE) - Required for JaCoCo integration
|
|
26
|
+
3. The specific coverage tools you intend to use (e.g., JaCoCo, dotnet-coverage)
|
|
27
|
+
|
|
28
|
+
## Supported Tools
|
|
29
|
+
|
|
30
|
+
CrossFit currently supports the following coverage tools:
|
|
31
|
+
|
|
32
|
+
1. **JaCoCo** - Java-based code coverage tool
|
|
33
|
+
2. **dotnet-coverage** - .NET coverage tool
|
|
34
|
+
3. **dotnet-reportgenerator** - .NET report generation tool
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
CrossFit provides a unified interface for managing code coverage across different tools. Here's how to use it:
|
|
39
|
+
|
|
40
|
+
### Basic Usage
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from crossfit.tools.jacoco import Jacoco
|
|
44
|
+
|
|
45
|
+
# Initialize the JaCoCo tool
|
|
46
|
+
jacoco = Jacoco(tool_path="/path/to/jacoco")
|
|
47
|
+
|
|
48
|
+
# Save coverage report
|
|
49
|
+
result = jacoco.save_report(
|
|
50
|
+
coverage_files=["coverage.exec"],
|
|
51
|
+
target_dir="/output/directory",
|
|
52
|
+
sourcecode_dir="/source/code"
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Key Features
|
|
57
|
+
|
|
58
|
+
- **Unified Interface**: Consistent API across different coverage tools
|
|
59
|
+
- **Command Building**: Automatic validation of required flags
|
|
60
|
+
- **Coverage Management**: Merge, snapshot, and save coverage data
|
|
61
|
+
- **Error Handling**: Comprehensive logging and error reporting
|
|
62
|
+
- **Multiple Report Formats**: Support for CSV, HTML, XML, and Cobertura formats
|
|
63
|
+
|
|
64
|
+
### Example Workflow
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from crossfit.tools.jacoco import Jacoco
|
|
68
|
+
from crossfit.models.tool_models import ReportFormat
|
|
69
|
+
|
|
70
|
+
# Initialize JaCoCo tool
|
|
71
|
+
jacoco = Jacoco(tool_path="/path/to/jacoco")
|
|
72
|
+
|
|
73
|
+
# Merge coverage files
|
|
74
|
+
merge_result = jacoco.merge_coverage(
|
|
75
|
+
coverage_files=["coverage1.exec", "coverage2.exec"],
|
|
76
|
+
target_dir="/output",
|
|
77
|
+
target_file="merged.exec"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Generate HTML report
|
|
81
|
+
report_result = jacoco.save_report(
|
|
82
|
+
coverage_files=["merged.exec"],
|
|
83
|
+
target_dir="/reports",
|
|
84
|
+
sourcecode_dir="/src",
|
|
85
|
+
report_format=ReportFormat.Html
|
|
86
|
+
)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Package Structure
|
|
90
|
+
|
|
91
|
+
The package follows a modular structure:
|
|
92
|
+
|
|
93
|
+
- `crossfit/tools/jacoco.py`: Implementation of JaCoCo tool wrapper
|
|
94
|
+
- `crossfit/tools/dotnet_coverage.py`: Implementation of .NET coverage tool wrapper
|
|
95
|
+
- `crossfit/tools/tool.py`: Base tool class and abstract methods
|
|
96
|
+
- `crossfit/models/tool_models.py`: Enum definitions for tool types and report formats
|
|
97
|
+
- `crossfit/models/command_models.py`: Command result models and command types
|
|
98
|
+
- `crossfit/commands/command.py`: Command building and execution utilities
|
|
99
|
+
|
|
100
|
+
## Core Components
|
|
101
|
+
|
|
102
|
+
### Tool Models (`crossfit/models/tool_models.py`)
|
|
103
|
+
|
|
104
|
+
Defines the core enumerations used throughout the package:
|
|
105
|
+
|
|
106
|
+
- **ToolType**: Enum representing supported tools
|
|
107
|
+
- `Jacoco`
|
|
108
|
+
- `DotnetCoverage`
|
|
109
|
+
- `DotnetReportGenerator`
|
|
110
|
+
|
|
111
|
+
- **ReportFormat**: Enum representing supported report formats
|
|
112
|
+
- `Csv`
|
|
113
|
+
- `Html`
|
|
114
|
+
- `Xml`
|
|
115
|
+
- `Cobertura`
|
|
116
|
+
|
|
117
|
+
### Command Models (`crossfit/models/command_models.py`)
|
|
118
|
+
|
|
119
|
+
Provides structured representations of command results:
|
|
120
|
+
|
|
121
|
+
- **CommandType**: Enum defining command types
|
|
122
|
+
- `SaveReport`
|
|
123
|
+
- `SnapshotCoverage`
|
|
124
|
+
- `MergeCoverage`
|
|
125
|
+
- `ResetCoverage`
|
|
126
|
+
|
|
127
|
+
- **CommandResult**: Pydantic model for command execution results with fields:
|
|
128
|
+
- `code`: Exit code from command execution
|
|
129
|
+
- `command`: The executed command string
|
|
130
|
+
- `output`: Standard output from command
|
|
131
|
+
- `target`: Target path/file of operation
|
|
132
|
+
- `error`: Error output from command
|
|
133
|
+
|
|
134
|
+
### Command Builder (`crossfit/commands/command.py`)
|
|
135
|
+
|
|
136
|
+
Provides utilities for building and executing shell commands:
|
|
137
|
+
|
|
138
|
+
- **Command**: Class for constructing shell commands with:
|
|
139
|
+
- Execution call (e.g., `java -jar`)
|
|
140
|
+
- Command keywords (e.g., `dump`, `merge`, `report`)
|
|
141
|
+
- Options and arguments
|
|
142
|
+
- Path validation
|
|
143
|
+
- Delimiter handling for option-value pairs
|
|
144
|
+
|
|
145
|
+
## Tool Implementations
|
|
146
|
+
|
|
147
|
+
### JaCoCo Tool (`crossfit/tools/jacoco.py`)
|
|
148
|
+
|
|
149
|
+
Implements the JaCoCo coverage tool with methods:
|
|
150
|
+
|
|
151
|
+
- `save_report()`: Generate coverage reports in various formats
|
|
152
|
+
- `snapshot_coverage()`: Take coverage snapshots
|
|
153
|
+
- `merge_coverage()`: Merge multiple coverage files
|
|
154
|
+
- `_get_command()`: Build validated JaCoCo commands with required flag checking
|
|
155
|
+
|
|
156
|
+
### DotNet Coverage Tool (`crossfit/tools/dotnet_coverage.py`)
|
|
157
|
+
|
|
158
|
+
Implements the .NET coverage tool with methods:
|
|
159
|
+
|
|
160
|
+
- `save_report()`: Generate reports from coverage files
|
|
161
|
+
- `merge_coverage()`: Merge coverage data
|
|
162
|
+
- `snapshot_coverage()`: Capture coverage snapshots
|
|
163
|
+
- `reset_coverage()`: Reset coverage data
|
|
164
|
+
|
|
165
|
+
## Advanced Usage
|
|
166
|
+
|
|
167
|
+
### Working with Multiple Report Formats
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from crossfit.tools.jacoco import Jacoco
|
|
171
|
+
from crossfit.models.tool_models import ReportFormat
|
|
172
|
+
|
|
173
|
+
jacoco = Jacoco(tool_path="/path/to/jacoco")
|
|
174
|
+
|
|
175
|
+
# Generate multiple report formats
|
|
176
|
+
result = jacoco.save_report(
|
|
177
|
+
coverage_files=["coverage.exec"],
|
|
178
|
+
target_dir="/reports",
|
|
179
|
+
sourcecode_dir="/src",
|
|
180
|
+
report_formats=[ReportFormat.Html, ReportFormat.Xml, ReportFormat.Cobertura]
|
|
181
|
+
)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Custom Command Arguments
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
from crossfit.tools.jacoco import Jacoco
|
|
188
|
+
|
|
189
|
+
jacoco = Jacoco(tool_path="/path/to/jacoco")
|
|
190
|
+
|
|
191
|
+
# Pass custom arguments to commands
|
|
192
|
+
result = jacoco.merge_coverage(
|
|
193
|
+
["coverage1.exec", "coverage2.exec"],
|
|
194
|
+
"/output", "merged.exec",
|
|
195
|
+
*["--format", "xml"] # Custom arguments
|
|
196
|
+
)
|
|
197
|
+
```
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# CrossFit Coverage Tools
|
|
2
|
+
|
|
3
|
+
CrossFit is a Python package designed to provide a unified interface for various code coverage tools. It wraps the functionality of different coverage CLI tools, allowing developers to use a consistent API regardless of which underlying tool they prefer.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
To install CrossFit, run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install crossfit
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
Before using CrossFit, ensure you have the following installed:
|
|
16
|
+
|
|
17
|
+
1. Python 3.7 or higher
|
|
18
|
+
2. Java Runtime Environment (JRE) - Required for JaCoCo integration
|
|
19
|
+
3. The specific coverage tools you intend to use (e.g., JaCoCo, dotnet-coverage)
|
|
20
|
+
|
|
21
|
+
## Supported Tools
|
|
22
|
+
|
|
23
|
+
CrossFit currently supports the following coverage tools:
|
|
24
|
+
|
|
25
|
+
1. **JaCoCo** - Java-based code coverage tool
|
|
26
|
+
2. **dotnet-coverage** - .NET coverage tool
|
|
27
|
+
3. **dotnet-reportgenerator** - .NET report generation tool
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
CrossFit provides a unified interface for managing code coverage across different tools. Here's how to use it:
|
|
32
|
+
|
|
33
|
+
### Basic Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from crossfit.tools.jacoco import Jacoco
|
|
37
|
+
|
|
38
|
+
# Initialize the JaCoCo tool
|
|
39
|
+
jacoco = Jacoco(tool_path="/path/to/jacoco")
|
|
40
|
+
|
|
41
|
+
# Save coverage report
|
|
42
|
+
result = jacoco.save_report(
|
|
43
|
+
coverage_files=["coverage.exec"],
|
|
44
|
+
target_dir="/output/directory",
|
|
45
|
+
sourcecode_dir="/source/code"
|
|
46
|
+
)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Key Features
|
|
50
|
+
|
|
51
|
+
- **Unified Interface**: Consistent API across different coverage tools
|
|
52
|
+
- **Command Building**: Automatic validation of required flags
|
|
53
|
+
- **Coverage Management**: Merge, snapshot, and save coverage data
|
|
54
|
+
- **Error Handling**: Comprehensive logging and error reporting
|
|
55
|
+
- **Multiple Report Formats**: Support for CSV, HTML, XML, and Cobertura formats
|
|
56
|
+
|
|
57
|
+
### Example Workflow
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from crossfit.tools.jacoco import Jacoco
|
|
61
|
+
from crossfit.models.tool_models import ReportFormat
|
|
62
|
+
|
|
63
|
+
# Initialize JaCoCo tool
|
|
64
|
+
jacoco = Jacoco(tool_path="/path/to/jacoco")
|
|
65
|
+
|
|
66
|
+
# Merge coverage files
|
|
67
|
+
merge_result = jacoco.merge_coverage(
|
|
68
|
+
coverage_files=["coverage1.exec", "coverage2.exec"],
|
|
69
|
+
target_dir="/output",
|
|
70
|
+
target_file="merged.exec"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
# Generate HTML report
|
|
74
|
+
report_result = jacoco.save_report(
|
|
75
|
+
coverage_files=["merged.exec"],
|
|
76
|
+
target_dir="/reports",
|
|
77
|
+
sourcecode_dir="/src",
|
|
78
|
+
report_format=ReportFormat.Html
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Package Structure
|
|
83
|
+
|
|
84
|
+
The package follows a modular structure:
|
|
85
|
+
|
|
86
|
+
- `crossfit/tools/jacoco.py`: Implementation of JaCoCo tool wrapper
|
|
87
|
+
- `crossfit/tools/dotnet_coverage.py`: Implementation of .NET coverage tool wrapper
|
|
88
|
+
- `crossfit/tools/tool.py`: Base tool class and abstract methods
|
|
89
|
+
- `crossfit/models/tool_models.py`: Enum definitions for tool types and report formats
|
|
90
|
+
- `crossfit/models/command_models.py`: Command result models and command types
|
|
91
|
+
- `crossfit/commands/command.py`: Command building and execution utilities
|
|
92
|
+
|
|
93
|
+
## Core Components
|
|
94
|
+
|
|
95
|
+
### Tool Models (`crossfit/models/tool_models.py`)
|
|
96
|
+
|
|
97
|
+
Defines the core enumerations used throughout the package:
|
|
98
|
+
|
|
99
|
+
- **ToolType**: Enum representing supported tools
|
|
100
|
+
- `Jacoco`
|
|
101
|
+
- `DotnetCoverage`
|
|
102
|
+
- `DotnetReportGenerator`
|
|
103
|
+
|
|
104
|
+
- **ReportFormat**: Enum representing supported report formats
|
|
105
|
+
- `Csv`
|
|
106
|
+
- `Html`
|
|
107
|
+
- `Xml`
|
|
108
|
+
- `Cobertura`
|
|
109
|
+
|
|
110
|
+
### Command Models (`crossfit/models/command_models.py`)
|
|
111
|
+
|
|
112
|
+
Provides structured representations of command results:
|
|
113
|
+
|
|
114
|
+
- **CommandType**: Enum defining command types
|
|
115
|
+
- `SaveReport`
|
|
116
|
+
- `SnapshotCoverage`
|
|
117
|
+
- `MergeCoverage`
|
|
118
|
+
- `ResetCoverage`
|
|
119
|
+
|
|
120
|
+
- **CommandResult**: Pydantic model for command execution results with fields:
|
|
121
|
+
- `code`: Exit code from command execution
|
|
122
|
+
- `command`: The executed command string
|
|
123
|
+
- `output`: Standard output from command
|
|
124
|
+
- `target`: Target path/file of operation
|
|
125
|
+
- `error`: Error output from command
|
|
126
|
+
|
|
127
|
+
### Command Builder (`crossfit/commands/command.py`)
|
|
128
|
+
|
|
129
|
+
Provides utilities for building and executing shell commands:
|
|
130
|
+
|
|
131
|
+
- **Command**: Class for constructing shell commands with:
|
|
132
|
+
- Execution call (e.g., `java -jar`)
|
|
133
|
+
- Command keywords (e.g., `dump`, `merge`, `report`)
|
|
134
|
+
- Options and arguments
|
|
135
|
+
- Path validation
|
|
136
|
+
- Delimiter handling for option-value pairs
|
|
137
|
+
|
|
138
|
+
## Tool Implementations
|
|
139
|
+
|
|
140
|
+
### JaCoCo Tool (`crossfit/tools/jacoco.py`)
|
|
141
|
+
|
|
142
|
+
Implements the JaCoCo coverage tool with methods:
|
|
143
|
+
|
|
144
|
+
- `save_report()`: Generate coverage reports in various formats
|
|
145
|
+
- `snapshot_coverage()`: Take coverage snapshots
|
|
146
|
+
- `merge_coverage()`: Merge multiple coverage files
|
|
147
|
+
- `_get_command()`: Build validated JaCoCo commands with required flag checking
|
|
148
|
+
|
|
149
|
+
### DotNet Coverage Tool (`crossfit/tools/dotnet_coverage.py`)
|
|
150
|
+
|
|
151
|
+
Implements the .NET coverage tool with methods:
|
|
152
|
+
|
|
153
|
+
- `save_report()`: Generate reports from coverage files
|
|
154
|
+
- `merge_coverage()`: Merge coverage data
|
|
155
|
+
- `snapshot_coverage()`: Capture coverage snapshots
|
|
156
|
+
- `reset_coverage()`: Reset coverage data
|
|
157
|
+
|
|
158
|
+
## Advanced Usage
|
|
159
|
+
|
|
160
|
+
### Working with Multiple Report Formats
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from crossfit.tools.jacoco import Jacoco
|
|
164
|
+
from crossfit.models.tool_models import ReportFormat
|
|
165
|
+
|
|
166
|
+
jacoco = Jacoco(tool_path="/path/to/jacoco")
|
|
167
|
+
|
|
168
|
+
# Generate multiple report formats
|
|
169
|
+
result = jacoco.save_report(
|
|
170
|
+
coverage_files=["coverage.exec"],
|
|
171
|
+
target_dir="/reports",
|
|
172
|
+
sourcecode_dir="/src",
|
|
173
|
+
report_formats=[ReportFormat.Html, ReportFormat.Xml, ReportFormat.Cobertura]
|
|
174
|
+
)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Custom Command Arguments
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from crossfit.tools.jacoco import Jacoco
|
|
181
|
+
|
|
182
|
+
jacoco = Jacoco(tool_path="/path/to/jacoco")
|
|
183
|
+
|
|
184
|
+
# Pass custom arguments to commands
|
|
185
|
+
result = jacoco.merge_coverage(
|
|
186
|
+
["coverage1.exec", "coverage2.exec"],
|
|
187
|
+
"/output", "merged.exec",
|
|
188
|
+
*["--format", "xml"] # Custom arguments
|
|
189
|
+
)
|
|
190
|
+
```
|