]> granicus.if.org Git - libevent/commitdiff
Guard against EVENT_NOWIN32 being set during testing.
authorJoakim Soderberg <joakim.soderberg@gmail.com>
Wed, 22 Jan 2014 11:12:51 +0000 (12:12 +0100)
committerJoakim Soderberg <joakim.soderberg@gmail.com>
Wed, 22 Jan 2014 11:12:51 +0000 (12:12 +0100)
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

index 00f4aa35aa235fa292e784f0201c054279ef2c73..2602a6d3c3c75aad15ae35d713ae0a9801cfb404 100644 (file)
@@ -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