Browse Source

NinjaMultiConfig: Update tests for the new dependency change

* Tests were updated for the cases both `AUTOGEN_BETTER_GRAPH_MULTI_CONFIG` is ON and OFF

This commit reimplements e454314daaed0ab5f86bba0015747eb296efb8da
Orkun Tokdemir 2 years ago
parent
commit
596e84b0d5

+ 0 - 7
Tests/RunCMake/NinjaMultiConfig/QtX-debug-in-release-graph-build-check.cmake

@@ -1,7 +0,0 @@
-check_files("${RunCMake_TEST_BINARY_DIR}"
-  INCLUDE
-    ${AUTOGEN_FILES}
-
-    ${TARGET_FILE_exe_Debug}
-    ${TARGET_OBJECT_FILES_exe_Debug}
-  )

+ 26 - 10
Tests/RunCMake/NinjaMultiConfig/QtX.cmake

@@ -19,16 +19,32 @@ if(${QtX}Core_VERSION VERSION_GREATER_EQUAL "5.15.0")
   set(moc_writes_depfiles 1)
 endif()
 
-set(autogen_files)
-if(moc_writes_depfiles)
-  list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/deps")
-  list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/timestamp")
-endif()
-foreach(c IN LISTS CMAKE_CONFIGURATION_TYPES)
-  list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/mocs_compilation_${c}.cpp")
-  list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp")
+foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES)
+  set(config_suffix "_${CONFIG}")
+  if (CMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG)
+    set(autogen_files_config_suffix "${config_suffix}")
+  endif()
+  set(autogen_files)
   if(moc_writes_depfiles)
-    list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp.d")
+    list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/deps${autogen_files_config_suffix}")
+    list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/timestamp${autogen_files_config_suffix}")
   endif()
+  if (CMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG)
+    list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/mocs_compilation${config_suffix}.cpp")
+    list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include${config_suffix}/moc_qt5.cpp")
+    if(moc_writes_depfiles)
+      list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include${config_suffix}/moc_qt5.cpp.d")
+    endif()
+  else()
+    foreach(c IN LISTS CMAKE_CONFIGURATION_TYPES)
+      list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/mocs_compilation_${c}.cpp")
+      list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp")
+      if(moc_writes_depfiles)
+        list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp.d")
+      endif()
+    endforeach()
+  endif()
+
+  file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(AUTOGEN_FILES${config_suffix} [==[${autogen_files}]==])\n")
+  unset(autogen_files)
 endforeach()
-file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(AUTOGEN_FILES [==[${autogen_files}]==])\n")

+ 59 - 5
Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake

@@ -488,11 +488,65 @@ if(CMake_TEST_Qt_version)
     "-D${QtX}Core_DIR=${${QtX}Core_DIR}"
     "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}"
   )
-  run_cmake_configure(QtX)
-  unset(RunCMake_TEST_OPTIONS)
-  include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
-  run_cmake_build(QtX debug-in-release-graph Release exe:Debug)
+
+  foreach(use_better_graph IN ITEMS ON OFF)
+    foreach(target_config IN ITEMS Debug Release RelWithDebInfo)
+      foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo)
+        block()
+          set(target_config_suffix "_${target_config}")
+          if (use_better_graph)
+            set(autogen_files_config_suffix "${target_config_suffix}")
+          else()
+            set(autogen_files_config_suffix "")
+          endif()
+          set(prefix "QtX")
+          set(case "${target_config}-in-${ninja_config}-better-graph-${use_better_graph}")
+          set(test_path "${prefix}-${case}")
+          set(RunCMake_TEST_VARIANT_DESCRIPTION "-${case}-configure")
+          set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test_path}-build)
+          run_cmake_with_options(QtX ${RunCMake_TEST_OPTIONS}
+            "-DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=${use_better_graph}")
+          unset(RunCMake_TEST_VARIANT_DESCRIPTION)
+          include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
+          run_cmake_build(${test_path} "" ${ninja_config} exe:${target_config})
+          check_files("${RunCMake_TEST_BINARY_DIR}"
+          INCLUDE
+            "${AUTOGEN_FILES${target_config_suffix}}"
+            "${TARGET_FILE_exe${target_config_suffix}}"
+            "${TARGET_OBJECT_FILES_exe${target_config_suffix}}"
+          )
+          if (DEFINED RunCMake_TEST_FAILED AND NOT RunCMake_TEST_FAILED STREQUAL "")
+            message(FATAL_ERROR "RunCMake_TEST_FAILED:${RunCMake_TEST_FAILED}")
+          else()
+            message(STATUS "${test_path}-check-files - PASSED")
+          endif()
+
+          check_file_contents("${RunCMake_TEST_BINARY_DIR}/exe_autogen/deps${autogen_files_config_suffix}"
+                              "exe_autogen/timestamp${autogen_files_config_suffix}")
+          if (DEFINED RunCMake_TEST_FAILED AND NOT RunCMake_TEST_FAILED STREQUAL "")
+            message(FATAL_ERROR "RunCMake_TEST_FAILED:${RunCMake_TEST_FAILED}")
+          endif()
+        endblock()
+      endforeach()
+    endforeach()
+  endforeach()
+
   if(CMake_TEST_${QtX}Core_Version VERSION_GREATER_EQUAL 5.15.0)
-    run_ninja(QtX automoc-check build-Debug.ninja -t query exe_autogen/timestamp)
+    foreach(use_better_graph IN ITEMS ON OFF)
+      foreach(target_config IN ITEMS Debug Release RelWithDebInfo)
+        foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo)
+          set(prefix "QtX")
+          set(case "${target_config}-in-${ninja_config}-better-graph-${use_better_graph}")
+          set(test_path "${prefix}-${case}")
+          if (use_better_graph)
+            set(autogen_files_config_suffix "_${target_config}")
+          else()
+            set(autogen_files_config_suffix "")
+          endif()
+          set(RunCMake_TEST_VARIANT_DESCRIPTION "-automoc-check")
+          run_ninja(${test_path} "" build-${ninja_config}.ninja -t query exe_autogen/timestamp${autogen_files_config_suffix})
+        endforeach()
+      endforeach()
+    endforeach()
   endif()
 endif()