Skip to content

Commit

Permalink
ctest: FATAL_ERROR on test failure
Browse files Browse the repository at this point in the history
This is required because ctest returns 0 to the calling process even if
a test fails. The script now checks for the RETURN_VALUE of ctest_test
and if it's non-zero calls message(FATAL_ERROR ...).

Signed-off-by: Matthias Kretz <kretz@kde.org>
  • Loading branch information
mattkretz committed Jan 21, 2016
1 parent f68d3b4 commit 70a2c62
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test.cmake
Expand Up @@ -331,6 +331,7 @@ macro(go)
ctest_submit(PARTS Notes Configure)
unset(CTEST_NOTES_FILES) # less clutter in ctest -V output
if(res EQUAL 0)
set(test_results 0)
if(travis_os)
set(CTEST_BUILD_COMMAND "${CMAKE_MAKE_PROGRAM} ${MAKE_ARGS}")
ctest_build(
Expand All @@ -340,6 +341,7 @@ macro(go)
ctest_test(
BUILD "${CTEST_BINARY_DIRECTORY}"
APPEND
RETURN_VALUE test_results
PARALLEL_LEVEL ${number_of_processors})
ctest_submit(PARTS Build Test)
else()
Expand All @@ -360,9 +362,13 @@ macro(go)
PARALLEL_LEVEL ${number_of_processors}
INCLUDE_LABEL "^${label}$")
ctest_submit(PARTS Test)
math(EXPR test_results "${test_results} + ${res}")
endif()
endforeach()
endif()
if(NOT test_results EQUAL 0)
message(FATAL_ERROR "One or more tests failed.")
endif()
endif()
endif()
endmacro()
Expand Down

0 comments on commit 70a2c62

Please sign in to comment.