summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-02-15 16:28:16 (GMT)
committerBrad King <brad.king@kitware.com>2022-02-16 17:10:19 (GMT)
commit67f97f54789413f47a0f03a36c3bb32518a2e922 (patch)
tree75ff938566ef64d4fd219f2f74e66dc99b1a738b /Tests/RunCMake
parenta15cc7706da8f4a1833539be3f37fbc63ee20e36 (diff)
downloadCMake-67f97f54789413f47a0f03a36c3bb32518a2e922.zip
CMake-67f97f54789413f47a0f03a36c3bb32518a2e922.tar.gz
CMake-67f97f54789413f47a0f03a36c3bb32518a2e922.tar.bz2
Tests: Add RunCMake helper to run cmake with raw execute_process args
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/RunCMake.cmake17
1 files changed, 15 insertions, 2 deletions
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index 6f79b78..9f692ee 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -119,12 +119,16 @@ function(run_cmake test)
else()
set(RunCMake_TEST_OPTIONS "")
endif()
+ if(NOT DEFINED RunCMake_TEST_RAW_ARGS)
+ set(RunCMake_TEST_RAW_ARGS "")
+ endif()
if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY)
set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
endif()
- execute_process(
+ string(CONCAT _code [[execute_process(
COMMAND ${RunCMake_TEST_COMMAND}
${RunCMake_TEST_OPTIONS}
+ ]] "${RunCMake_TEST_RAW_ARGS}\n" [[
WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}"
OUTPUT_VARIABLE actual_stdout
ERROR_VARIABLE ${actual_stderr_var}
@@ -132,7 +136,8 @@ function(run_cmake test)
ENCODING UTF8
${maybe_timeout}
${maybe_input_file}
- )
+ )]])
+ cmake_language(EVAL CODE "${_code}")
set(msg "")
if(NOT "${actual_result}" MATCHES "${expect_result}")
string(APPEND msg "Result is [${actual_result}], not [${expect_result}].\n")
@@ -196,6 +201,9 @@ function(run_cmake test)
string(REPLACE ";" "\" \"" options "\"${RunCMake_TEST_OPTIONS}\"")
string(APPEND command " ${options}")
endif()
+ if(RunCMake_TEST_RAW_ARGS)
+ string(APPEND command " ${RunCMake_TEST_RAW_ARGS}")
+ endif()
string(APPEND msg "Command was:\n command> ${command}\n")
endif()
if(msg)
@@ -228,6 +236,11 @@ function(run_cmake_with_options test)
run_cmake(${test})
endfunction()
+function(run_cmake_with_raw_args test args)
+ set(RunCMake_TEST_RAW_ARGS "${args}")
+ run_cmake(${test})
+endfunction()
+
function(ensure_files_match expected_file actual_file)
if(NOT EXISTS "${expected_file}")
message(FATAL_ERROR "Expected file does not exist:\n ${expected_file}")