Browse Source

cmake: let every test depends on pretest

Anonymous Maarten 1 year ago
parent
commit
f5886f11d0
2 changed files with 8 additions and 6 deletions
  1. 4 5
      test/CMakeLists.txt
  2. 4 1
      test/pretest.c

+ 4 - 5
test/CMakeLists.txt

@@ -304,7 +304,7 @@ add_sdl_test_executable(testplatform NONINTERACTIVE SOURCES testplatform.c)
 add_sdl_test_executable(testpower NONINTERACTIVE SOURCES testpower.c)
 add_sdl_test_executable(testfilesystem NONINTERACTIVE SOURCES testfilesystem.c)
 if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
-    add_sdl_test_executable(testfilesystem_pre SOURCES testfilesystem_pre.c NONINTERACTIVE NONINTERACTIVE_TIMEOUT 60)
+    add_sdl_test_executable(pretest SOURCES pretest.c NONINTERACTIVE NONINTERACTIVE_TIMEOUT 60)
 endif()
 add_sdl_test_executable(testrendertarget NEEDS_RESOURCES TESTUTILS SOURCES testrendertarget.c)
 add_sdl_test_executable(testscale NEEDS_RESOURCES TESTUTILS SOURCES testscale.c)
@@ -511,13 +511,12 @@ foreach(TEST ${SDL_TEST_EXECUTABLES})
                 DESTINATION ${CMAKE_INSTALL_DATADIR}/installed-tests/SDL3
             )
         endif()
+        if(TARGET pretest AND NOT "${TEST}" MATCHES "pretest")
+            set_property(TEST ${TEST} APPEND PROPERTY DEPENDS pretest)
+        endif()
     endif()
 endforeach()
 
-if(TARGET testfilesystem_pre)
-    set_property(TEST testfilesystem APPEND PROPERTY DEPENDS testfilesystem_pre)
-endif()
-
 if(SDL_INSTALL_TESTS)
     if(RISCOS)
         install(

+ 4 - 1
test/testfilesystem_pre.c → test/pretest.c

@@ -22,12 +22,15 @@
 int main(int argc, char *argv[])
 {
     Uint64 start;
+    Uint64 prequit;
     (void)argc;
     (void)argv;
     SDL_Init(0);
     start = SDL_GetTicks();
     SDL_GetPrefPath("libsdl", "test_filesystem");
-    SDL_Log("SDL_GetPrefPath took %" SDL_PRIu64 "ms", SDL_GetTicks() - start);
+    prequit = SDL_GetTicks();
+    SDL_Log("SDL_GetPrefPath took %" SDL_PRIu64 "ms", prequit - start);
     SDL_Quit();
+    SDL_Log("SDL_Quit took %" SDL_PRIu64 "ms", SDL_GetTicks() - prequit);
     return 0;
 }