From c750ce13af8051e56a875fefd017e7f325d01bec Mon Sep 17 00:00:00 2001 From: Carlos Venegas Date: Wed, 3 Mar 2021 19:29:40 +0000 Subject: [PATCH] agent: makefile: Add codecov target Add target to run codecov report locally. Useful to identify what are the missing lines to be covered by unit test. Fixes: #1487 Signed-off-by: Carlos Venegas (backport https://github.com/kata-containers/kata-containers/pull/1489) Signed-off-by: Chelsea Mafrica --- src/agent/.gitignore | 1 + src/agent/Makefile | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/agent/.gitignore diff --git a/src/agent/.gitignore b/src/agent/.gitignore new file mode 100644 index 0000000000..581de56347 --- /dev/null +++ b/src/agent/.gitignore @@ -0,0 +1 @@ +tarpaulin-report.html diff --git a/src/agent/Makefile b/src/agent/Makefile index 302547b265..704e71927f 100644 --- a/src/agent/Makefile +++ b/src/agent/Makefile @@ -148,6 +148,7 @@ install: install-services clean: @cargo clean @rm -f $(GENERATED_FILES) + @rm -f tarpaulin-report.html #TARGET test: run cargo tests test: @@ -193,6 +194,27 @@ help: Makefile show-summary @echo "Targets:" @sed -n 's/^##TARGET//p' $< | sort +TARPAULIN_ARGS:=-v --workspace +install-tarpaulin: + cargo install cargo-tarpaulin + +# Check if cargo tarpaulin is installed +HAS_TARPAULIN:= $(shell cargo --list | grep tarpaulin 2>/dev/null) +check_tarpaulin: +ifndef HAS_TARPAULIN + $(error "tarpaulin is not available please: run make install-tarpaulin ") +else + $(info OK: tarpaulin installed) +endif + +##TARGET codecov: Generate code coverage report +codecov: check_tarpaulin + cargo tarpaulin $(TARPAULIN_ARGS) + +##TARGET codecov-html: Generate code coverage html report +codecov-html: check_tarpaulin + cargo tarpaulin $(TARPAULIN_ARGS) -o Html + .PHONY: \ help \ show-header \