fixing tests!
diff --git a/doc/markdown/todo.md b/doc/markdown/todo.md
index 9ffc82e..1b1e0fa 100644
--- a/doc/markdown/todo.md
+++ b/doc/markdown/todo.md
@@ -22,6 +22,7 @@
- remove <cstring> dependency (strcpy and strtok)
- pool allocator for String class
- think about the exit code (maybe clamp between 0/127) (catch also returns the number of failed tests) - http://stackoverflow.com/questions/36727192
+- make it possible for tests through valgrind to have an exit code different than 0 - http://stackoverflow.com/questions/36729692
- example of stringify-ing common stl stuff like containers
- test coverage
diff --git a/examples/type_reporting/CMakeLists.txt b/examples/type_reporting/CMakeLists.txt
index 5ce5ce1..e2cdf08 100644
--- a/examples/type_reporting/CMakeLists.txt
+++ b/examples/type_reporting/CMakeLists.txt
@@ -9,4 +9,4 @@
add_executable(${PROJECT_NAME} main.cpp)
-add_test(NAME ${PROJECT_NAME} COMMAND $<TARGET_FILE:${PROJECT_NAME}>)
+add_test(NO_EXITCODE NAME ${PROJECT_NAME} COMMAND $<TARGET_FILE:${PROJECT_NAME}>)
diff --git a/scripts/common.cmake b/scripts/common.cmake
index fc30668..a6b6a93 100644
--- a/scripts/common.cmake
+++ b/scripts/common.cmake
@@ -15,7 +15,7 @@
# add a customized overloaded version of add_test() to suite my needs
function(add_test)
- cmake_parse_arguments(ARG "NO_VALGRIND;NO_OUTPUT" "NAME" "COMMAND" ${ARGN})
+ cmake_parse_arguments(ARG "NO_VALGRIND;NO_OUTPUT;NO_EXITCODE" "NAME" "COMMAND" ${ARGN})
if(NOT "${ARG_UNPARSED_ARGUMENTS}" STREQUAL "" OR "${ARG_NAME}" STREQUAL "" OR "${ARG_COMMAND}" STREQUAL "")
message(FATAL_ERROR "add_test() called with wrong options!")
endif()
@@ -40,6 +40,10 @@
list(APPEND ADDITIONAL_FLAGS -DTEST_OUTPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/test_output/${ARG_NAME}.txt)
list(APPEND ADDITIONAL_FLAGS -DTEST_TEMP_FILE=${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/temp_test_output.txt)
endif()
+ else()
+ if(ARG_NO_EXITCODE)
+ list(APPEND ADDITIONAL_FLAGS -DNO_EXITCODE=ON)
+ endif()
endif()
list(APPEND ADDITIONAL_FLAGS -DTEST_MODE=${the_test_mode})
@@ -107,7 +111,9 @@
add_compiler_flags(-Wmissing-declarations)
add_compiler_flags(-Woverloaded-virtual)
add_compiler_flags(-Wstrict-null-sentinel)
- add_compiler_flags(-Wnoexcept)
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
+ add_compiler_flags(-Wnoexcept)
+ endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
add_compiler_flags(-Wdouble-promotion)
diff --git a/scripts/exec_test.cmake b/scripts/exec_test.cmake
index e6d99a3..f75d620 100644
--- a/scripts/exec_test.cmake
+++ b/scripts/exec_test.cmake
@@ -1,6 +1,7 @@
# Arguments:
# - COMMAND: the command to run with all it's arguments
# - TEST_MODE: NORMAL/VALGRIND/COLLECT/COMPARE
+# - NO_EXITCODE: if ON the exit code of the application will be ignored
# - TEST_OUTPUT_FILE: the file to/from which to write/read the output of the test
# - TEST_TEMP_FILE: the temp file for the current test output used in COMPARE mode
# To run something through this script use cmake like this:
@@ -8,6 +9,7 @@
#message("COMMAND: ${COMMAND}")
#message("TEST_MODE: ${TEST_MODE}")
+#message("NO_EXITCODE: ${NO_EXITCODE}")
#message("TEST_OUTPUT_FILE: ${TEST_OUTPUT_FILE}")
#message("TEST_TEMP_FILE: ${TEST_TEMP_FILE}")
@@ -43,6 +45,11 @@
message("${temp}")
set(CMD_RESULT "Output is different from reference file!")
endif()
+else()
+ # ignore the exit code if requested
+ if(NO_EXITCODE)
+ set(CMD_RESULT "")
+ endif()
endif()
if(CMD_RESULT)