From 05bea3e922aa7aec5cba3242d3f34b5c10fad24e Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Mon, 4 Mar 2024 23:37:49 +0100 Subject: test: add basic bats setup and test cases for `version setup` Signed-off-by: Levente Polyak --- Makefile | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 708bec7..b3e32a0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SHELL=/bin/bash +SHELL=/bin/bash -o pipefail V=1.1.1 BUILDTOOLVER ?= $(V) @@ -52,6 +52,13 @@ ARCHBUILD_LINKS = \ COMPLETIONS = $(addprefix $(BUILDDIR)/,$(patsubst %.in,%,$(wildcard contrib/completion/*/*))) +CASES ?= test/case +JOBS ?= $(shell nproc) +BATS_EXTRA_ARGS ?= +BATS_ARGS ?= --jobs $(JOBS) $(BATS_EXTRA_ARGS) --verbose-run +COVERAGE_DIR ?= $(BUILDDIR)/coverage + + all: binprogs library conf completion man binprogs: $(BINPROGS) library: $(LIBRARY) @@ -168,8 +175,17 @@ dist: git archive --format=tar --prefix=devtools-$(V)/ v$(V) | gzip > devtools-$(V).tar.gz gpg --detach-sign --use-agent devtools-$(V).tar.gz +test: binprogs library conf completion man + @mkdir -p $(COVERAGE_DIR) + bats $(BATS_ARGS) $(CASES) | tee $(COVERAGE_DIR)/bats-report.xml + +coverage: binprogs library conf completion man + kcov --include-path=src $(COVERAGE_DIR) bats $(BATS_ARGS) $(CASES) + jq -r '. | ["Percent covered", .percent_covered], ["Covered lines", .covered_lines], ["Total lines", .total_lines], ["Percent low", .percent_low], ["Percent high", .percent_high] | @tsv' \ + $(COVERAGE_DIR)/bats.*/coverage.json + check: $(BINPROGS_SRC) $(LIBRARY_SRC) contrib/completion/bash/devtools.in config/makepkg/x86_64.conf contrib/makepkg/PKGBUILD.proto shellcheck $^ -.PHONY: all binprogs library completion conf man clean install uninstall tag dist upload check +.PHONY: all binprogs library completion conf man clean install uninstall tag dist upload test coverage check .DELETE_ON_ERROR: -- cgit v1.2.3-70-g09d2