diff options
author | Dave Abrahams <dabrahams@adobe.com> | 2024-05-22 19:01:16 (GMT) |
---|---|---|
committer | Dave Abrahams <dabrahams@adobe.com> | 2024-05-24 20:41:01 (GMT) |
commit | 45b3387c50cb9516eb8ff6b88e537f0d97cd8404 (patch) | |
tree | f7956af49b85303c129c725c337e2bba6211d552 /Tests | |
parent | 50252733c46025d7086d7b0ea6daef04e0c5346f (diff) | |
download | CMake-45b3387c50cb9516eb8ff6b88e537f0d97cd8404.zip CMake-45b3387c50cb9516eb8ff6b88e537f0d97cd8404.tar.gz CMake-45b3387c50cb9516eb8ff6b88e537f0d97cd8404.tar.bz2 |
Tests/RunCMake/Swift: Enable more cases with Ninja Multi-Config
Also factor out testing that's common across Xcode and Ninja.* generators.
- Ninja expected output files were extended to accept directories named
after the configuration in paths.
- Tests that previously ran with Ninja were allowed to run with Ninja
Multi-Config.
- Swift/RunCMakeTest.cmake:
- Checks for conditions where little or no testing could be done
were moved to the top of the file, with return()s to limit nesting
of the remainder of the code ("Early bailouts").
- CMP0157 tests, which were being performed for all generators, were
factored out into a block at the top of the file.
- RunCMake_TEST_OPTIONS is set initially for all multi-config
generators and list(APPEND)'ed-to in each block() where it was previously
set() and unset().
Diffstat (limited to 'Tests')
7 files changed, 116 insertions, 114 deletions
diff --git a/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt b/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt index d593b92..4fb69be 100644 --- a/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt +++ b/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt @@ -1 +1 @@ -swiftc(.exe)? .* -output-file-map CMakeFiles(/|\\)greetings_default.dir(//|\\\\)output-file-map.json .* +swiftc(.exe)? .* -output-file-map CMakeFiles(/|\\)greetings_default.dir(/|\\)(Debug)?(/|\\)output-file-map.json .* diff --git a/Tests/RunCMake/Swift/CompileCommands-check.cmake b/Tests/RunCMake/Swift/CompileCommands-check.cmake index 6450745..e33a027 100644 --- a/Tests/RunCMake/Swift/CompileCommands-check.cmake +++ b/Tests/RunCMake/Swift/CompileCommands-check.cmake @@ -11,13 +11,13 @@ set(expected_compile_commands "directory": ".*(/Tests/RunCMake/Swift/CompileCommands-build|\\\\Tests\\\\RunCMake\\\\Swift\\\\CompileCommands-build)", "command": ".*swiftc .* (\\")?.*(/Tests/RunCMake/Swift/E.swift|\\\\Tests\\\\RunCMake\\\\Swift\\\\E.swift)(\\")? (\\")?.*(/Tests/RunCMake/Swift/L.swift|\\\\Tests\\\\RunCMake\\\\Swift\\\\L.swift)(\\")?", "file": ".*(/Tests/RunCMake/Swift/E.swift|\\\\Tests\\\\RunCMake\\\\Swift\\\\E.swift)", - "output": "CMakeFiles/CompileCommandLib.dir/E.swift.o|CMakeFiles\\\\CompileCommandLib.dir\\\\E.swift.obj" + "output": "CMakeFiles/CompileCommandLib.dir/(Debug(/|\\))?E.swift.o|CMakeFiles\\\\CompileCommandLib.dir\\\\E.swift.obj" }, { "directory": ".*(/Tests/RunCMake/Swift/CompileCommands-build|\\\\Tests\\\\RunCMake\\\\Swift\\\\CompileCommands-build)", "command": ".*swiftc .* (\\")?.*(/Tests/RunCMake/Swift/E.swift|\\\\Tests\\\\RunCMake\\\\Swift\\\\E.swift)(\\")? (\\")?.*(/Tests/RunCMake/Swift/L.swift|\\\\Tests\\\\RunCMake\\\\Swift\\\\L.swift)(\\")?", "file": ".*/Tests/RunCMake/Swift/L.swift", - "output": "CMakeFiles/CompileCommandLib.dir/L.swift.o|CMakeFiles\\\\CompileCommandLib.dir\\\\L.swift.obj" + "output": "CMakeFiles/CompileCommandLib.dir/(Debug(/|\\))?L.swift.o|CMakeFiles\\\\CompileCommandLib.dir\\\\L.swift.obj" } ]$]==] ) diff --git a/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt b/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt index ec396d7..adea1f1 100644 --- a/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt +++ b/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt @@ -1,2 +1,2 @@ -swiftc(.exe)? -j [0-9]+ -num-threads [0-9]+ -c @CMakeFiles(/|\\)L.dir(/|\\)L.o(bj)?.swift.rsp -.*swiftc(.exe)? -emit-library -static -o (libL.a|L.lib) @CMakeFiles(/|\\)L.rsp +swiftc(.exe)? -j [0-9]+ -num-threads [0-9]+ -c @CMakeFiles(/|\\)L.dir(/|\\)(Debug(/|\\))?L.o(bj)?.swift.rsp +.*swiftc(.exe)? -emit-library -static -o (Debug(/|\\))?(libL.a|L.lib) @CMakeFiles(/|\\)L.(Debug\.)?rsp diff --git a/Tests/RunCMake/Swift/ForceResponseFile.cmake b/Tests/RunCMake/Swift/ForceResponseFile.cmake index 7fd4636..880ff72 100644 --- a/Tests/RunCMake/Swift/ForceResponseFile.cmake +++ b/Tests/RunCMake/Swift/ForceResponseFile.cmake @@ -2,8 +2,8 @@ if(POLICY CMP0157) cmake_policy(SET CMP0157 NEW) endif() -if(NOT CMAKE_GENERATOR STREQUAL "Ninja") - message(SEND_ERROR "this test must use Ninja generator, found ${CMAKE_GENERATOR} ") +if(NOT CMAKE_GENERATOR MATCHES "Ninja") + message(SEND_ERROR "this test must use a Ninja generator, found ${CMAKE_GENERATOR} ") endif() set(CMAKE_NINJA_FORCE_RESPONSE_FILE TRUE) diff --git a/Tests/RunCMake/Swift/IncrementalSwift-second-stderr.txt b/Tests/RunCMake/Swift/IncrementalSwift-second-stderr.txt index 3650fe5..0131378 100644 --- a/Tests/RunCMake/Swift/IncrementalSwift-second-stderr.txt +++ b/Tests/RunCMake/Swift/IncrementalSwift-second-stderr.txt @@ -1 +1 @@ -ninja explain: A.swiftmodule is dirty +ninja explain: (Debug(/|\\))?A.swiftmodule is dirty diff --git a/Tests/RunCMake/Swift/IncrementalSwift-second-stdout.txt b/Tests/RunCMake/Swift/IncrementalSwift-second-stdout.txt index ccd8aee..7bc8c75 100644 --- a/Tests/RunCMake/Swift/IncrementalSwift-second-stdout.txt +++ b/Tests/RunCMake/Swift/IncrementalSwift-second-stdout.txt @@ -1,3 +1,3 @@ .*Building Swift Module 'A' with 1 source .*Building Swift Module 'B' with 1 source -FAILED: B.swiftmodule CMakeFiles(/|\\)B.dir(/|\\)b.swift.o(bj)? +FAILED: (Debug(/|\\))?B.swiftmodule CMakeFiles(/|\\)B.dir(/|\\)(Debug(/|\\))?b.swift.o(bj)? diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake index e8a1dab..39f754c 100644 --- a/Tests/RunCMake/Swift/RunCMakeTest.cmake +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -1,122 +1,124 @@ include(RunCMake) -if(RunCMake_GENERATOR STREQUAL Xcode) - if(XCODE_VERSION VERSION_LESS 6.1) - run_cmake(XcodeTooOld) - elseif(CMake_TEST_Swift) - run_cmake(CMP0157-NEW) - run_cmake(CMP0157-OLD) - run_cmake(CMP0157-WARN) +# Early bailouts. +if(RunCMake_GENERATOR STREQUAL "Xcode" AND XCODE_VERSION VERSION_LESS 6.1) + run_cmake(XcodeTooOld) + return() +elseif(NOT CMake_TEST_Swift) + return() +elseif(NOT RunCMake_GENERATOR MATCHES "^Ninja|^Xcode$") + run_cmake(NotSupported) + return() +endif() + +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release") +endif() + +block() + run_cmake(CMP0157-NEW) + run_cmake(CMP0157-WARN) + + if(RunCMake_GENERATOR MATCHES "Ninja.*") + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0157-OLD-build) endif() -elseif(RunCMake_GENERATOR STREQUAL Ninja) - if(CMake_TEST_Swift) + + run_cmake(CMP0157-OLD) + + if(RunCMake_GENERATOR MATCHES "Ninja.*") + set(RunCMake_TEST_NO_CLEAN 1) + # -n: dry-run to avoid actually compiling, -v: verbose to capture executed command + run_cmake_command(CMP0157-OLD-build ${CMAKE_COMMAND} --build . -- -n -v) + endif() +endblock() + +if(RunCMake_GENERATOR MATCHES "Ninja") + run_cmake(SwiftSimple) + + block() if (CMAKE_SYSTEM_NAME MATCHES "Windows") run_cmake_with_options(Win32ExecutableDisallowed) else() run_cmake_with_options(Win32ExecutableIgnored) - set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Darwin) + list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Darwin) run_cmake(SwiftMultiArch) - unset(RunCMake_TEST_OPTIONS) endif() + endblock() - # Test that a second build with no changes does nothing. - block() - run_cmake(NoWorkToDo) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/NoWorkToDo-build) - set(RunCMake_TEST_OUTPUT_MERGE 1) - run_cmake_command(NoWorkToDo-build ${CMAKE_COMMAND} --build .) - run_cmake_command(NoWorkToDo-nowork ${CMAKE_COMMAND} --build . -- -d explain) - file(WRITE ${RunCMake_TEST_BINARY_DIR}/hello.swift "//No-op change\n") - run_cmake_command(NoWorkToDo-norelink ${CMAKE_COMMAND} --build . -- -d explain) - run_cmake_command(NoWorkToDo-nowork ${CMAKE_COMMAND} --build . -- -d explain) - endblock() - - # Test that intermediate static libraries are rebuilt when the public - # interface of their dependency changes - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/IncrementalSwift-build) - # Since files are modified during test, the files are created in the cmake - # file into the build directory - run_cmake(IncrementalSwift) - set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(IncrementalSwift-first ${CMAKE_COMMAND} --build .) + # Test that a second build with no changes does nothing. + block() + run_cmake(NoWorkToDo) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/NoWorkToDo-build) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(NoWorkToDo-build ${CMAKE_COMMAND} --build .) + run_cmake_command(NoWorkToDo-nowork ${CMAKE_COMMAND} --build . -- -d explain) + file(WRITE ${RunCMake_TEST_BINARY_DIR}/hello.swift "//No-op change\n") + run_cmake_command(NoWorkToDo-norelink ${CMAKE_COMMAND} --build . -- -d explain) + run_cmake_command(NoWorkToDo-nowork ${CMAKE_COMMAND} --build . -- -d explain) + endblock() - # Modify public interface of libA requiring rebuild of libB - file(WRITE ${RunCMake_TEST_BINARY_DIR}/a.swift - "public func callA() -> Float { return 32.0 }\n") + # Test that intermediate static libraries are rebuilt when the public + # interface of their dependency changes + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/IncrementalSwift-build) + # Since files are modified during test, the files are created in the cmake + # file into the build directory + run_cmake(IncrementalSwift) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(IncrementalSwift-first ${CMAKE_COMMAND} --build .) - # Note: We still expect this to fail, but instead of failure at link time, - # it should fail while re-compiling libB because the function changed - run_cmake_command(IncrementalSwift-second ${CMAKE_COMMAND} --build . -- -d explain) - endblock() + # Modify public interface of libA requiring rebuild of libB + file(WRITE ${RunCMake_TEST_BINARY_DIR}/a.swift + "public func callA() -> Float { return 32.0 }\n") - block() - run_cmake(CMP0157-NEW) - run_cmake(CMP0157-WARN) + # Note: We still expect this to fail, but instead of failure at link time, + # it should fail while re-compiling libB because the function changed + run_cmake_command(IncrementalSwift-second ${CMAKE_COMMAND} --build . -- -d explain) + endblock() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0157-OLD-build) - run_cmake(CMP0157-OLD) - set(RunCMake_TEST_NO_CLEAN 1) - # -n: dry-run to avoid actually compiling, -v: verbose to capture executed command - run_cmake_command(CMP0157-OLD-build ${CMAKE_COMMAND} --build . -- -n -v) - endblock() + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CompileCommands-build) + run_cmake(CompileCommands) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(CompileCommands-check ${CMAKE_COMMAND} --build .) + endblock() - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CompileCommands-build) - run_cmake(CompileCommands) - set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(CompileCommands-check ${CMAKE_COMMAND} --build .) - endblock() - - block() - # Try enabling Swift with a static-library try-compile - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/StaticLibTryCompile-build) - set(RunCMake_TEST_OPTIONS -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY) - run_cmake(EnableSwift) - endblock() - - block() - # Try enabling Swift with an executable try-compile - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExecutableTryCompile-build) - set(RunCMake_TEST_OPTIONS -DCMAKE_TRY_COMPILE_TARGET_TYPE=EXECUTABLE) - run_cmake(EnableSwift) - endblock() - - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ForceResponseFile-build) - run_cmake(ForceResponseFile) - set(RunCMake_TEST_NO_CLEAN 1) - # -v: verbose to capture executed commands -n: dry-run to avoid actually compiling - run_cmake_command(ForceResponseFile-check ${CMAKE_COMMAND} --build . -- -vn) - endblock() - - block() - if(CMAKE_SYSTEM_NAME MATCHES Windows) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ImportLibraryFlags-build) - run_cmake(ImportLibraryFlags) - set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(ImportLibraryFlags-check ${CMAKE_COMMAND} --build . -- -n -v) - endif() - endblock() - - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SwiftLibraryModuleCommand-build) - run_cmake(SwiftLibraryModuleCommand) + block() + # Try enabling Swift with a static-library try-compile + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/StaticLibTryCompile-build) + list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY) + run_cmake(EnableSwift) + endblock() + + block() + # Try enabling Swift with an executable try-compile + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExecutableTryCompile-build) + list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_TRY_COMPILE_TARGET_TYPE=EXECUTABLE) + run_cmake(EnableSwift) + endblock() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ForceResponseFile-build) + run_cmake(ForceResponseFile) + set(RunCMake_TEST_NO_CLEAN 1) + # -v: verbose to capture executed commands -n: dry-run to avoid actually compiling + run_cmake_command(ForceResponseFile-check ${CMAKE_COMMAND} --build . -- -vn) + endblock() + + block() + if(CMAKE_SYSTEM_NAME MATCHES Windows) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ImportLibraryFlags-build) + run_cmake(ImportLibraryFlags) set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(SwiftLibraryModuleCommand-check ${CMAKE_COMMAND} --build . -- -n -v) - endblock() - endif() -elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config") - if(CMake_TEST_Swift) - set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release") - run_cmake(SwiftSimple) - - run_cmake(CMP0157-NEW) - run_cmake(CMP0157-OLD) - run_cmake(CMP0157-WARN) - unset(RunCMake_TEST_OPTIONS) - endif() -else() - run_cmake(NotSupported) + run_cmake_command(ImportLibraryFlags-check ${CMAKE_COMMAND} --build . -- -n -v) + endif() + endblock() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SwiftLibraryModuleCommand-build) + run_cmake(SwiftLibraryModuleCommand) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(SwiftLibraryModuleCommand-check ${CMAKE_COMMAND} --build . -- -n -v) + endblock() endif() |