cargo-llvm-cov
БесплатноБез исполняемых скриптовНе проверенcargo-llvm-cov: Rust code coverage with LLVM instrumentation. Use when measuring coverage, enforcing thresholds, generating reports, or integrating…
Об этом скилле
cargo-llvm-cov - Code Coverage with LLVM
cargo-llvm-cov provides accurate code coverage for Rust using LLVM's instrumentation-based coverage. It supports multiple output formats and integrates seamlessly with CI platforms.
When to Use This Skill
| Use this skill when... | Use sibling skill instead when... |
|---|---|
| Measuring line / branch coverage with LLVM instrumentation | Just running tests fast in parallel -- use cargo-nextest |
| Generating HTML / lcov / codecov reports | Auditing unused dependencies -- use cargo-machete |
| Enforcing coverage thresholds in CI | Configuring lint rules -- use clippy-advanced |
| Wiring codecov.io or coveralls upload | Writing the tests themselves -- use rust-development |
Installation
# Install cargo-llvm-cov
cargo install cargo-llvm-cov
# Verify installation
cargo llvm-cov --version
# Install llvm-tools-preview component (required)
rustup component add llvm-tools-preview
Basic Usage
# Run tests and generate coverage
cargo llvm-cov
# Generate HTML report
cargo llvm-cov --html
open target/llvm-cov/html/index.html
# Generate LCOV report
cargo llvm-cov --lcov --output-path target/llvm-cov/lcov.info
# Generate JSON report
cargo llvm-cov --json --output-path target/llvm-cov/coverage.json
# Show coverage as text summary
cargo llvm-cov --text
# Show coverage for specific files
cargo llvm-cov --text -- --show-instantiations
Output Formats
# HTML report (interactive, line-by-line)
cargo llvm-cov --html --open
# LCOV format (compatible with many tools)
cargo llvm-cov --lcov --output-path lcov.info
# JSON format (programmatic analysis)
cargo llvm-cov --json --output-path coverage.json
# Cobertura XML (for Jenkins, GitLab)
cargo llvm-cov --cobertura --output-path cobertura.xml
# Text summary (terminal output)
cargo llvm-cov --text
# Multiple formats simultaneously
cargo llvm-cov --html --lcov --output-path lcov.info
Coverage Thresholds for CI
# Fail if coverage is below threshold
cargo llvm-cov --fail-under-lines 80
# Multiple threshold types
cargo llvm-cov --fail-under-lines 80 --fail-under-functions 75
# Available threshold types
cargo llvm-cov --fail-under-lines 80 # Line coverage
cargo llvm-cov --fail-under-regions 80 # Region coverage
cargo llvm-cov --fail-under-functions 75 # Function coverage
Threshold Configuration
Create a script or Makefile for consistent thresholds:
# Makefile
.PHONY: coverage coverage-ci
coverage:
cargo llvm-cov --html --open
coverage-ci:
cargo llvm-cov \
--fail-under-lines 80 \
--fail-under-functions 75 \
--lcov --output-path lcov.info
Or use a shell script:
#!/usr/bin/env bash
# scripts/coverage.sh
set -euo pipefail
COVERAGE_THRESHOLD="${COVERAGE_THRESHOLD:-80}"
cargo llvm-cov \
--fail-under-lines "$COVERAGE_THRESHOLD" \
--lcov --output-path target/llvm-cov/lcov.info \
--html
echo "Coverage threshold: $COVERAGE_THRESHOLD% (lines)"
Branch Coverage (Nightly)
Branch coverage requires Rust nightly:
# Install nightly toolchain
rustup toolchain install nightly
rustup component add llvm-tools-preview --toolchain nightly
# Run with branch coverage
cargo +nightly llvm-cov --branch --html
# Branch coverage with thresholds
cargo +nightly llvm-cov \
--branch \
--fail-under-lines 80 \
--fail-under-branches 70
Branch Coverage Configuration
# rust-toolchain.toml
[toolchain]
channel = "nightly"
components = ["llvm-tools-preview"]
# Allows using `cargo llvm-cov --branch` without +nightly
Integration with cargo-nextest
# Use nextest as test runner
cargo llvm-cov nextest --html
# With nextest profile
cargo llvm-cov nextest --profile ci --lcov --output-path lcov.info
# All nextest options work
cargo llvm-cov nextest -E 'not test(slow_)' --html
Codecov Integration
# .github/workflows/coverage.yml
name: Coverage
on: [push, pull_request]
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Install the pinned toolchain
run: rustup toolchain install --no-self-update
- name: Add llvm-tools to the pinned toolchain
run: rustup component add llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/[email protected]
with:
tool: cargo-llvm-cov
- name: Generate coverage
run: cargo llvm-cov --all-features --lcov --output-path lcov.info
- name: Upload to codecov
uses: codecov/[email protected]
with:
files: lcov.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
Coveralls Integration
Same workflow as Codecov, with the upload step swapped for coverallsapp/github-action (path-to-lcov: lcov.info): REFERENCE.md.
Advanced Configuration
Exclude Files from Coverage
# Exclude gen
Установить cargo-llvm-cov в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Bash(cargo llvm-cov *)Bash(cargo +nightly llvm-cov *)Bash(cargo clean *)ReadGrepGlobВложенные файлы
FAQ
Что делает скилл cargo-llvm-cov?
cargo-llvm-cov: Rust code coverage with LLVM instrumentation. Use when measuring coverage, enforcing thresholds, generating reports, or integrating codecov/coveralls.
Как установить скилл cargo-llvm-cov?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cargo-llvm-cov запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic