Skip to content

Commit

Permalink
Add test rust coverage cmd to Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
torymur committed Nov 13, 2024
1 parent 334dab0 commit 527f952
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ benchmarks/results
# Remove doc build folders
.cache/
build/

rust-coverage/
target/
*.so
*.pyd
Expand Down
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Optional target to test/benchmark.
TARGET ?=
TARPAULIN_INSTALLED := $(shell command -v cargo-tarpaulin > /dev/null && echo 1 || echo 0)

.ONESHELL:
.PHONY: venv setup install install-release build-extension-debug build-extension-release watch-extension watch-extension-release pcc test test-rust test-python bench pybench doc dist clean check-clean-git
.PHONY: venv setup install install-release build-extension-debug build-extension-release watch-extension watch-extension-release pcc test test-rust test-python bench pybench doc dist clean check-clean-git check-tarpaulin test-rust-cov
.SILENT:

# Create a fresh virtual environment with the latest pip.
Expand Down Expand Up @@ -59,6 +60,26 @@ test-python: build-extension-debug
--cov=outlines_core \
--cov-report=term-missing:skip-covered

# Check if tarpaulin needs to be installed first.
check-tarpaulin:
ifeq ($(TARPAULIN_INSTALLED), 0)
@echo "cargo-tarpaulin is not found, installing..."
cargo install cargo-tarpaulin
else
@echo "cargo-tarpaulin is already installed"
endif

# Run rust tests with coverage report.
test-rust-cov: check-tarpaulin
RUSTFLAGS="-C instrument-coverage" cargo tarpaulin \
--out=Lcov \
--output-dir=rust-coverage \
--engine=llvm \
--exclude-files=src/python_bindings/* \
--no-dead-code \
--workspace \
--verbose

# Run rust benchmarks.
bench:
ifeq ($(TARGET),)
Expand Down

0 comments on commit 527f952

Please sign in to comment.