From 7ca773a1a9de4021a0132e481d37c3995d45a694 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Mon, 20 Aug 2018 14:54:03 -0500 Subject: [PATCH] ENT-3756: change code coverage destination to work with atom IDE plugin. Should work fine with codecov.io --- .gitignore | 3 +-- HACKING.md | 20 ++++++++++++++++++++ Makefile.am | 12 +++++++----- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index b6c514bd47..a8d61bc034 100644 --- a/.gitignore +++ b/.gitignore @@ -81,9 +81,8 @@ misc/systemd/*.service *.gcno *.gcda *.trace -cfengine-lcov-base.info -cfengine-lcov.info coverage-html/ +coverage/ # links /nova diff --git a/HACKING.md b/HACKING.md index 82cb1c1fb1..e3053854a9 100644 --- a/HACKING.md +++ b/HACKING.md @@ -387,6 +387,26 @@ Tip: In order to trigger assert() calls in the code, build with `--enable-debug` (passed to either `./autogen.sh` or `./configure`). If you get very large binary sizes you can also pass `CFLAGS='-g -O0'` to reduce that. +Code Coverage +------------- +We strive to always increase code coverage. If you wish to generate code +coverage information then you must autogen or configure with --enable-debug +and --enable-coverage as well as ensure lcov is installed (typically an lcov +package is available in a distribution). +We use gcov to instrument and process coverage information. .gcno files are +generated at compile-time and will not be regenerated if the source code +does not change. So be careful about cleaning those files. .gcda files are +like index files which can be used to generate the .gcov files which lcov +uses to generate lcov.info and the HTML report in the coverage-html directory. +Many IDEs and editors expect a /coverage/lcov.info summary of coverage +information. After running `make check` you can run `make coverage` and +generate this lcov.info summary for use with other tools. If you wish to only +run a few tests which will add to coverage data you can update lcov.info with +`make collect-coverage` which will only collect coverage data, not compile or +run any tests. + +For the atom editor, install the package atom-lcov-info. + Unsafe Tests ------------ diff --git a/Makefile.am b/Makefile.am index 0200a726a7..33c8fa0769 100644 --- a/Makefile.am +++ b/Makefile.am @@ -114,13 +114,15 @@ run-coverage: collect-coverage: - $(LCOV) $(LCOV_FLAGS) --capture --initial --directory . --output-file cfengine-lcov-base.info - $(LCOV) $(LCOV_FLAGS) --capture --directory . --output-file cfengine-lcov.info --test-name CFENGINE --no-checksum --compat-libtool - $(LCOV) $(LCOV_FLAGS) -a cfengine-lcov-base.info -a cfengine-lcov.info --output-file cfengine-lcov.info - $(LCOV) $(LCOV_FLAGS) --remove cfengine-lcov.info '/usr/include/*' --output-file cfengine-lcov.info - LANG=C $(LCOV_GENHTML) $(LCOV_FLAGS) --prefix . --output-directory coverage-html --title "CFEngine Code Coverage" --legend --show-details cfengine-lcov.info + mkdir -p coverage + $(LCOV) $(LCOV_FLAGS) --capture --initial --directory . --output-file coverage/cfengine-lcov-base.info + $(LCOV) $(LCOV_FLAGS) --capture --directory . --output-file coverage/lcov.info --test-name CFENGINE --no-checksum --compat-libtool + $(LCOV) $(LCOV_FLAGS) -a coverage/cfengine-lcov-base.info -a coverage/lcov.info --output-file coverage/cfengine-lcov.info + $(LCOV) $(LCOV_FLAGS) --remove coverage/lcov.info '/usr/include/*' --output-file coverage/lcov.info + LANG=C $(LCOV_GENHTML) $(LCOV_FLAGS) --prefix . --output-directory coverage-html --title "CFEngine Code Coverage" --legend --show-details coverage/lcov.info @echo @echo " Code coverage information: file://"`pwd`"/coverage-html/index.html" + @echo " Code coverage summary for IDEs: file://"`pwd`"/coverage/lcov.info" @echo coverage: clean-coverage run-coverage collect-coverage