Add tests coverage report generation
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Mon, 18 Apr 2016 23:56:57 +0000 (01:56 +0200)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Mon, 18 Apr 2016 23:56:57 +0000 (01:56 +0200)
test-all.sh [new file with mode: 0644]
tests/Makefile.am
tests/callable/TestCallableFunctionPointer.h [new file with mode: 0644]

diff --git a/test-all.sh b/test-all.sh
new file mode 100644 (file)
index 0000000..4061274
--- /dev/null
@@ -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
index e17e256c212f08c9e279284b4ac9574b4511dbf2..fa1fbc4fca8f0c8f34f2f4f44f3095cbefdaf465 100644 (file)
@@ -48,6 +48,23 @@ AM_CXXFLAGS = -I$(top_srcdir)/include -std=c++11
 check-% :      %.test all
        @srcdir=$(srcdir); export srcdir;
 
 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
 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 (file)
index 0000000..7fea870
--- /dev/null
@@ -0,0 +1,27 @@
+#include "callable.h"
+
+using namespace command;
+
+template<typename ArgumentType>
+class TestCallable : public Callable<ArgumentType> {
+public:
+    TestCallable(void (*function)(ArgumentType))
+        : Callable<ArgumentType>(function) {
+    }
+
+    void callFunction(ArgumentType test) {
+        this->call(test);
+    }
+};
+
+template<>
+class TestCallable<void> : public Callable<void> {
+public:
+    TestCallable(void (*function)(void))
+        : Callable<void>(function) {
+    }
+
+    void callFunction() {
+        this->call();
+    }
+};