]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
CI coverage: add missing Lua files to the report
authorPetr Špaček <petr.spacek@nic.cz>
Thu, 21 Dec 2017 09:09:11 +0000 (10:09 +0100)
committerPetr Špaček <petr.spacek@nic.cz>
Sat, 23 Dec 2017 22:48:48 +0000 (23:48 +0100)
Luacov does not know about files which were not loaded at all.
Script luacov_gen_empty.sh generates empty luacov stats for all files
which forces luacov to show all files.

Makefile
scripts/luacov_gen_empty.sh [new file with mode: 0755]

index 6a22017c65c3df6ed0beda061270a183d6ea561e..897a1740734cf24afd1af7251a913eca0a4b77b0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,12 +14,15 @@ coverage-c:
        @echo "# C coverage in $(COVERAGE_STAGE).c.info"
        @$(LCOV) --no-external --capture -d lib -d daemon -d modules -o $(COVERAGE_STAGE).c.info > /dev/null
 coverage-lua: $(shell find -type f -name 'luacov.stats.out')
-       # map install paths to source paths
+       @# map install paths to source paths
        @$(MAKE) PREFIX=$(PREFIX) install --dry-run --always-make | scripts/map_install_src.lua --sed > .luacov_path_map
        @find -type f -name 'luacov.stats.out' | xargs sed -i -f .luacov_path_map
        @rm .luacov_path_map
+       @# add missing Lua files
+       @$(MAKE) PREFIX=$(PREFIX) install --dry-run --always-make | scripts/map_install_src.lua | cut -f 2 | grep '\.lua$$' | scripts/luacov_gen_empty.sh > luacov.empty_stats.out
        @echo "# Lua coverage in $(COVERAGE_STAGE).lua.info"
-       @scripts/luacov_to_info.lua $^ > $(COVERAGE_STAGE).lua.info
+       @scripts/luacov_to_info.lua luacov.empty_stats.out $^ > $(COVERAGE_STAGE).lua.info
+       @rm luacov.empty_stats.out
 coverage:
        @$(LCOV) $(addprefix --add-tracefile ,$(wildcard $(COVERAGE_STAGE)*.info)) --output-file coverage.info
        @$(GENHTML) --no-function-coverage --no-branch-coverage -q -o coverage -p $(realpath $(CURDIR)) -t "Knot DNS Resolver $(VERSION)-$(PLATFORM) coverage report" --legend coverage.info
diff --git a/scripts/luacov_gen_empty.sh b/scripts/luacov_gen_empty.sh
new file mode 100755 (executable)
index 0000000..a224081
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Generate stats file in luacov format indicating that files named on stdin
+# were not processed.
+#
+# Normally luacov does not know about files which were not loaded so
+# without this manual addition the files are missing in coverage report.
+
+# Usage:
+# $ luacov_gen_empty.sh < list_of_lua_files > luacov.empty_stats.out
+
+set -o errexit -o nounset
+IFS=$'\n'
+
+while read FILENAME
+do
+       echo -e "0:${FILENAME}\n "
+done