From e0fda02032d7d502e57e24eb218da9e24155541a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Tue, 19 Apr 2016 01:56:57 +0200 Subject: [PATCH] Add tests coverage report generation --- test-all.sh | 10 ++++++++ tests/Makefile.am | 17 ++++++++++++ tests/callable/TestCallableFunctionPointer.h | 27 ++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 test-all.sh create mode 100644 tests/callable/TestCallableFunctionPointer.h diff --git a/test-all.sh b/test-all.sh new file mode 100644 index 0000000..4061274 --- /dev/null +++ b/test-all.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ ! -f configure ] ; then + ./autogen.sh +fi + +CXXFLAGS='--coverage -O0' ./configure + +make check +cd tests; make cov \ No newline at end of file diff --git a/tests/Makefile.am b/tests/Makefile.am index e17e256..fa1fbc4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -48,6 +48,23 @@ AM_CXXFLAGS = -I$(top_srcdir)/include -std=c++11 check-% : %.test all @srcdir=$(srcdir); export srcdir; +cov-reset: + rm -fr coverage + find . -name "*.gcda" -exec rm {} \; + find . -name "*.gcno" -exec rm {} \; + lcov --directory . --zerocounters + +cov-report: + mkdir -p coverage + lcov --compat-libtool --directory . --capture --output-file coverage/app.info + genhtml -o coverage/ coverage/app.info + +cov: + make cov-report + +clean-local: + make cov-reset + descriptive_holds_data_test_SOURCES = descriptive/holds_data.cpp callable_invokes_provided_function_test_SOURCES = callable/invokes_provided_function.cpp diff --git a/tests/callable/TestCallableFunctionPointer.h b/tests/callable/TestCallableFunctionPointer.h new file mode 100644 index 0000000..7fea870 --- /dev/null +++ b/tests/callable/TestCallableFunctionPointer.h @@ -0,0 +1,27 @@ +#include "callable.h" + +using namespace command; + +template +class TestCallable : public Callable { +public: + TestCallable(void (*function)(ArgumentType)) + : Callable(function) { + } + + void callFunction(ArgumentType test) { + this->call(test); + } +}; + +template<> +class TestCallable : public Callable { +public: + TestCallable(void (*function)(void)) + : Callable(function) { + } + + void callFunction() { + this->call(); + } +}; -- 2.30.2