pydcov


Namepydcov JSON
Version 1.0.3 PyPI version JSON
download
home_pageNone
SummaryIncremental C/C++ code coverage tools for CMake projects
upload_time2025-10-15 21:42:10
maintainerEthan Li
docs_urlNone
authorEthan Li
requires_python>=3.11
licenseNone
keywords coverage incremental c cpp cmake testing gcov llvm-cov
VCS
bugtrack_url
requirements pytest pytest-cov pytest-xdist pytest-html coverage
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyDCov - Incremental C/C++ Code Coverage Tools

[![PyPI version](https://badge.fury.io/py/pydcov.svg)](https://badge.fury.io/py/pydcov)
[![Python Support](https://img.shields.io/pypi/pyversions/pydcov.svg)](https://pypi.org/project/pydcov/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A streamlined incremental coverage tracking system for CMake-based C/C++ projects. PyDCov provides modern Python tools for incremental coverage collection and reporting with support for both GCC/gcov and Clang/llvm-cov toolchains, plus CMake integration setup.

## Features

- **Cross-platform support**: Linux, macOS, Windows
- **Multiple compiler support**: GCC/gcov and Clang/llvm-cov
- **CMake integration**: Seamless integration with CMake build systems
- **Incremental coverage**: Efficient incremental collection and reporting
- **Framework-agnostic**: Works with any testing framework (pytest, unittest, custom executables)
- **Modern Python API**: Clean, well-documented Python interface

## Installation

### Python Package

```bash
pip install pydcov
```

### Standalone Executables

Pre-built standalone executables are available for Linux and macOS from the [GitHub Releases](https://github.com/ethan-li/pydcov/releases) page. These executables don't require Python to be installed on the target system.

- **Linux (x64)**: `pydcov-linux-x64`
- **macOS (ARM64)**: `pydcov-macos-arm64`

### System Requirements

PyDCov requires the following system tools to be installed:

**Build Tools:**
- CMake (3.10 or later)
- Make or Ninja
- GCC or Clang compiler

**Coverage Tools (choose one):**

For GCC:
```bash
# Ubuntu/Debian
sudo apt-get install gcc gcov lcov

# macOS
brew install gcc lcov
```

For Clang:
```bash
# Ubuntu/Debian  
sudo apt-get install clang llvm

# macOS
brew install llvm
```

## Quick Start

### 1. Initialize CMake Integration

In your C/C++ project directory:

```bash
pydcov init-cmake
```

This copies the CMake integration files to your project.

### 2. Update CMakeLists.txt

Add this line to your root CMakeLists.txt:

```cmake
include(cmake/coverage.cmake)
```

### 3. Run Incremental Coverage

```bash
# Initialize incremental tracking
pydcov init

# Add coverage data from test runs
pydcov add python -m pytest tests/test_module1.py
pydcov add python -m pytest tests/test_module2.py

# Generate combined report
pydcov report
```

## Command Reference

### Incremental Coverage Commands

```bash
pydcov init                          # Initialize incremental tracking
pydcov init --pydcov-dir /path/data  # Initialize with custom coverage directory
pydcov add python -m pytest tests/  # Add coverage data from test run
pydcov merge                         # Merge coverage data
pydcov report                        # Generate incremental report
pydcov status                        # Show incremental status
pydcov clean                         # Clean all coverage data
```

### Utility Commands

```bash
pydcov init-cmake              # Copy CMake integration files
pydcov --version               # Show version
pydcov --help                  # Show help
```

## Python API

PyDCov can also be used programmatically:

```python
from pydcov import IncrementalCoverageManager

# Incremental coverage workflow
manager = IncrementalCoverageManager()
manager.init()
manager.add(["python", "-m", "pytest", "tests/module1/"])
manager.add(["python", "-m", "pytest", "tests/module2/"])
manager.merge()
manager.report()
```

## CMake Integration

PyDCov provides a comprehensive CMake module that automatically:

- Detects available compilers and coverage tools
- Configures appropriate coverage flags
- Creates coverage targets (`coverage-clean`, `coverage-report`)
- Supports both GCC/gcov and Clang/llvm-cov workflows
- Integrates with incremental coverage collection

Example CMakeLists.txt:

```cmake
cmake_minimum_required(VERSION 3.10)
project(MyProject)

# Include PyDCov coverage support
include(cmake/coverage.cmake)

# Your project configuration
add_executable(my_app src/main.cpp)

# Coverage will be automatically configured
```

## Examples

### Basic C++ Project

```bash
# Setup
mkdir my-cpp-project && cd my-cpp-project
pydcov init-cmake

# Create CMakeLists.txt with coverage support
echo 'cmake_minimum_required(VERSION 3.10)
project(MyApp)
include(cmake/coverage.cmake)
add_executable(my_app main.cpp)' > CMakeLists.txt

# Run coverage
pydcov init
pydcov add python -m pytest tests/
pydcov report
```

### Integration with CI/CD

```yaml
# GitHub Actions example
- name: Install PyDCov
  run: pip install pydcov

- name: Setup coverage
  run: pydcov init-cmake

- name: Run coverage
  run: |
    pydcov init
    pydcov add python -m pytest tests/
    pydcov report
```

## Troubleshooting

### Common Issues

**"Coverage tools not found"**
- Install GCC/gcov or Clang/llvm-cov
- Ensure tools are in PATH

**"CMake configuration failed"**
- Verify CMake is installed and accessible
- Check that `include(cmake/coverage.cmake)` is in CMakeLists.txt

**"No coverage data found"**
- Ensure tests are actually running
- Verify executables are built with coverage flags

### Getting Help

- Check the [documentation](https://github.com/ethan-li/pydcov)
- Report issues on [GitHub](https://github.com/ethan-li/pydcov/issues)

## License

MIT License. See LICENSE file for details.

## Contributing

Contributions are welcome! Please see the contributing guidelines in the repository.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pydcov",
    "maintainer": "Ethan Li",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "coverage, incremental, c, cpp, cmake, testing, gcov, llvm-cov",
    "author": "Ethan Li",
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "# PyDCov - Incremental C/C++ Code Coverage Tools\n\n[![PyPI version](https://badge.fury.io/py/pydcov.svg)](https://badge.fury.io/py/pydcov)\n[![Python Support](https://img.shields.io/pypi/pyversions/pydcov.svg)](https://pypi.org/project/pydcov/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA streamlined incremental coverage tracking system for CMake-based C/C++ projects. PyDCov provides modern Python tools for incremental coverage collection and reporting with support for both GCC/gcov and Clang/llvm-cov toolchains, plus CMake integration setup.\n\n## Features\n\n- **Cross-platform support**: Linux, macOS, Windows\n- **Multiple compiler support**: GCC/gcov and Clang/llvm-cov\n- **CMake integration**: Seamless integration with CMake build systems\n- **Incremental coverage**: Efficient incremental collection and reporting\n- **Framework-agnostic**: Works with any testing framework (pytest, unittest, custom executables)\n- **Modern Python API**: Clean, well-documented Python interface\n\n## Installation\n\n### Python Package\n\n```bash\npip install pydcov\n```\n\n### Standalone Executables\n\nPre-built standalone executables are available for Linux and macOS from the [GitHub Releases](https://github.com/ethan-li/pydcov/releases) page. These executables don't require Python to be installed on the target system.\n\n- **Linux (x64)**: `pydcov-linux-x64`\n- **macOS (ARM64)**: `pydcov-macos-arm64`\n\n### System Requirements\n\nPyDCov requires the following system tools to be installed:\n\n**Build Tools:**\n- CMake (3.10 or later)\n- Make or Ninja\n- GCC or Clang compiler\n\n**Coverage Tools (choose one):**\n\nFor GCC:\n```bash\n# Ubuntu/Debian\nsudo apt-get install gcc gcov lcov\n\n# macOS\nbrew install gcc lcov\n```\n\nFor Clang:\n```bash\n# Ubuntu/Debian  \nsudo apt-get install clang llvm\n\n# macOS\nbrew install llvm\n```\n\n## Quick Start\n\n### 1. Initialize CMake Integration\n\nIn your C/C++ project directory:\n\n```bash\npydcov init-cmake\n```\n\nThis copies the CMake integration files to your project.\n\n### 2. Update CMakeLists.txt\n\nAdd this line to your root CMakeLists.txt:\n\n```cmake\ninclude(cmake/coverage.cmake)\n```\n\n### 3. Run Incremental Coverage\n\n```bash\n# Initialize incremental tracking\npydcov init\n\n# Add coverage data from test runs\npydcov add python -m pytest tests/test_module1.py\npydcov add python -m pytest tests/test_module2.py\n\n# Generate combined report\npydcov report\n```\n\n## Command Reference\n\n### Incremental Coverage Commands\n\n```bash\npydcov init                          # Initialize incremental tracking\npydcov init --pydcov-dir /path/data  # Initialize with custom coverage directory\npydcov add python -m pytest tests/  # Add coverage data from test run\npydcov merge                         # Merge coverage data\npydcov report                        # Generate incremental report\npydcov status                        # Show incremental status\npydcov clean                         # Clean all coverage data\n```\n\n### Utility Commands\n\n```bash\npydcov init-cmake              # Copy CMake integration files\npydcov --version               # Show version\npydcov --help                  # Show help\n```\n\n## Python API\n\nPyDCov can also be used programmatically:\n\n```python\nfrom pydcov import IncrementalCoverageManager\n\n# Incremental coverage workflow\nmanager = IncrementalCoverageManager()\nmanager.init()\nmanager.add([\"python\", \"-m\", \"pytest\", \"tests/module1/\"])\nmanager.add([\"python\", \"-m\", \"pytest\", \"tests/module2/\"])\nmanager.merge()\nmanager.report()\n```\n\n## CMake Integration\n\nPyDCov provides a comprehensive CMake module that automatically:\n\n- Detects available compilers and coverage tools\n- Configures appropriate coverage flags\n- Creates coverage targets (`coverage-clean`, `coverage-report`)\n- Supports both GCC/gcov and Clang/llvm-cov workflows\n- Integrates with incremental coverage collection\n\nExample CMakeLists.txt:\n\n```cmake\ncmake_minimum_required(VERSION 3.10)\nproject(MyProject)\n\n# Include PyDCov coverage support\ninclude(cmake/coverage.cmake)\n\n# Your project configuration\nadd_executable(my_app src/main.cpp)\n\n# Coverage will be automatically configured\n```\n\n## Examples\n\n### Basic C++ Project\n\n```bash\n# Setup\nmkdir my-cpp-project && cd my-cpp-project\npydcov init-cmake\n\n# Create CMakeLists.txt with coverage support\necho 'cmake_minimum_required(VERSION 3.10)\nproject(MyApp)\ninclude(cmake/coverage.cmake)\nadd_executable(my_app main.cpp)' > CMakeLists.txt\n\n# Run coverage\npydcov init\npydcov add python -m pytest tests/\npydcov report\n```\n\n### Integration with CI/CD\n\n```yaml\n# GitHub Actions example\n- name: Install PyDCov\n  run: pip install pydcov\n\n- name: Setup coverage\n  run: pydcov init-cmake\n\n- name: Run coverage\n  run: |\n    pydcov init\n    pydcov add python -m pytest tests/\n    pydcov report\n```\n\n## Troubleshooting\n\n### Common Issues\n\n**\"Coverage tools not found\"**\n- Install GCC/gcov or Clang/llvm-cov\n- Ensure tools are in PATH\n\n**\"CMake configuration failed\"**\n- Verify CMake is installed and accessible\n- Check that `include(cmake/coverage.cmake)` is in CMakeLists.txt\n\n**\"No coverage data found\"**\n- Ensure tests are actually running\n- Verify executables are built with coverage flags\n\n### Getting Help\n\n- Check the [documentation](https://github.com/ethan-li/pydcov)\n- Report issues on [GitHub](https://github.com/ethan-li/pydcov/issues)\n\n## License\n\nMIT License. See LICENSE file for details.\n\n## Contributing\n\nContributions are welcome! Please see the contributing guidelines in the repository.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Incremental C/C++ code coverage tools for CMake projects",
    "version": "1.0.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/ethan-li/pydcov/issues",
        "Documentation": "https://github.com/ethan-li/pydcov/blob/main/README.md",
        "Homepage": "https://github.com/ethan-li/pydcov",
        "Repository": "https://github.com/ethan-li/pydcov.git"
    },
    "split_keywords": [
        "coverage",
        " incremental",
        " c",
        " cpp",
        " cmake",
        " testing",
        " gcov",
        " llvm-cov"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2f4c08303b187642630c32e9ad9abd2391f6d85edb7fc4750b4d90e21edeaa41",
                "md5": "67613e75b8cb6915dff619d9e22b9383",
                "sha256": "752d82a8cbf593d9287edb8192d0a136bddbf0ded51a3cb56f0f534bf2f81cc6"
            },
            "downloads": -1,
            "filename": "pydcov-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "67613e75b8cb6915dff619d9e22b9383",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 39817,
            "upload_time": "2025-10-15T21:42:10",
            "upload_time_iso_8601": "2025-10-15T21:42:10.259980Z",
            "url": "https://files.pythonhosted.org/packages/2f/4c/08303b187642630c32e9ad9abd2391f6d85edb7fc4750b4d90e21edeaa41/pydcov-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-15 21:42:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ethan-li",
    "github_project": "pydcov",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pytest",
            "specs": [
                [
                    ">=",
                    "7.0.0"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    ">=",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "pytest-xdist",
            "specs": [
                [
                    ">=",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "pytest-html",
            "specs": [
                [
                    ">=",
                    "3.1.0"
                ]
            ]
        },
        {
            "name": "coverage",
            "specs": [
                [
                    ">=",
                    "7.0.0"
                ]
            ]
        }
    ],
    "lcname": "pydcov"
}
        
Elapsed time: 1.97156s