Skip to content

Commit

Permalink
Merge f6b8312 into 8f7ebd4
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreLouisCaron committed Jan 1, 2016
2 parents 8f7ebd4 + f6b8312 commit 9b3d895
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ before_script:

script:
# Build without tests.
- cmake .. -DGREEN_TESTS=OFF
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DGREEN_TESTS=OFF
- make
# Build tests and run them.
- cmake .. -DGREEN_TESTS=ON -DGREEN_GCOV=ON
- make clean
# Build again with tests.
- cmake .. -DGREEN_TESTS=ON -DGREEN_GCOV=ON -DGREEN_VALGRIND=ON
- make
- CTEST_OUTPUT_ON_FAILURE=TRUE make test
# Run tests (fails if any leaks are found).
- CTEST_OUTPUT_ON_FAILURE=TRUE ctest -T memcheck
# Build docs.
- sphinx-build -b html ../docs/ docs/
# Send code coverage to coveralls.io.
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project(green)

option(GREEN_TESTS "Compile the test suite." ON)
option(GREEN_GCOV "Compute code coverage." OFF)
option(GREEN_VALGRIND "Run tests with memory leak checker." OFF)

if (GREEN_GCOV)
message(STATUS "Code coverage enabled.")
Expand All @@ -31,6 +32,15 @@ add_library(green
"src/green.c"
)

# This enables `ctest -T memcheck`.
if (GREEN_VALGRIND)
find_program(MEMORYCHECK_COMMAND "valgrind")
set(MEMORYCHECK_COMMAND_OPTIONS
"--leak-check=yes --error-exitcode=666"
)
include(Dart)
endif()

macro(green_add_test test-name source-file)
add_executable(${test-name} ${source-file})
target_link_libraries(${test-name} green)
Expand Down

0 comments on commit 9b3d895

Please sign in to comment.