From a02b70a23fa33434597f1c30d6c3fee2cb2f4294 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 13 Jan 2025 14:49:55 -0500 Subject: Tests: Forward tested CMake generator to more cases --- Tests/CMakeLib/CMakeLists.txt | 14 +++++++++-- Tests/CMakeLib/testDebuggerNamedPipe.cxx | 28 ++++++++-------------- .../RunCMake/CMakeListFileName/RunCMakeTest.cmake | 16 +++++++------ .../CMakePresets/IncludeOutsideProject.json.in | 3 ++- .../IncludeUserOutsideProjectUser.json.in | 3 ++- .../CMakePresetsPackage/ListPresets.json.in | 3 ++- 6 files changed, 37 insertions(+), 30 deletions(-) diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index de08d56..dda1622 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/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 - "$" ${CMAKE_CURRENT_SOURCE_DIR}/DebuggerSample ${CMAKE_CURRENT_BINARY_DIR}/DebuggerSample + "$" -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 - "$" ${CMAKE_CURRENT_SOURCE_DIR}/DebuggerSample/script.cmake + "$" -P ${CMAKE_CURRENT_SOURCE_DIR}/DebuggerSample/script.cmake ) foreach(case Project Script) add_test(NAME CMakeLib.testDebuggerNamedPipe-${case} COMMAND testDebuggerNamedPipe ${testDebuggerNamedPipe_${case}_ARGS}) diff --git a/Tests/CMakeLib/testDebuggerNamedPipe.cxx b/Tests/CMakeLib/testDebuggerNamedPipe.cxx index 67e1372..781afb0 100644 --- a/Tests/CMakeLib/testDebuggerNamedPipe.cxx +++ b/Tests/CMakeLib/testDebuggerNamedPipe.cxx @@ -12,6 +12,9 @@ #include #include +#include +#include + #include #include "cmsys/RegularExpression.hxx" @@ -60,22 +63,20 @@ static void sendCommands(std::shared_ptr const& debugger, */ int runTest(int argc, char* argv[]) { - if (argc < 3) { + if (argc < 4) { std::cout << "Usage:\n"; - std::cout << "\t(project mode) TestDebuggerNamedPipe " - " \n"; - std::cout << "\t(script mode) TestDebuggerNamedPipe " + std::cout << "\t(project mode) TestDebuggerNamedPipe -S " + " -B ...\n"; + std::cout << "\t(script mode) TestDebuggerNamedPipe -P " "\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; diff --git a/Tests/RunCMake/CMakeListFileName/RunCMakeTest.cmake b/Tests/RunCMake/CMakeListFileName/RunCMakeTest.cmake index c787900..147590e 100644 --- a/Tests/RunCMake/CMakeListFileName/RunCMakeTest.cmake +++ b/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() diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProject.json.in b/Tests/RunCMake/CMakePresets/IncludeOutsideProject.json.in index cf1928f..f84494f 100644 --- a/Tests/RunCMake/CMakePresets/IncludeOutsideProject.json.in +++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProject.json.in @@ -5,7 +5,8 @@ ], "configurePresets": [ { - "name": "IncludeOutsideProject" + "name": "IncludeOutsideProject", + "generator": "@RunCMake_GENERATOR@" } ] } diff --git a/Tests/RunCMake/CMakePresets/IncludeUserOutsideProjectUser.json.in b/Tests/RunCMake/CMakePresets/IncludeUserOutsideProjectUser.json.in index 5b5427a..c7436c7 100644 --- a/Tests/RunCMake/CMakePresets/IncludeUserOutsideProjectUser.json.in +++ b/Tests/RunCMake/CMakePresets/IncludeUserOutsideProjectUser.json.in @@ -5,7 +5,8 @@ ], "configurePresets": [ { - "name": "IncludeUserOutsideProject" + "name": "IncludeUserOutsideProject", + "generator": "@RunCMake_GENERATOR@" } ] } diff --git a/Tests/RunCMake/CMakePresetsPackage/ListPresets.json.in b/Tests/RunCMake/CMakePresetsPackage/ListPresets.json.in index 5f3cf48..95dbb02 100644 --- a/Tests/RunCMake/CMakePresetsPackage/ListPresets.json.in +++ b/Tests/RunCMake/CMakePresetsPackage/ListPresets.json.in @@ -2,7 +2,8 @@ "version": 6, "configurePresets": [ { - "name": "default" + "name": "default", + "generator": "@RunCMake_GENERATOR@" } ], "packagePresets": [ -- cgit v0.12 From a62313b1dd9258c7be2cb738930bf0c40891e8df Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 13 Jan 2025 14:51:02 -0500 Subject: Tests: Fix testing with MinGW without VS installed --- .../Import/install-RUNTIME_DEPENDENCIES/check_installed.cmake | 2 +- Tests/RunCMake/CommandLine/Envgen-bad-help-stdout.txt | 2 +- Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt | 2 +- Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt | 2 +- Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/check_installed.cmake b/Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/check_installed.cmake index 447a5b6..8b193f6 100644 --- a/Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/check_installed.cmake +++ b/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$]]) diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-help-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-bad-help-stdout.txt index 075c48c..cd43295 100644 --- a/Tests/RunCMake/CommandLine/Envgen-bad-help-stdout.txt +++ b/Tests/RunCMake/CommandLine/Envgen-bad-help-stdout.txt @@ -1,2 +1,2 @@ Generators.* -\* (Unix Makefiles|Visual Studio).* +\* (Unix Makefiles|NMake Makefiles|Visual Studio).* diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt index 4a1215e..aebe93a 100644 --- a/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt +++ b/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).* diff --git a/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt index ec6ec92..12085ad 100644 --- a/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt +++ b/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).* diff --git a/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt index 47f9c9e..68d1d12 100644 --- a/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt +++ b/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).* -- cgit v0.12