-
Notifications
You must be signed in to change notification settings - Fork 0
feat(make): add coverage targets with LCOV for editor integration #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| ## —— Coverage (cargo-llvm-cov) ---------------------------------------------------------------- | ||
| ## | ||
| ## Prerequisites: | ||
| ## cargo install cargo-llvm-cov | ||
| ## rustup component add llvm-tools-preview | ||
| ## | ||
| ## Doctests are not run under coverage (they require nightly). Use stable for unit/e2e coverage. | ||
| ## Optional: use COVERAGE_OUTPUT_DIR to change report dir (default: target/coverage) | ||
| ## | ||
| ## Use BFD linker for coverage builds when available to avoid LLD duplicate-symbol | ||
| ## errors with -C instrument-coverage (e.g. arrow_array/arrow_arith in datafusion). | ||
| ## If ld.bfd is not found, no linker override is set (may hit duplicate symbol on LLD). | ||
| ## Override: make coverage-unit COVERAGE_RUSTFLAGS="-C link-arg=-fuse-ld=bfd" | ||
|
|
||
| COVERAGE_RUSTFLAGS_DEFAULT := $(shell command -v ld.bfd >/dev/null 2>&1 && echo '-C link-arg=-fuse-ld=bfd' || true) | ||
| COVERAGE_RUSTFLAGS ?= $(COVERAGE_RUSTFLAGS_DEFAULT) | ||
| COVERAGE_OUTPUT_DIR ?= target/coverage | ||
| COVERAGE_E2E_DIR := $(COVERAGE_OUTPUT_DIR)/e2e | ||
| ## LCOV file for editor integration (Cursor/VS Code Coverage Gutters). Default: repo root. | ||
| COVERAGE_LCOV_PATH ?= lcov.info | ||
|
|
||
| .PHONY: coverage-check | ||
| coverage-check: ## Verify cargo-llvm-cov and llvm-tools are available | ||
| @cargo llvm-cov --version >/dev/null 2>&1 || (echo "Install: cargo install cargo-llvm-cov && rustup component add llvm-tools-preview"; exit 1) | ||
|
|
||
| .PHONY: coverage-deps | ||
| coverage-deps: ## Install cargo-llvm-cov and llvm-tools-preview if missing | ||
| @command -v cargo >/dev/null 2>&1 || (echo "cargo not found. Ensure Rust is installed and in PATH."; exit 1) | ||
| @cargo llvm-cov --version >/dev/null 2>&1 || \ | ||
| (echo "Installing coverage tools..."; cargo install cargo-llvm-cov && rustup component add llvm-tools-preview) | ||
| @cargo llvm-cov --version >/dev/null 2>&1 || (echo "Install failed. Run: cargo install cargo-llvm-cov && rustup component add llvm-tools-preview"; exit 1) | ||
|
|
||
| .PHONY: coverage-unit | ||
| coverage-unit: coverage-deps ## Run unit/integration tests with coverage (excludes e2e_test) | ||
| @echo "📊 Running unit/integration coverage..." | ||
| export RUSTFLAGS="$(COVERAGE_RUSTFLAGS)" && \ | ||
| cargo llvm-cov test --workspace --exclude e2e_test --no-fail-fast --no-report | ||
| export RUSTFLAGS="$(COVERAGE_RUSTFLAGS)" && \ | ||
| cargo llvm-cov report --lcov --output-path "$(COVERAGE_LCOV_PATH)" | ||
|
Comment on lines
+36
to
+39
|
||
| @echo "📄 LCOV (editor): $(COVERAGE_LCOV_PATH)" | ||
|
|
||
| .PHONY: coverage-e2e | ||
| coverage-e2e: coverage-deps ## Run e2e tests with coverage (e2e_test crate only) | ||
| @echo "📊 Running e2e coverage..." | ||
| @mkdir -p "$(COVERAGE_E2E_DIR)" | ||
| export RUSTFLAGS="$(COVERAGE_RUSTFLAGS)" && \ | ||
| cargo llvm-cov test -p e2e_test --no-fail-fast --no-report | ||
| export RUSTFLAGS="$(COVERAGE_RUSTFLAGS)" && \ | ||
| cargo llvm-cov report -p e2e_test --lcov --output-path "$(COVERAGE_E2E_DIR)/lcov.info" | ||
| @echo "📄 LCOV: $(COVERAGE_E2E_DIR)/lcov.info" | ||
|
|
||
| .PHONY: coverage-combined | ||
| coverage-combined: coverage-deps ## Run all tests (unit + e2e) with a single combined coverage report | ||
| @echo "📊 Running combined coverage (unit + e2e)..." | ||
| export RUSTFLAGS="$(COVERAGE_RUSTFLAGS)" && \ | ||
| cargo llvm-cov test --workspace --no-fail-fast --no-report | ||
| export RUSTFLAGS="$(COVERAGE_RUSTFLAGS)" && \ | ||
| cargo llvm-cov report --lcov --output-path "$(COVERAGE_LCOV_PATH)" | ||
| @echo "📄 LCOV (editor): $(COVERAGE_LCOV_PATH)" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| /target | ||
| lcov.info | ||
| .DS_Store | ||
| .idea | ||
| .vscode | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,88 @@ | ||||||||||
| # Development Guide | ||||||||||
|
|
||||||||||
| This page covers building, testing, and running quality checks for RustFS. For code formatting rules and PR expectations, see [CONTRIBUTING.md](../CONTRIBUTING.md). | ||||||||||
|
|
||||||||||
| ## Prerequisites | ||||||||||
|
|
||||||||||
| - Rust (see root [Cargo.toml](../Cargo.toml) `rust-version`) | ||||||||||
| - For full quality gates: `make` (see [.config/make/](../.config/make/) and root [Makefile](../Makefile)) | ||||||||||
|
|
||||||||||
| ## Build | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| # Build the RustFS binary | ||||||||||
| make build | ||||||||||
| # or | ||||||||||
| cargo build --release | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Testing | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| # Run tests | ||||||||||
| make test | ||||||||||
| # or | ||||||||||
| cargo test --all-targets | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Code Quality (Mandatory Before Commit) | ||||||||||
|
|
||||||||||
| Run all pre-commit checks: | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| make pre-commit | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| If `make` is unavailable, run the equivalent steps from [.config/make/](../.config/make/). Typical steps: | ||||||||||
|
|
||||||||||
| - Format: `cargo fmt --all` and `cargo fmt --all --check` | ||||||||||
| - Lint: `cargo clippy --all-targets --all-features -- -D warnings` | ||||||||||
| - Check: `cargo check --all-targets` | ||||||||||
| - Tests: `cargo test --all-targets` | ||||||||||
|
|
||||||||||
| See [CONTRIBUTING.md](../CONTRIBUTING.md) for detailed formatting and clippy rules. | ||||||||||
|
|
||||||||||
| ## Make Targets | ||||||||||
|
|
||||||||||
| - `make help` — Main help and categories | ||||||||||
| - `make help-build` — Build-related targets | ||||||||||
| - `make help-docker` — Docker and image targets | ||||||||||
| - `make fmt` / `make fmt-check` — Format and verify | ||||||||||
| - `make clippy` — Clippy | ||||||||||
| - `make check` — Compilation check | ||||||||||
|
Comment on lines
+51
to
+52
|
||||||||||
| - `make clippy` — Clippy | |
| - `make check` — Compilation check | |
| - `make clippy-check` — Clippy | |
| - `make compilation-check` — Compilation check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coverage-check/coverage-depsclaim to verify/install bothcargo-llvm-covandllvm-tools-preview, but the logic only checks whethercargo llvm-covexists. If a developer already hascargo-llvm-covinstalled but is missingllvm-tools-preview(orrustupitself), these targets can still pass the dependency step and then fail later duringcargo llvm-cov test/report. Update the checks to also verify the LLVM tools are available (e.g., viarustup which llvm-profdata/llvm-cov) and makerustup component add llvm-tools-previewrun when the component is missing, regardless of whethercargo-llvm-covis already installed.