https://github.com/orbl/rusty_coverage_output_generator
Drop-in replacement for Bazels original java based CoverageOutputGenerator
https://github.com/orbl/rusty_coverage_output_generator
bazel coverage rust
Last synced: about 1 month ago
JSON representation
Drop-in replacement for Bazels original java based CoverageOutputGenerator
- Host: GitHub
- URL: https://github.com/orbl/rusty_coverage_output_generator
- Owner: orbl
- License: mit
- Created: 2025-06-26T16:13:22.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-30T12:26:33.000Z (12 months ago)
- Last Synced: 2025-09-26T16:44:53.453Z (9 months ago)
- Topics: bazel, coverage, rust
- Language: Rust
- Homepage: https://github.com/orbl/rusty_coverage_output_generator
- Size: 110 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rusty Coverage Output Generator
A fast, drop-in replacement for Bazel's CoverageOutputGenerator written in Rust.
## Overview
This tool merges and processes coverage data from multiple formats (LCOV, gcov text, gcov JSON) into a unified LCOV output format. It's designed to be a high-performance alternative to the Java-based CoverageOutputGenerator used in Bazel builds.
## Features
### Core Capabilities
- **Multiple Format Support**: LCOV, gcov text format, and gcov JSON format
- **High Performance**: Parallel processing with Rayon for fast merging of large coverage datasets
- **100% Java Compatibility**: Produces identical output to the original Java implementation
- **GZIP Support**: Automatic detection and decompression of compressed coverage files
- **Robust Error Handling**: Comprehensive validation and clear error messages
- **CLI Compatible**: Drop-in replacement with identical command-line interface
### Changes from Original
- **Dropped Features**:
- Serial processing (this version uses parallel processing only)
- BA line records (not valid LCOV format)
## Supported Formats
### Input Formats
- **LCOV**: Standard Linux Test Project format
- **gcov Text**: Traditional gcov intermediate format
- **gcov JSON**: Modern JSON-based gcov format
- **Compressed Files**: Automatic GZIP decompression
### Output Format
- **LCOV**: Industry-standard format compatible with all major coverage tools
## Usage
### Quick Start with Bazel
For quick testing, add this to your root `MODULE.bazel` and create an alias in your build file. Then run bazel coverage with `--coverage_report_generator=//:coverage_report_generator`:
**MODULE.bazel**
```starlark
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rusty_coverage_output_generator",
sha256 = "21625bed96e0c3856dd12d2ea6d0cf5d7c459fb66024cab3bc6bfdffe0e782f2",
urls = [
"https://github.com/orbl/rusty_coverage_output_generator/releases/download/v1.0/coverage_output_generator_release.tar",
],
)
```
**BUILD**
```starlark
alias(
name = "coverage_report_generator",
actual = "@rusty_coverage_output_generator//:cog",
tags = ["manual"],
)
```
### Building Your Own Release
If you wish to make your own version, create the release tar by running:
```bash
bazel build coverage_output_generator_release
```
### Local Testing Setup
You can serve the file on localhost for quick testing:
```python
#!/usr/bin/env python3
from flask import Flask, send_file
app = Flask(__name__)
FILE_PATH = "bazel-bin/coverage_output_generator_release.tar"
@app.route('/bazel-bin/coverage_output_generator_release.tar')
def serve_file():
return send_file(FILE_PATH)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8000)
```
## Development Notes
- **Platform Support**: This has only been tested on Linux
- **Development**: Built with ChatGPT 4.1 and Claude Sonnet 4 with human intervention and oversight
- **Error Handling**: The original Java version allowed errors to pass with no warnings. This implementation is less forgiving, which should save you hours of debugging to find out why your coverage looks weird.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.