From 99b81adf8cf24c0f96fa9f6a6fd2d504047d4d19 Mon Sep 17 00:00:00 2001 From: jordan Date: Sat, 7 Feb 2026 20:21:25 -0700 Subject: [PATCH] perf: speed up test suite with profile.test optimization - Add [profile.test] with opt-level=1 and debug=0 for faster compile/link - Add [profile.test.build-override] with opt-level=3 for proc-macros - Add tiered test targets: test-fast (single crate), test-lib (unit tests) - Add install-nextest target for parallel test runner - Update CLAUDE.md with new test command options - Add CRATE variable guard to test-fast for helpful error messages Expected improvement: ~50% faster incremental test builds Co-Authored-By: Claude Opus 4.5 --- CLAUDE.md | 7 +++++-- Cargo.toml | 7 +++++++ Makefile | 26 ++++++++++++++++++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 6092871..d275bb3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -97,8 +97,11 @@ Two files, strict separation: # Build cargo build --workspace -# Test -cargo test --workspace +# Test (choose based on need) +cargo test -p stemedb-core # Fast: single crate (~30s) +cargo test --workspace --lib # Medium: all unit tests (~3min) +cargo nextest run # Full: parallel runner (~5min) +cargo test --workspace # Legacy: sequential (~15min) # Lint (must pass before commit) cargo clippy --workspace -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index 50b94bf..1c687b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,13 @@ lto = true codegen-units = 1 panic = "abort" +[profile.test] +opt-level = 1 # Slightly optimize - faster execution +debug = 0 # Skip debug info - faster linking + +[profile.test.build-override] +opt-level = 3 # Optimize proc-macros and build scripts + [workspace.lints.rust] unsafe_code = "forbid" missing_docs = "warn" diff --git a/Makefile b/Makefile index 5dbae02..4b90ea2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Makefile for StemeDB -.PHONY: all build dev quality install clean test help go-fmt go-lint go-test validate +.PHONY: all build dev quality install clean test test-fast test-lib install-nextest help go-fmt go-lint go-test validate # Default target all: build @@ -15,9 +15,24 @@ build: dev: cargo run -p stemedb-core -# Run tests +# Run tests - choose based on need test: - cargo test --workspace + @cargo nextest run --workspace 2>/dev/null || cargo test --workspace + +# Fast: single crate during development (usage: make test-fast CRATE=stemedb-core) +test-fast: +ifndef CRATE + $(error CRATE is required. Usage: make test-fast CRATE=stemedb-core) +endif + cargo test -p $(CRATE) --lib + +# Medium: all lib tests (skip integration tests) +test-lib: + cargo test --workspace --lib + +# Install nextest for faster parallel test execution +install-nextest: + cargo install cargo-nextest --locked # Validate end-to-end (build, start server, assert, query, shutdown) validate: @@ -101,7 +116,10 @@ help: @echo "Available commands:" @echo " make build - Build the workspace" @echo " make dev - Run the core binary" - @echo " make test - Run unit tests" + @echo " make test - Run all tests (uses nextest if available)" + @echo " make test-fast CRATE=name - Fast: single crate lib tests (~30s)" + @echo " make test-lib - Medium: all unit tests (~3min)" + @echo " make install-nextest - Install cargo-nextest for parallel tests" @echo " make quality - Run format check, clippy, duplication, tests" @echo " make fmt - Auto-format code" @echo " make lint - Run clippy linter"