summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-09-22 14:31:29 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-09-22 14:32:34 (GMT)
commitd832c1cc7d717623b2eb07a940c85ca427a8084e (patch)
treeb6df341db1b3a8b8e323efb5676cb9ba50711cff /Tests
parentf4c21d4953afe1c638226a0e8db2f0a887665f38 (diff)
downloadCMake-d832c1cc7d717623b2eb07a940c85ca427a8084e.zip
CMake-d832c1cc7d717623b2eb07a940c85ca427a8084e.tar.gz
CMake-d832c1cc7d717623b2eb07a940c85ca427a8084e.tar.bz2
separate_arguments: add option PROGRAM
Fixes: #21217
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/separate_arguments/ProgramCommand.cmake48
-rw-r--r--Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake28
-rw-r--r--Tests/RunCMake/separate_arguments/ProgramOnly-result.txt1
-rw-r--r--Tests/RunCMake/separate_arguments/ProgramOnly-stderr.txt5
-rw-r--r--Tests/RunCMake/separate_arguments/ProgramOnly.cmake2
-rw-r--r--Tests/RunCMake/separate_arguments/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/separate_arguments/SeparateArgsOnly-result.txt1
-rw-r--r--Tests/RunCMake/separate_arguments/SeparateArgsOnly-stderr.txt4
-rw-r--r--Tests/RunCMake/separate_arguments/SeparateArgsOnly.cmake2
9 files changed, 96 insertions, 0 deletions
diff --git a/Tests/RunCMake/separate_arguments/ProgramCommand.cmake b/Tests/RunCMake/separate_arguments/ProgramCommand.cmake
new file mode 100644
index 0000000..bdf5810
--- /dev/null
+++ b/Tests/RunCMake/separate_arguments/ProgramCommand.cmake
@@ -0,0 +1,48 @@
+
+separate_arguments (out UNIX_COMMAND PROGRAM "xx a b c")
+if (out)
+ message (SEND_ERROR "unexpected result with nonexistent program")
+endif()
+
+set (TEST_EXE_DIR "${CMAKE_CURRENT_BINARY_DIR}/TestExe")
+file(MAKE_DIRECTORY "${TEST_EXE_DIR}")
+file(COPY "${CMAKE_COMMAND}" DESTINATION "${TEST_EXE_DIR}")
+cmake_path (GET CMAKE_COMMAND FILENAME cmake_exe)
+
+set (ENV{PATH} "${TEST_EXE_DIR}")
+
+
+separate_arguments (out UNIX_COMMAND PROGRAM "${cmake_exe}")
+list (LENGTH out length)
+if (length EQUAL 0)
+ message(FATAL_ERROR "existent program not found")
+endif()
+if (NOT length EQUAL 2)
+ message(FATAL_ERROR "unexpected arguments")
+endif()
+list(GET out 0 cmake)
+list(GET out 1 args)
+if (NOT cmake STREQUAL "${TEST_EXE_DIR}/${cmake_exe}")
+ message (SEND_ERROR "bad path for program: '${cmake}' instead of '${TEST_EXE_DIR}/${cmake_exe}'")
+endif()
+if (NOT args STREQUAL "")
+ message (SEND_ERROR "bad value for args: '${args}' instead of ''")
+endif()
+
+
+separate_arguments (out UNIX_COMMAND PROGRAM "${cmake_exe} a b c")
+list (LENGTH out length)
+if (length EQUAL 0)
+ message(FATAL_ERROR "existent program not found")
+endif()
+if (NOT length EQUAL 2)
+ message(FATAL_ERROR "unexpected arguments")
+endif()
+list(GET out 0 cmake)
+list(GET out 1 args)
+if (NOT cmake STREQUAL "${TEST_EXE_DIR}/${cmake_exe}")
+ message (SEND_ERROR "bad path for program: '${cmake}' instead of '${TEST_EXE_DIR}/${cmake_exe}'")
+endif()
+if (NOT args STREQUAL " a b c")
+ message (SEND_ERROR "bad value for args: '${args}' instead of ' a b c'")
+endif()
diff --git a/Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake b/Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake
new file mode 100644
index 0000000..2826cc9
--- /dev/null
+++ b/Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake
@@ -0,0 +1,28 @@
+
+separate_arguments (out UNIX_COMMAND PROGRAM SEPARATE_ARGS "xx a b c")
+if (out)
+ message (SEND_ERROR "unexpected result with nonexistent program")
+endif()
+
+set (TEST_EXE_DIR "${CMAKE_CURRENT_BINARY_DIR}/TestExe")
+file(MAKE_DIRECTORY "${TEST_EXE_DIR}")
+file(COPY "${CMAKE_COMMAND}" DESTINATION "${TEST_EXE_DIR}")
+cmake_path (GET CMAKE_COMMAND FILENAME cmake_exe)
+
+set (ENV{PATH} "${TEST_EXE_DIR}")
+
+separate_arguments (out UNIX_COMMAND PROGRAM SEPARATE_ARGS "${cmake_exe} a b c")
+list (LENGTH out length)
+if (length EQUAL 0)
+ message(FATAL_ERROR "existent program not found")
+endif()
+if (NOT length EQUAL 4)
+ message(FATAL_ERROR "unexpected arguments")
+endif()
+list(POP_FRONT out cmake)
+if (NOT cmake STREQUAL "${TEST_EXE_DIR}/${cmake_exe}")
+ message (SEND_ERROR "bad path for program: '${cmake}' instead of '${TEST_EXE_DIR}/${cmake_exe}'")
+endif()
+if (NOT out STREQUAL "a;b;c")
+ message (SEND_ERROR "bad path for args: '${out}' instead of 'a;b;c'")
+endif()
diff --git a/Tests/RunCMake/separate_arguments/ProgramOnly-result.txt b/Tests/RunCMake/separate_arguments/ProgramOnly-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/separate_arguments/ProgramOnly-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/separate_arguments/ProgramOnly-stderr.txt b/Tests/RunCMake/separate_arguments/ProgramOnly-stderr.txt
new file mode 100644
index 0000000..e34ca4c
--- /dev/null
+++ b/Tests/RunCMake/separate_arguments/ProgramOnly-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at ProgramOnly.cmake:[0-9]+ \(separate_arguments\):
+ separate_arguments missing required option: 'UNIX_COMMAND' or
+ 'WINDOWS_COMMAND' or 'NATIVE_COMMAND'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/separate_arguments/ProgramOnly.cmake b/Tests/RunCMake/separate_arguments/ProgramOnly.cmake
new file mode 100644
index 0000000..cc21d2b
--- /dev/null
+++ b/Tests/RunCMake/separate_arguments/ProgramOnly.cmake
@@ -0,0 +1,2 @@
+
+separate_arguments (var PROGRAM arg)
diff --git a/Tests/RunCMake/separate_arguments/RunCMakeTest.cmake b/Tests/RunCMake/separate_arguments/RunCMakeTest.cmake
index ed0f052..3c02c49 100644
--- a/Tests/RunCMake/separate_arguments/RunCMakeTest.cmake
+++ b/Tests/RunCMake/separate_arguments/RunCMakeTest.cmake
@@ -2,9 +2,14 @@ include(RunCMake)
run_cmake(MultipleCommands)
run_cmake(MultipleArguments)
+run_cmake(ProgramOnly)
+run_cmake(SeparateArgsOnly)
run_cmake(EmptyCommand)
run_cmake(PlainCommand)
run_cmake(UnixCommand)
run_cmake(WindowsCommand)
run_cmake(NativeCommand)
+
+run_cmake(ProgramCommand)
+run_cmake(ProgramCommandWithSeparateArgs)
diff --git a/Tests/RunCMake/separate_arguments/SeparateArgsOnly-result.txt b/Tests/RunCMake/separate_arguments/SeparateArgsOnly-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/separate_arguments/SeparateArgsOnly-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/separate_arguments/SeparateArgsOnly-stderr.txt b/Tests/RunCMake/separate_arguments/SeparateArgsOnly-stderr.txt
new file mode 100644
index 0000000..e87b1cb
--- /dev/null
+++ b/Tests/RunCMake/separate_arguments/SeparateArgsOnly-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at SeparateArgsOnly.cmake:[0-9]+ \(separate_arguments\):
+ separate_arguments `SEPARATE_ARGS` option requires `PROGRAM' option
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/separate_arguments/SeparateArgsOnly.cmake b/Tests/RunCMake/separate_arguments/SeparateArgsOnly.cmake
new file mode 100644
index 0000000..876fd7c
--- /dev/null
+++ b/Tests/RunCMake/separate_arguments/SeparateArgsOnly.cmake
@@ -0,0 +1,2 @@
+
+separate_arguments (var UNIX_COMMAND SEPARATE_ARGS arg)