From 73c6abc4f6aa542429511e538bf55efdfcb8074e Mon Sep 17 00:00:00 2001 From: Jan Kossmann Date: Mon, 10 Oct 2016 16:15:33 +0200 Subject: [PATCH] Enable test code coverage --- .gitignore | 1 + README.md | 4 ++++ premake4.lua | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/.gitignore b/.gitignore index 1498a98b84..a9696c7d76 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ obj/* build/* *.make Makefile* +coverage diff --git a/README.md b/README.md index ee68e2f0fa..93b19e227e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ ## testing (is also automatically triggered before git commit) `premake4 test` executes all available tests +## coverage +`make -j coverage` will print a summary to the command line and create detailed html reports at ./coverage/index.html +*Supports only clang on MacOS and only gcc on linux* + Naming convention for gtest macros: TEST(module_name_class_name, test_case_description), e.g., TEST(operators_get_table, get_output_returns_correct_table) diff --git a/premake4.lua b/premake4.lua index 218eee8ba9..c4ead3c71d 100644 --- a/premake4.lua +++ b/premake4.lua @@ -91,6 +91,12 @@ project "opossum" kind "StaticLib" files { "src/lib/**.hpp", "src/lib/**.cpp", "src/bin/server.cpp" } +project "opossumCoverage" + kind "StaticLib" + buildoptions { "-fprofile-arcs -ftest-coverage" } + linkoptions { "-lgcov --coverage" } + files { "src/lib/**.hpp", "src/lib/**.cpp" } + project "server" kind "ConsoleApp" links { "opossum" } @@ -112,6 +118,21 @@ project "test" includedirs { "third_party/googletest/googletest/include" } postbuildcommands { "./build/test" } +project "coverage" + kind "ConsoleApp" + + defines { "IS_DEBUG=1" } + + links { "opossumCoverage", "googletest" } + if os.is("macosx") then + linkoptions {"--coverage"} + else + linkoptions {"-pthread --coverage"} + end + files { "src/test/**.hpp", "src/test/**.cpp" } + includedirs { "third_party/googletest/googletest/include" } + postbuildcommands { "./build/coverage && rm -fr coverage; mkdir coverage && gcovr -s -r . --exclude=\".*types*.\" --html --html-details -o coverage/index.html" } + newoption { trigger = "compiler", value = "clang||gcc",