.SUFFIXES:
.PHONY: help test coverage coverage-html coverage-clean mutants mutants-quick clean build release lint format check \
tier1 tier2 tier3 chaos-test chaos-full check-regression fuzz benchmark install-llvm verify-llvm
install-llvm:
@echo "๐ง Installing LLVM/Clang development libraries..."
@if [ -f /etc/debian_version ]; then \
echo "๐ฆ Detected Debian/Ubuntu"; \
sudo apt-get update; \
sudo apt-get install -y llvm-14-dev libclang-14-dev clang-14 build-essential pkg-config; \
echo "๐ Setting up LLVM environment variables..."; \
if ! grep -q "LLVM_CONFIG_PATH" ~/.zshrc; then \
echo 'export LLVM_CONFIG_PATH=/usr/bin/llvm-config-14' >> ~/.zshrc; \
fi; \
if ! grep -q "LIBCLANG_PATH" ~/.zshrc; then \
echo 'export LIBCLANG_PATH=/usr/lib/llvm-14/lib' >> ~/.zshrc; \
fi; \
export LLVM_CONFIG_PATH=/usr/bin/llvm-config-14; \
export LIBCLANG_PATH=/usr/lib/llvm-14/lib; \
echo "โ
LLVM/Clang libraries installed"; \
echo "โ ๏ธ Run 'source ~/.zshrc' to reload environment"; \
elif [ -f /etc/redhat-release ]; then \
echo "๐ฆ Detected RHEL/CentOS/Fedora"; \
sudo yum install -y llvm-devel clang-devel || sudo dnf install -y llvm-devel clang-devel; \
echo "โ
LLVM/Clang libraries installed"; \
elif [ "$$(uname)" = "Darwin" ]; then \
echo "๐ฆ Detected macOS"; \
brew install llvm; \
echo "๐ Setting up LLVM environment variables..."; \
if ! grep -q "LLVM_CONFIG_PATH" ~/.zshrc; then \
echo 'export PATH="/usr/local/opt/llvm/bin:$$PATH"' >> ~/.zshrc; \
echo 'export LDFLAGS="-L/usr/local/opt/llvm/lib"' >> ~/.zshrc; \
echo 'export CPPFLAGS="-I/usr/local/opt/llvm/include"' >> ~/.zshrc; \
echo 'export LIBCLANG_PATH=/usr/local/opt/llvm/lib' >> ~/.zshrc; \
fi; \
echo "โ
LLVM/Clang libraries installed"; \
echo "โ ๏ธ Run 'source ~/.zshrc' to reload environment"; \
else \
echo "โ Unsupported platform. Please install LLVM/Clang manually."; \
exit 1; \
fi
verify-llvm:
@echo "๐ Verifying LLVM/Clang installation..."
@echo ""
@if command -v llvm-config >/dev/null 2>&1 || command -v llvm-config-14 >/dev/null 2>&1; then \
echo "โ
LLVM found:"; \
llvm-config-14 --version 2>/dev/null || llvm-config --version; \
else \
echo "โ LLVM not found"; \
fi
@echo ""
@if [ -n "$$LLVM_CONFIG_PATH" ]; then \
echo "โ
LLVM_CONFIG_PATH: $$LLVM_CONFIG_PATH"; \
else \
echo "โ ๏ธ LLVM_CONFIG_PATH not set"; \
fi
@echo ""
@if [ -n "$$LIBCLANG_PATH" ]; then \
echo "โ
LIBCLANG_PATH: $$LIBCLANG_PATH"; \
if [ -d "$$LIBCLANG_PATH" ]; then \
echo "โ
libclang directory exists"; \
ls -la "$$LIBCLANG_PATH"/libclang.so* 2>/dev/null || echo "โ ๏ธ libclang.so not found"; \
else \
echo "โ libclang directory does not exist"; \
fi; \
else \
echo "โ ๏ธ LIBCLANG_PATH not set"; \
fi
help:
@echo "Renacer - Pure Rust strace alternative"
@echo ""
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
test:
@echo "๐งช Running tests..."
@cargo test --quiet
test-fast:
@echo "๐งช Running fast tests with nextest..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
PROPTEST_CASES=25 RUST_TEST_THREADS=$$(nproc) cargo nextest run \
--workspace \
--status-level skip \
--failure-output immediate; \
else \
echo "โ ๏ธ cargo-nextest not found. Installing..."; \
cargo install cargo-nextest; \
PROPTEST_CASES=25 RUST_TEST_THREADS=$$(nproc) cargo nextest run \
--workspace \
--status-level skip \
--failure-output immediate; \
fi
coverage:
@echo "๐ Running comprehensive test coverage analysis..."
@echo "๐ Checking for cargo-llvm-cov..."
@which cargo-llvm-cov > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-llvm-cov..." && cargo install cargo-llvm-cov --locked)
@if ! rustup component list --installed | grep -q llvm-tools-preview; then \
echo "๐ฆ Installing llvm-tools-preview..."; \
rustup component add llvm-tools-preview; \
fi
@echo "๐ Detecting GPU hardware..."
@GPU_FEATURES=""; \
if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi >/dev/null 2>&1; then \
echo "โ
NVIDIA GPU detected - enabling gpu-tracing and cuda-tracing features"; \
GPU_FEATURES="--features gpu-tracing,cuda-tracing"; \
export CUDA_VISIBLE_DEVICES=0; \
else \
echo "โ ๏ธ No NVIDIA GPU detected - running without GPU features"; \
GPU_FEATURES=""; \
fi; \
echo "๐งน Cleaning old coverage data..."; \
mkdir -p target/coverage/html; \
echo "๐งช Phase 1: Running tests with instrumentation (reduced proptest cases)..."; \
PROPTEST_CASES=20 RUST_TEST_THREADS=$$(nproc) timeout 600 cargo llvm-cov --no-report test --workspace $$GPU_FEATURES || true; \
echo "๐ Phase 2: Generating coverage reports..."; \
cargo llvm-cov report --html --output-dir target/coverage/html || echo "โ ๏ธ No coverage data generated"; \
cargo llvm-cov report --lcov --output-path target/coverage/lcov.info || echo "โ ๏ธ LCOV generation skipped"; \
echo ""; \
echo "๐ Coverage Summary:"; \
cargo llvm-cov report --summary-only || echo "Run 'cargo test' to generate coverage data first"; \
echo ""; \
echo "๐ Coverage reports generated:"; \
echo "- HTML: target/coverage/html/index.html"; \
echo "- LCOV: target/coverage/lcov.info"; \
echo ""; \
xdg-open target/coverage/html/index.html 2>/dev/null || \
open target/coverage/html/index.html 2>/dev/null || \
echo "โ
Open target/coverage/html/index.html in your browser"
coverage-html: coverage
coverage-clean:
@echo "๐งน Cleaning coverage artifacts..."
@if command -v cargo-llvm-cov >/dev/null 2>&1; then \
echo "โ
Coverage artifacts cleaned!"; \
else \
echo "โ ๏ธ cargo-llvm-cov not installed, skipping clean."; \
fi
build:
@echo "๐จ Building debug binary..."
@cargo build
release:
@echo "๐ Building release binary..."
@cargo build --release
@echo "โ
Release binary: target/release/renacer"
lint:
@echo "๐ Running clippy..."
@cargo clippy -- -D warnings
format:
@echo "๐ Formatting code..."
@cargo fmt
check:
@echo "โ
Type checking..."
@cargo check --all-targets --all-features
clean:
@echo "๐งน Cleaning build artifacts..."
@cargo clean
@rm -rf target/coverage
@echo "โ
Clean completed!"
benchmark:
@echo "๐ Running benchmarks..."
@cargo test --test benchmark_vs_strace -- --nocapture --test-threads=1
mutants:
@echo "๐งฌ Running mutation testing..."
@echo "๐ Checking for cargo-mutants..."
@which cargo-mutants > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-mutants..." && cargo install cargo-mutants --locked)
@echo "๐งฌ Running cargo-mutants (this may take several minutes)..."
@cargo mutants --output target/mutants.out || echo "โ ๏ธ Some mutants survived"
@echo ""
@echo "๐ Mutation Testing Results:"
@cat target/mutants.out/mutants.out 2>/dev/null || echo "Check target/mutants.out/ for detailed results"
mutants-quick:
@echo "๐งฌ Running quick mutation testing..."
@echo "๐ Checking for cargo-mutants..."
@which cargo-mutants > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-mutants..." && cargo install cargo-mutants --locked)
@echo "๐งฌ Running cargo-mutants on uncommitted changes..."
@cargo mutants --in-diff git:HEAD --output target/mutants-quick.out || echo "โ ๏ธ Some mutants survived"
@echo ""
@echo "๐ Quick Mutation Testing Results:"
@cat target/mutants-quick.out/mutants.out 2>/dev/null || echo "Check target/mutants-quick.out/ for detailed results"
tier1:
@echo "๐ Tier 1: Fast tests (<5 seconds)..."
@cargo fmt --check
@cargo clippy -- -D warnings
@cargo test --lib --quiet
@echo "โ
Tier 1 complete!"
tier2: tier1
@echo "๐ Tier 2: Integration tests (<30 seconds)..."
@cargo test --tests --quiet
@echo "โ
Tier 2 complete!"
tier3: tier2
@echo "๐ Tier 3: Full validation (<5 minutes)..."
@cargo test --all-targets --all-features --quiet
@echo "โ
Tier 3 complete!"
chaos-test:
@echo "๐ฅ Running chaos engineering tests..."
@cargo test --features chaos-basic --quiet
@echo "โ
Chaos basic tests complete!"
chaos-full:
@echo "๐ฅ Running full chaos engineering suite..."
@cargo test --features chaos-full --quiet
@echo "โ
Full chaos tests complete!"
check-regression:
@echo "๐ Checking for performance regressions..."
@ruchy scripts/check_regression.ruchy || echo "โ ๏ธ Regression check failed or ruchy not found"
fuzz:
@echo "๐ฒ Running fuzz tests..."
@echo "๐ Checking for cargo-fuzz..."
@which cargo-fuzz > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-fuzz..." && cargo install cargo-fuzz --locked)
@cargo +nightly fuzz run filter_parser -- -max_total_time=60 || echo "โ ๏ธ Fuzz testing requires nightly toolchain"
diff-test:
@echo "๐ฌ Running differential tests (Renacer vs strace)..."
@cargo test --test differential_strace_tests --quiet || echo "โ ๏ธ Differential tests not yet implemented"