summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2017-03-04 16:08:27 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2017-03-04 17:35:18 +0000
commitb609d07be3b37f81f5c05ae56bd427d16bb6f5c9 (patch)
treec38a7b0c0bd126e989cb7582a1f9fbd30333adb5 /Makefile
parentf2f5b4e6229532f3ba69e9f32bc3305e37b20f4c (diff)
downloadgitano-b609d07be3b37f81f5c05ae56bd427d16bb6f5c9.tar.gz
adds support for coverage testing
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile66
1 files changed, 57 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 08ad6a5..c85383a 100644
--- a/Makefile
+++ b/Makefile
@@ -86,12 +86,24 @@ TESTS := $(patsubst %,testing/%.yarn,$(TESTS))
GEN_BIN := utils/install-lua-bin
RUN_GEN_BIN := $(LUA) $(GEN_BIN) $(LUA)
+
+COVERAGE := no
+
+ifeq ($(COVERAGE),yes)
+define GEN_LOCAL_BIN
+
+$(RUN_GEN_BIN) $(shell pwd) $(shell pwd)/bin $(shell pwd)/lib $(shell pwd)/plugins $1 $2 $(shell pwd)/extras/luacov/src $(shell pwd)/.coverage/
+chmod 755 $2
+
+endef
+else
define GEN_LOCAL_BIN
$(RUN_GEN_BIN) $(shell pwd) $(shell pwd)/bin $(shell pwd)/lib $(shell pwd)/plugins $1 $2
chmod 755 $2
endef
+endif
define GEN_INSTALL_BIN
@@ -113,23 +125,51 @@ install -m 644 $1 $2
endef
-local: $(LOCAL_BINS)
- $(LUAC) -p $(LOCAL_BINS)
+define GEN_LOCAL_MOD
-clean:
- @echo "CLEAN: local binaries"
- @$(RM) $(LOCAL_BINS)
+$(RUN_GEN_BIN) $(shell pwd) $(shell pwd)/bin $(shell pwd)/lib $(shell pwd)/plugins $1 $2
+
+endef
+
+LOCAL_MODS := lib/gitano/coverage.lua
+
+local: $(LOCAL_BINS) $(LOCAL_MODS)
+ @$(LUAC) -p $(LOCAL_BINS) $(LOCAL_MODS)
+ @mkdir -p .coverage
+ifeq ($(COVERAGE),yes)
+ @echo NOTE: Coverage gathering enabled
+ @if ! test -r extras/luacov/src/luacov; then \
+ echo "CANNOT COVERAGE TEST, LUACOV MODULE NOT AVAILABLE"; \
+ echo "Please run: git submodule init && git submodule update"; \
+ fi
+else
+ @echo NOTE: Coverage gathering is not enabled
+endif
+
+clean: cleanbins
+ @echo "CLEAN: coverage stats and reports"
+ @$(RM) -r .coverage luacov.stats.out luacov.report.out
+
+cleanbins:
+ @echo "CLEAN: local binaries and modules"
+ @$(RM) $(LOCAL_BINS) $(LOCAL_MODS)
@echo "CLEAN: test binaries"
@$(RM) $(TEST_BINS)
distclean: clean
@find . -name "*~" -delete
-bin/%: bin/%.in $(GEN_BIN)
- $(call GEN_LOCAL_BIN,$<,$@)
+bin/%: bin/%.in $(GEN_BIN) FORCE
+ @$(call GEN_LOCAL_BIN,$<,$@)
-testing/%: testing/%.in $(GEN_BIN)
- $(call GEN_LOCAL_BIN,$<,$@)
+testing/%: testing/%.in $(GEN_BIN) FORCE
+ @$(call GEN_LOCAL_BIN,$<,$@)
+
+lib/gitano/%.lua: lib/gitano/%.lua.in $(GEN_BIN) FORCE
+ @$(call GEN_LOCAL_MOD,$<,$@)
+
+FORCE:
+.PHONY: FORCE
install: install-bins install-lib-bins install-mods install-skel install-man install-plugins install-lang
@@ -242,3 +282,11 @@ testing/%: testing/%.in $(GEN_BIN)
$(call GEN_LOCAL_BIN,$<,$@)
check: test
+
+coverage-report:
+ @echo "COVERAGE: Merge stats..."
+ @env LUA_PATH="$(shell pwd)/extras/luacov/src/?.lua;;" $(LUA) utils/merge-luacov-stats .coverage/luacov.stats-*.out
+ @echo "COVERAGE: Generate report..."
+ @env LUA_PATH="$(shell pwd)/extras/luacov/src/?.lua;;" $(LUA) extras/luacov/src/bin/luacov
+ @echo "COVERAGE: Summary:"
+ @sed '0,/^Summary/d' < luacov.report.out | tail -n +2 | sed -e's/^/COVERAGE: /'