Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2024-03-04 23:37:49 +0100
committerChristian Heusel <christian@heusel.eu>2024-03-23 23:57:46 +0100
commit05bea3e922aa7aec5cba3242d3f34b5c10fad24e (patch)
treede09c15c36a0860e93eb664f16db694244218cd1 /Makefile
parentde0ea3b2f839c2f6ba074d7401d2a28118680da0 (diff)
test: add basic bats setup and test cases for `version setup`
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 18 insertions, 2 deletions
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: