Skip to content

Commit

Permalink
ctest: skip tests if the label has no tests defined
Browse files Browse the repository at this point in the history
This avoids error code 255 for cases where a label has 0 tests. This
resulted in spurious Travis & AppVeyor failures.

Signed-off-by: Matthias Kretz <kretz@kde.org>
  • Loading branch information
mattkretz committed Dec 8, 2016
1 parent f8b8b30 commit eabcb2f
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,25 @@ macro(go)
RETURN_VALUE res)
ctest_submit(PARTS Build)
if(res EQUAL 0 AND NOT skip_tests)
ctest_test(
BUILD "${CTEST_BINARY_DIRECTORY}"
APPEND
RETURN_VALUE res
PARALLEL_LEVEL ${number_of_processors}
INCLUDE_LABEL "^${label}$")
ctest_submit(PARTS Test)
if(NOT res EQUAL 0)
set(test_results ${res})
execute_process(
COMMAND ${CMAKE_CTEST_COMMAND} -N -L "^${label}$"
WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
OUTPUT_VARIABLE tmp
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(tmp MATCHES "Total Tests: 0")
message("No tests were defined. Skipping tests.")
else()
ctest_test(
BUILD "${CTEST_BINARY_DIRECTORY}"
APPEND
RETURN_VALUE res
PARALLEL_LEVEL ${number_of_processors}
INCLUDE_LABEL "^${label}$")
ctest_submit(PARTS Test)
if(NOT res EQUAL 0)
message("ctest_test returned non-zero result: ${res}")
set(test_results ${res})
endif()
endif()
endif()
endforeach()
Expand Down

0 comments on commit eabcb2f

Please sign in to comment.