.SUFFIXES:
.DELETE_ON_ERROR:
.ONESHELL:
.PHONY: help build test test-fast test-quick test-cuda test-viz coverage coverage-ci coverage-check coverage-clean clean-coverage bench bench-ptx lint fmt clean all
test:
cargo test -p trueno-gpu --all-features -- --nocapture
test-fast:
@echo "โก Running fast tests for trueno-gpu (target: <2 min)..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
PROPTEST_CASES=50 RUST_TEST_THREADS=$$(nproc) cargo nextest run \
-p trueno-gpu \
--status-level skip \
--failure-output immediate; \
else \
PROPTEST_CASES=50 cargo test -p trueno-gpu; \
fi
test-quick: test-fast
@echo "โ
Quick tests completed!"
test-cuda:
@echo "๐ฅ๏ธ Running CUDA tests (requires NVIDIA driver)..."
cargo test -p trueno-gpu --features cuda -- --nocapture
test-viz:
@echo "๐จ Running visual tests..."
cargo test -p trueno-gpu --features viz -- --nocapture
test-stress:
@echo "๐ฅ Running stress tests..."
cargo test -p trueno-gpu --features stress-test -- stress --nocapture
coverage:
@echo "๐ Running coverage analysis for trueno-gpu (target: <5 min)..."
@echo "๐ Checking for cargo-llvm-cov and cargo-nextest..."
@which cargo-llvm-cov > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-llvm-cov..." && cargo install cargo-llvm-cov --locked)
@which cargo-nextest > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-nextest..." && cargo install cargo-nextest --locked)
@echo "๐งน Cleaning old coverage data..."
@cargo llvm-cov clean --workspace
@mkdir -p target/coverage
@echo "โ๏ธ Temporarily disabling global cargo config (mold breaks coverage)..."
@test -f ~/.cargo/config.toml && mv ~/.cargo/config.toml ~/.cargo/config.toml.cov-backup || true
@echo "๐งช Phase 1: Running tests with instrumentation (no report)..."
@ @env PROPTEST_CASES=100 cargo llvm-cov --no-report --ignore-filename-regex '(benches/|demos/|examples/|tests/|pkg/|test_output/|docs/|driver/memory\.rs|driver/module\.rs|driver/stream\.rs|wasm\.rs)' nextest --no-tests=warn -p trueno-gpu --all-features
@echo "๐ Phase 2: Generating coverage reports..."
@ @cargo llvm-cov report --html --output-dir target/coverage/html --ignore-filename-regex '(driver/memory\.rs|driver/module\.rs|driver/stream\.rs|wasm\.rs)'
@cargo llvm-cov report --lcov --output-path target/coverage/lcov.info --ignore-filename-regex '(driver/memory\.rs|driver/module\.rs|driver/stream\.rs|wasm\.rs)'
@echo "โ๏ธ Restoring global cargo config..."
@test -f ~/.cargo/config.toml.cov-backup && mv ~/.cargo/config.toml.cov-backup ~/.cargo/config.toml || true
@echo ""
@echo "๐ Coverage Summary:"
@echo "=================="
@cargo llvm-cov report --summary-only --ignore-filename-regex '(driver/memory\.rs|driver/module\.rs|driver/stream\.rs|wasm\.rs)'
@echo ""
@echo "๐ก COVERAGE INSIGHTS:"
@echo "- HTML report: target/coverage/html/index.html"
@echo "- LCOV file: target/coverage/lcov.info"
@echo "- Open HTML: make coverage-open"
@echo ""
coverage-ci:
@echo "=== Code Coverage for CI/CD (โฅ95% required) ==="
@cargo llvm-cov clean --workspace
@test -f ~/.cargo/config.toml && mv ~/.cargo/config.toml ~/.cargo/config.toml.cov-backup || true
@ @env PROPTEST_CASES=100 cargo llvm-cov --no-report --ignore-filename-regex '(benches/|demos/|examples/|tests/|pkg/|test_output/|docs/|driver/memory\.rs|driver/module\.rs|driver/stream\.rs|wasm\.rs)' nextest --no-tests=warn -p trueno-gpu --all-features
@cargo llvm-cov report --lcov --output-path lcov.info
@test -f ~/.cargo/config.toml.cov-backup && mv ~/.cargo/config.toml.cov-backup ~/.cargo/config.toml || true
@echo "โ Coverage report generated: lcov.info"
coverage-check:
@echo "๐ Enforcing 95% coverage threshold for trueno-gpu..."
@test -f ~/.cargo/config.toml && mv ~/.cargo/config.toml ~/.cargo/config.toml.cov-backup || true
@cargo llvm-cov -p trueno-gpu --all-features --ignore-filename-regex '(benches/|demos/|examples/|tests/|pkg/|test_output/|docs/)' --lcov --output-path lcov.info > /dev/null 2>&1
@test -f ~/.cargo/config.toml.cov-backup && mv ~/.cargo/config.toml.cov-backup ~/.cargo/config.toml || true
@COVERAGE=$$(cargo llvm-cov report --summary-only 2>/dev/null | grep "TOTAL" | awk '{print $$NF}' | sed 's/%//'); \
echo "trueno-gpu coverage: $${COVERAGE}%"; \
if [ $$(echo "$$COVERAGE < 95" | bc -l 2>/dev/null || echo 1) -eq 1 ]; then \
echo "โ FAIL: Coverage below 95% threshold"; \
exit 1; \
else \
echo "โ
Coverage threshold met (โฅ95%)"; \
fi
coverage-clean:
@cargo llvm-cov clean --workspace
@rm -f lcov.info target/coverage/lcov.info
@rm -rf target/llvm-cov target/coverage
@find . -name "*.profraw" -delete
@echo "โ Coverage artifacts cleaned"
clean-coverage: coverage-clean
@echo "โ Fresh coverage ready"
bench:
cargo bench -p trueno-gpu --no-fail-fast
bench-ptx:
@echo "๐ Running PTX generation benchmarks..."
cargo bench -p trueno-gpu --bench ptx_gen --no-fail-fast
build:
cargo build -p trueno-gpu
build-release:
cargo build -p trueno-gpu --release
build-wasm:
@echo "๐ Building for WASM..."
cargo build -p trueno-gpu --target wasm32-unknown-unknown --features wasm
lint:
@echo "๐ Running clippy for trueno-gpu..."
cargo clippy -p trueno-gpu --all-features -- -D warnings
fmt:
cargo fmt -p trueno-gpu
fmt-check:
cargo fmt -p trueno-gpu -- --check
clean:
cargo clean -p trueno-gpu
rm -f lcov.info
find . -name "*.profraw" -delete
all: lint test-fast
@echo "โ
All checks passed!"
help:
@echo 'trueno-gpu Development Commands:'
@echo ''
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help