sdl2-compat: ci: enable tests

From 63cbaa393d6455e57f5ead0c8580d815f9cd40ca Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Wed, 9 Aug 2023 01:43:50 +0200
Subject: [PATCH] ci: enable tests

---
 .github/workflows/main.yml | 14 +++-----------
 test/CMakeLists.txt        |  6 ++++++
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 620d7d25..1655aa33 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -112,21 +112,13 @@ jobs:
       run: |
         cmake --build build/ --target package
     - name: Run build-time tests (CMake)
-      if: ${{ false && !matrix.platform.cross }} # FIXME: enable build-time tests on CI
+      if: ${{ !matrix.platform.cross }}
       run: |
-        #FIXME: do this in libsdl-org/setup-sdl (by adding it to .bashrc)? Or move to separate ci step?
-        sdl_binpath="${{ steps.sdl.outputs.prefix }}/bin"
-        if [ "x${{ runner.os }}" = "xWindows" ]; then
-          sdl_binpath="$( cygpath -u "$sdl_binpath" )"
-        fi
-        echo "sdl_binpath=$sdl_binpath"
-        export PATH="$sdl_binpath:$PATH"
-        export LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH"
-
         set -eu
         export SDL_TESTS_QUICK=1
         ctest -VV --test-dir build/
-    - name: Run build tests (CMake)
+    - name: Run compile tests (CMake)
+      if: ${{ always() }}
       run: |
         cmake --build build/ --verbose --target sdl2compat-build-tests
     - name: Check that versioning is consistent
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index e31adc5b..38a93bc2 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -56,6 +56,12 @@ function(test_program NAME)
       ENVIRONMENT "SDL_AUDIODRIVER=dummy;SDL_VIDEODRIVER=dummy"
       TIMEOUT ${timeout}
     )
+    if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.27")
+      set_property(TEST ${NAME} APPEND PROPERTY ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_RUNTIME_DLL_DIRS:${NAME}>")
+      if(TARGET SDL3::SDL3-shared)
+        set_property(TEST ${NAME} APPEND PROPERTY ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:SDL3::SDL3-shared>")
+      endif()
+    endif()
     if(SDL2COMPAT_INSTALL_TESTS)
       set(exe ${NAME})
       set(installedtestsdir "${CMAKE_INSTALL_FULL_LIBEXECDIR}/installed-tests/SDL2_compat")