Hack around CMake < 3.9 reporting skipped tests as failed

This commit is contained in:
Mahmoud Al-Qudsi 2021-09-07 12:04:05 -05:00
parent 9151acc498
commit e0476cf219
2 changed files with 19 additions and 2 deletions

View file

@ -121,6 +121,14 @@ add_custom_target(tests_buildroot_target
${TEST_ROOT_DIR}
DEPENDS fish fish_test_helper)
# CMake less than 3.9.0 "fully supports" setting an exit code to denote a skipped test, but then
# it just goes ahead and reports it as failed. Really?
if(${CMAKE_VERSION} VERSION_LESS "3.9.0")
set(CMAKE_SKIPPED_HACK "env" "CMAKE_SKIPPED_HACK=1")
else()
set(CMAKE_SKIPPED_HACK)
endif()
foreach(LTEST ${LOW_LEVEL_TESTS})
add_test(
NAME ${LTEST}
@ -137,7 +145,7 @@ foreach(CHECK ${FISH_CHECKS})
get_filename_component(CHECK_NAME ${CHECK} NAME)
get_filename_component(CHECK ${CHECK} NAME_WE)
add_test(NAME ${CHECK_NAME}
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
COMMAND ${CMAKE_SKIPPED_HACK} sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
${CMAKE_CURRENT_BINARY_DIR}/tests/test.fish ${CHECK}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
)
@ -149,7 +157,7 @@ FILE(GLOB PEXPECTS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/pexpects/*.py)
foreach(PEXPECT ${PEXPECTS})
get_filename_component(PEXPECT ${PEXPECT} NAME)
add_test(NAME ${PEXPECT}
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
COMMAND ${CMAKE_SKIPPED_HACK} sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
${CMAKE_CURRENT_BINARY_DIR}/tests/interactive.fish ${PEXPECT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
)

View file

@ -75,5 +75,14 @@ fish_init_cmd="${fish_init_cmd} && source ${TESTS_ROOT}/test_util.fish";
"$fish_script" "$script_args")
test_status="$?"
# CMake less than 3.9.0 "fully supports" setting an exit code to denote a skipped test, but then
# it just goes ahead and reports them as failed anyway. Really?
if test -n $CMAKE_SKIPPED_HACK; then
if test $test_status -eq 125; then
echo "Overriding SKIPPED return code from test" 1>&2
test_status=0
fi
fi
rm -rf "$homedir"
exit "$test_status"