From 6919b3dea647c67ee3372bbafdb0bec83be3a60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Mon, 3 Jul 2023 14:11:23 +0200 Subject: [PATCH] chore: run tests with coverage in `Makefile` (#3418) --- .gitignore | 5 ++++- Makefile | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index dd772483c..c2c144f4a 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,7 @@ dist/ db-tools/ # VSCode -.vscode \ No newline at end of file +.vscode + +# Coverage report +lcov.info diff --git a/Makefile b/Makefile index f024ccf55..d49d427b9 100644 --- a/Makefile +++ b/Makefile @@ -105,6 +105,23 @@ build-release-tarballs: ## Create a series of `.tar.gz` files in the BIN_DIR dir ##@ Test +UNIT_TEST_ARGS := --locked --workspace --all-features -E 'kind(lib)' -E 'kind(bin)' -E 'kind(proc-macro)' +COV_FILE := lcov.info + +.PHONY: test-unit +test-unit: ## Run unit tests. + cargo nextest run $(UNIT_TEST_ARGS) + +.PHONY: cov-unit +cov-unit: ## Run unit tests with coverage. + rm -f $(COV_FILE) + cargo llvm-cov nextest --lcov --output-path $(COV_FILE) $(UNIT_TEST_ARGS) + +.PHONY: cov-report-html +cov-report-html: cov-unit ## Generate a HTML coverage report and open it in the browser. + cargo llvm-cov report --html + open target/llvm-cov/html/index.html + # Downloads and unpacks Ethereum Foundation tests in the `$(EF_TESTS_DIR)` directory. # # Requires `wget` and `tar`