Skip to content

Commit

Permalink
Enable test code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bensk1 committed Oct 10, 2016
1 parent 3616aab commit 73c6abc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ obj/*
build/*
*.make
Makefile*
coverage
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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",
Expand Down

0 comments on commit 73c6abc

Please sign in to comment.