summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLib/testUVProcessChain.cxx19
-rw-r--r--Tests/RunCMake/Make/Foo/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake32
-rw-r--r--Tests/RunCMake/Make/GNUMakeJobServerAware.cmake27
4 files changed, 69 insertions, 13 deletions
diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx
index 7630aa0..22373ef 100644
--- a/Tests/CMakeLib/testUVProcessChain.cxx
+++ b/Tests/CMakeLib/testUVProcessChain.cxx
@@ -652,6 +652,20 @@ bool testUVProcessChainInputFile(const char* helperCommand)
return true;
}
+bool testUVProcessChainWait0(const char* helperCommand)
+{
+ cmUVProcessChainBuilder builder;
+ builder.AddCommand({ helperCommand, "echo" });
+
+ auto chain = builder.Start();
+ if (!chain.Wait(0)) {
+ std::cout << "Wait(0) returned false, should be true" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
int testUVProcessChain(int argc, char** const argv)
{
if (argc < 2) {
@@ -699,5 +713,10 @@ int testUVProcessChain(int argc, char** const argv)
return -1;
}
+ if (!testUVProcessChainWait0(argv[1])) {
+ std::cout << "While executing testUVProcessChainWait0().\n";
+ return -1;
+ }
+
return 0;
}
diff --git a/Tests/RunCMake/Make/Foo/CMakeLists.txt b/Tests/RunCMake/Make/Foo/CMakeLists.txt
new file mode 100644
index 0000000..baa6634
--- /dev/null
+++ b/Tests/RunCMake/Make/Foo/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.26)
+project(Foo NONE)
+
+add_custom_target(drive ALL COMMAND ${CMAKE_COMMAND} -E true)
diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake
index 7c5c296..da18f00 100644
--- a/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake
+++ b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake
@@ -1,12 +1,26 @@
-# This test verifies that the commands in the generated Makefiles contain the
-# `+` prefix
-function(check_for_plus_prefix target)
- set(file "${RunCMake_BINARY_DIR}/GNUMakeJobServerAware-build/${target}")
- file(READ "${file}" build_file)
- if(NOT "${build_file}" MATCHES [[\+]])
- message(FATAL_ERROR "The file ${file} does not contain the expected prefix in the custom command.")
+set(BUILD_DIR "${RunCMake_BINARY_DIR}/GNUMakeJobServerAware-build")
+
+function(check target line)
+ # Read the file and split it into a list of lines
+ file(READ ${BUILD_DIR}/${target} contents)
+ STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
+ STRING(REGEX REPLACE "\n" ";" contents "${contents}")
+
+ set(found FALSE)
+ foreach(entry ${contents})
+ if("${entry}" MATCHES "${line}")
+ set(found TRUE)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT found)
+ message(FATAL_ERROR "Could not find '${line}' in ${BUILD_DIR}/${target}\n${contents}")
endif()
endfunction()
-check_for_plus_prefix("CMakeFiles/dummy.dir/build.make")
-check_for_plus_prefix("CMakeFiles/dummy2.dir/build.make")
+check("CMakeFiles/dummy.dir/build.make" [[\+\$\(CMAKE_COMMAND\) -E true]])
+check("CMakeFiles/dummy2.dir/build.make" [[\+\$\(CMAKE_COMMAND\) -E true]])
+
+check("CMakeFiles/dummy3.dir/build.make" [[\+cd (/d )?"?.*"? && \$\(CMAKE_COMMAND\) -E true]])
+check("CMakeFiles/dummy4.dir/build.make" [[\+cd (/d )?"?.*"? && \$\(CMAKE_COMMAND\) -E true]])
diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake
index 951c2d7..d92e842 100644
--- a/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake
+++ b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake
@@ -1,12 +1,31 @@
+# Test JOB_SERVER_AWARE with custom commands
add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/custom-command"
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/missing"
JOB_SERVER_AWARE ON
- COMMAND $(CMAKE_COMMAND) -E touch "${CMAKE_CURRENT_BINARY_DIR}/custom-command"
+ COMMAND $(CMAKE_COMMAND) -E true
)
-add_custom_target(dummy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/custom-command")
+add_custom_target(dummy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/missing")
+# Test JOB_SERVER_AWARE with custom targets
add_custom_target(
dummy2 ALL
JOB_SERVER_AWARE ON
- COMMAND ${CMAKE_COMMAND} -E true
+ COMMAND $(CMAKE_COMMAND) -E true
+)
+
+# Test JOB_SERVER_AWARE with custom commands with WORKING_DIRECTORY
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/missing2"
+ JOB_SERVER_AWARE ON
+ COMMAND $(CMAKE_COMMAND) -E true
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Foo"
+)
+add_custom_target(dummy3 ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/missing2")
+
+# Test JOB_SERVER_AWARE with custom targets with WORKING_DIRECTORY
+add_custom_target(
+ dummy4 ALL
+ JOB_SERVER_AWARE ON
+ COMMAND $(CMAKE_COMMAND) -E true
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Foo"
)