Просмотр исходного кода

Merge topic 'test-mingw-no-vs'

a62313b1dd Tests: Fix testing with MinGW without VS installed
a02b70a23f Tests: Forward tested CMake generator to more cases

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Merge-request: !10170
Brad King 1 год назад
Родитель
Сommit
a41b1d66cd

+ 12 - 2
Tests/CMakeLib/CMakeLists.txt

@@ -111,10 +111,20 @@ if(CMake_ENABLE_DEBUGGER)
   add_executable(testDebuggerNamedPipe testDebuggerNamedPipe.cxx)
   target_link_libraries(testDebuggerNamedPipe PRIVATE CMakeLib)
   set(testDebuggerNamedPipe_Project_ARGS
-    "$<TARGET_FILE:cmake>" ${CMAKE_CURRENT_SOURCE_DIR}/DebuggerSample ${CMAKE_CURRENT_BINARY_DIR}/DebuggerSample
+    "$<TARGET_FILE:cmake>" -S ${CMAKE_CURRENT_SOURCE_DIR}/DebuggerSample -B ${CMAKE_CURRENT_BINARY_DIR}/DebuggerSample
+    --fresh -G ${CMAKE_GENERATOR}
     )
+  if(CMAKE_GENERATOR_PLATFORM)
+    list(APPEND testDebuggerNamedPipe_Project_ARGS -A "${CMAKE_GENERATOR_PLATFORM}")
+  endif()
+  if(CMAKE_GENERATOR_TOOLSET)
+    list(APPEND testDebuggerNamedPipe_Project_ARGS -T "${CMAKE_GENERATOR_TOOLSET}")
+  endif()
+  if(CMAKE_GENERATOR_INSTANCE)
+    list(APPEND testDebuggerNamedPipe_Project_ARGS "-DCMAKE_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE}")
+  endif()
   set(testDebuggerNamedPipe_Script_ARGS
-    "$<TARGET_FILE:cmake>" ${CMAKE_CURRENT_SOURCE_DIR}/DebuggerSample/script.cmake
+    "$<TARGET_FILE:cmake>" -P ${CMAKE_CURRENT_SOURCE_DIR}/DebuggerSample/script.cmake
     )
   foreach(case Project Script)
     add_test(NAME CMakeLib.testDebuggerNamedPipe-${case} COMMAND testDebuggerNamedPipe ${testDebuggerNamedPipe_${case}_ARGS})

+ 10 - 18
Tests/CMakeLib/testDebuggerNamedPipe.cxx

@@ -12,6 +12,9 @@
 #include <thread>
 #include <vector>
 
+#include <cm/string_view>
+#include <cmext/string_view>
+
 #include <cm3p/cppdap/io.h>
 
 #include "cmsys/RegularExpression.hxx"
@@ -60,22 +63,20 @@ static void sendCommands(std::shared_ptr<dap::ReaderWriter> const& debugger,
  */
 int runTest(int argc, char* argv[])
 {
-  if (argc < 3) {
+  if (argc < 4) {
     std::cout << "Usage:\n";
-    std::cout << "\t(project mode) TestDebuggerNamedPipe <CMakePath> "
-                 "<SourceFolder> <OutputFolder>\n";
-    std::cout << "\t(script mode) TestDebuggerNamedPipe <CMakePath> "
+    std::cout << "\t(project mode) TestDebuggerNamedPipe <CMakePath> -S "
+                 "<SourceFolder> -B <OutputFolder> ...\n";
+    std::cout << "\t(script mode) TestDebuggerNamedPipe <CMakePath> -P "
                  "<ScriptPath>\n";
     return 1;
   }
 
-  bool scriptMode = argc == 3;
-
 #ifdef _WIN32
   std::string namedPipe = R"(\\.\pipe\LOCAL\CMakeDebuggerPipe_)" +
-    cmCryptoHash(cmCryptoHash::AlgoSHA256)
-      .HashString(scriptMode ? argv[2] : argv[3]);
+    cmCryptoHash(cmCryptoHash::AlgoSHA256).HashString(argv[2]);
 #else
+  bool const scriptMode = argv[2] == "-P"_s;
   std::string namedPipe =
     std::string("CMakeDebuggerPipe") + (scriptMode ? "Script" : "Project");
 #endif
@@ -85,16 +86,7 @@ int runTest(int argc, char* argv[])
   cmakeCommand.emplace_back("--debugger");
   cmakeCommand.emplace_back("--debugger-pipe");
   cmakeCommand.emplace_back(namedPipe);
-
-  if (scriptMode) {
-    cmakeCommand.emplace_back("-P");
-    cmakeCommand.emplace_back(argv[2]);
-  } else {
-    cmakeCommand.emplace_back("-S");
-    cmakeCommand.emplace_back(argv[2]);
-    cmakeCommand.emplace_back("-B");
-    cmakeCommand.emplace_back(argv[3]);
-  }
+  cmakeCommand.insert(cmakeCommand.end(), argv + 2, argv + argc);
 
   // Capture debugger response stream.
   std::stringstream debuggerResponseStream;

+ 1 - 1
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/check_installed.cmake

@@ -4,7 +4,7 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
   check_installed([[^lib;lib/libdep8\.so;lib/liblib\.so;subdir;subdir/bin;subdir/bin/exe1;subdir/bin/exe2;subdir/lib;subdir/lib/libdep10\.so;subdir/lib/libdep11\.so;subdir/lib/libdep2\.so\.1;subdir/lib/libdep2\.so\.1\.2\.3;subdir/lib/libdep3\.so;subdir/lib/libdep5\.so;subdir/lib/libdep6\.so;subdir/lib/libdep8\.so;subdir/lib/libdep9\.so;subdir/lib/liblib\.so;subdir/lib/libmod\.so;subdir/lib/libsublib1\.so$]])
 elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
   set(_msvc_check [[bin;bin/dep8\.dll;bin/lib\.dll;lib;lib/lib\.(lib|l);subdir;subdir/bin;subdir/bin/dep10\.dll;subdir/bin/dep11\.dll;subdir/bin/dep2\.dll;subdir/bin/dep3\.dll;subdir/bin/dep5\.dll;subdir/bin/dep6\.dll;subdir/bin/dep8\.dll;subdir/bin/dep9\.dll;subdir/bin/exe1\.exe;subdir/bin/exe2\.exe;subdir/bin/lib\.dll;subdir/bin/sublib1\.dll;subdir/lib;subdir/lib/mod\.dll]])
-  set(_mingw_check [[bin;bin/libdep8\.dll;bin/liblib\.dll;lib;lib/liblib\.dll\.a;lib/liblib\.lib;subdir;subdir/bin;subdir/bin/exe1\.exe;subdir/bin/exe2\.exe;subdir/bin/libdep10\.dll;subdir/bin/libdep11\.dll;subdir/bin/libdep2\.dll;subdir/bin/libdep3\.dll;subdir/bin/libdep5\.dll;subdir/bin/libdep6\.dll;subdir/bin/libdep8\.dll;subdir/bin/libdep9\.dll;subdir/bin/liblib\.dll;subdir/bin/libsublib1\.dll;subdir/lib;subdir/lib/libmod\.dll]])
+  set(_mingw_check [[bin;bin/libdep8\.dll;bin/liblib\.dll;lib;lib/liblib\.dll\.a(;lib/liblib\.lib)?;subdir;subdir/bin;subdir/bin/exe1\.exe;subdir/bin/exe2\.exe;subdir/bin/libdep10\.dll;subdir/bin/libdep11\.dll;subdir/bin/libdep2\.dll;subdir/bin/libdep3\.dll;subdir/bin/libdep5\.dll;subdir/bin/libdep6\.dll;subdir/bin/libdep8\.dll;subdir/bin/libdep9\.dll;subdir/bin/liblib\.dll;subdir/bin/libsublib1\.dll;subdir/lib;subdir/lib/libmod\.dll]])
   check_installed("^(${_msvc_check}|${_mingw_check})$")
 elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
   check_installed([[^lib;lib/libdep8\.dylib;lib/liblib\.dylib;subdir;subdir/bin;subdir/bin/exe1;subdir/bin/exe2;subdir/frameworks;subdir/frameworks/dep9\.framework;subdir/frameworks/dep9\.framework/Resources;subdir/frameworks/dep9\.framework/Versions;subdir/frameworks/dep9\.framework/Versions/A;subdir/frameworks/dep9\.framework/Versions/A/Resources;subdir/frameworks/dep9\.framework/Versions/A/Resources/Info\.plist(;subdir/frameworks/dep9.framework/Versions/A/_CodeSignature;subdir/frameworks/dep9.framework/Versions/A/_CodeSignature/CodeResources)?;subdir/frameworks/dep9\.framework/Versions/A/dep9;subdir/frameworks/dep9\.framework/Versions/Current;subdir/frameworks/dep9\.framework/dep9;subdir/lib;subdir/lib/libdep10\.dylib;subdir/lib/libdep11\.dylib;subdir/lib/libdep2\.1\.2\.3\.dylib;subdir/lib/libdep2\.1\.dylib;subdir/lib/libdep3\.dylib;subdir/lib/libdep5\.dylib;subdir/lib/libdep6\.dylib;subdir/lib/libdep8\.dylib;subdir/lib/liblib\.dylib;subdir/lib/libmod\.so;subdir/lib/libsublib1\.dylib$]])

+ 9 - 7
Tests/RunCMake/CMakeListFileName/RunCMakeTest.cmake

@@ -1,15 +1,17 @@
 include(RunCMake)
 
 block()
+  set(RunCMake_TEST_NO_SOURCE_DIR 1)
   set(source ${RunCMake_SOURCE_DIR}/project)
-  run_cmake_command(dont-set-file ${CMAKE_COMMAND} -S ${source})
-  run_cmake_command(set-file-dne ${CMAKE_COMMAND} -S ${source} --project-file dne.cmake)
-  run_cmake_command(set-file-multi ${CMAKE_COMMAND} -S ${source} --project-file 1 --project-file 2)
-  run_cmake_command(set-file-none ${CMAKE_COMMAND} -S ${source} --project-file)
+  run_cmake_with_options(dont-set-file -S ${source})
+  run_cmake_with_options(set-file-dne -S ${source} --project-file dne.cmake)
+  run_cmake_with_options(set-file-multi -S ${source} --project-file 1 --project-file 2)
+  run_cmake_with_options(set-file-none -S ${source} --project-file)
 
   set(RunCMake_TEST_NO_CLEAN 1)
   set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/other)
-  run_cmake_command(set-file ${CMAKE_COMMAND} -S ${source} --project-file other.cmake)
-  run_cmake_command(remembers-file ${CMAKE_COMMAND} -S ${source})
-  run_cmake_command(cant-change-file ${CMAKE_COMMAND} -S ${source} --project-file another.cmake)
+  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+  run_cmake_with_options(set-file -S ${source} --project-file other.cmake)
+  run_cmake_with_options(remembers-file -S ${source})
+  run_cmake_with_options(cant-change-file -S ${source} --project-file another.cmake)
 endblock()

+ 2 - 1
Tests/RunCMake/CMakePresets/IncludeOutsideProject.json.in

@@ -5,7 +5,8 @@
   ],
   "configurePresets": [
     {
-      "name": "IncludeOutsideProject"
+      "name": "IncludeOutsideProject",
+      "generator": "@RunCMake_GENERATOR@"
     }
   ]
 }

+ 2 - 1
Tests/RunCMake/CMakePresets/IncludeUserOutsideProjectUser.json.in

@@ -5,7 +5,8 @@
   ],
   "configurePresets": [
     {
-      "name": "IncludeUserOutsideProject"
+      "name": "IncludeUserOutsideProject",
+      "generator": "@RunCMake_GENERATOR@"
     }
   ]
 }

+ 2 - 1
Tests/RunCMake/CMakePresetsPackage/ListPresets.json.in

@@ -2,7 +2,8 @@
   "version": 6,
   "configurePresets": [
     {
-      "name": "default"
+      "name": "default",
+      "generator": "@RunCMake_GENERATOR@"
     }
   ],
   "packagePresets": [

+ 1 - 1
Tests/RunCMake/CommandLine/Envgen-bad-help-stdout.txt

@@ -1,2 +1,2 @@
 Generators.*
-\* (Unix Makefiles|Visual Studio).*
+\* (Unix Makefiles|NMake Makefiles|Visual Studio).*

+ 1 - 1
Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt

@@ -2,4 +2,4 @@
 CMake Error: CMAKE_GENERATOR was set but the specified generator doesn't exist. Using CMake default.
 
 Generators.*
-\* (Unix Makefiles|Visual Studio).*
+\* (Unix Makefiles|NMake Makefiles|Visual Studio).*

+ 1 - 1
Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt

@@ -1,4 +1,4 @@
 ^CMake Error: No generator specified for -G
 
 Generators.*
-\* (Unix Makefiles|Visual Studio).*
+\* (Unix Makefiles|NMake Makefiles|Visual Studio).*

+ 1 - 1
Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt

@@ -4,4 +4,4 @@ Warning: Environment variable CMAKE_GENERATOR_TOOLSET will be ignored, because C
 CMake Error: No generator specified for -G
 
 Generators.*
-\* (Unix Makefiles|Visual Studio).*
+\* (Unix Makefiles|NMake Makefiles|Visual Studio).*