Skip to content

Commit

Permalink
Modifies tests build spec to automatically build tests executables wh…
Browse files Browse the repository at this point in the history
…en running ctest or make test
  • Loading branch information
jmealler committed Aug 21, 2014
1 parent 0daa720 commit 40d91fc
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

set(TEST_SOURCES
dep_canonicalization.cpp
dependency_loop.cpp
Expand All @@ -24,16 +23,22 @@ type_already_bound.cpp
type_already_bound2.cpp
)

function(add_successful_compile NAME)
set(BIN ${NAME}-exec)
set(BUILD ${NAME}-build)
add_executable(${BIN} ${NAME}.cpp)
target_link_libraries(${BIN} fruit)
add_test(NAME ${BUILD} COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target ${BIN})
set_tests_properties(${NAME} PROPERTIES DEPENDS ${BUILD})
endfunction(add_successful_compile)

function(add_test_expected_to_pass NAME)
add_executable(${NAME}-exec ${NAME}.cpp)
target_link_libraries(${NAME}-exec fruit)
add_test(NAME ${NAME}
COMMAND valgrind --leak-check=full --malloc-fill=AA --track-origins=yes --read-var-info=yes --num-callers=50 --error-exitcode=1 $<TARGET_FILE:${NAME}-exec>)
add_successful_compile(${NAME})
endfunction(add_test_expected_to_pass)

function(add_test_expected_to_fail_at_runtime NAME MESSAGE)
add_executable(${NAME}-exec ${NAME}.cpp)
target_link_libraries(${NAME}-exec fruit)
add_test(NAME ${NAME}
COMMAND bash -c "
F=`mktemp`
Expand All @@ -51,6 +56,7 @@ function(add_test_expected_to_fail_at_runtime NAME MESSAGE)
fi
rm -f \${F}
")
add_successful_compile(${NAME})
endfunction(add_test_expected_to_fail_at_runtime)

set(COMPILERS_TO_TEST "g++" "clang++")
Expand Down

0 comments on commit 40d91fc

Please sign in to comment.