From f1715b471d7e900d56502ce6c315f427d78815f4 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Wed, 22 Jan 2014 12:12:51 +0100 Subject: [PATCH] Guard against EVENT_NOWIN32 being set during testing. On windows all tests will fail if EVENT_NOWIN32 is set, since then there will be no backend available. Question is if we should simply disable the environment variable check on Windows, since there's only one backend available anyway? --- CMakeLists.txt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00f4aa35..2602a6d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -925,8 +925,25 @@ if (NOT EVENT__DISABLE_TESTS) # (Important! This will unset all EVENT_NO* environment variables. # If they are set in the shell the tests are running using simply "ctest" or "make test" will fail) if (WIN32) - # Windows doesn't have "unset", and the above does not happen anyway. - add_custom_target(verify COMMAND ${CMAKE_CTEST_COMMAND} + # Windows doesn't have "unset". But you can use "set VAR=" instead. + # We need to guard against the possibility taht EVENT_NOWIN32 is set, and all test failing + # since no event backend being available. + file(TO_NATIVE_PATH ${CMAKE_CTEST_COMMAND} WINDOWS_CTEST_COMMAND) + + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.bat + " + set EVENT_NOWIN32= + \"${WINDOWS_CTEST_COMMAND}\" + ") + + message("${WINDOWS_CTEST_COMMAND}") + file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.bat + DESTINATION ${CMAKE_CURRENT_BINARY_DIR} + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + + file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/verify_tests.bat" VERIFY_PATH) + + add_custom_target(verify COMMAND "${VERIFY_PATH}" DEPENDS event ${ALL_TESTPROGS}) else() # On some platforms doing exec(unset) as CMake does won't work, so make sure -- 2.40.0