diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2020-02-21 14:20:45 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2020-02-24 13:44:14 (GMT) |
commit | 6ec274b00254977061b114489782910e02fc5343 (patch) | |
tree | 8af7e1450eb5c2187a6f6f21f023bd6a5413bb92 /Tests/RunCMake/execute_process | |
parent | 25ca8e5ce5019c0fb8648f7408b864add6b19d83 (diff) | |
download | CMake-6ec274b00254977061b114489782910e02fc5343.zip CMake-6ec274b00254977061b114489782910e02fc5343.tar.gz CMake-6ec274b00254977061b114489782910e02fc5343.tar.bz2 |
execute_process: Add ECHO_(OUTPUT|ERROR)_VARIABLE options
Fixes: #20378
Diffstat (limited to 'Tests/RunCMake/execute_process')
5 files changed, 31 insertions, 0 deletions
diff --git a/Tests/RunCMake/execute_process/EchoVariable-stderr.txt b/Tests/RunCMake/execute_process/EchoVariable-stderr.txt new file mode 100644 index 0000000..d927553 --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoVariable-stderr.txt @@ -0,0 +1,3 @@ +CMake Error at [^ +]*EchoVariableOutput.cmake:2 \(message\): + Text to stderr diff --git a/Tests/RunCMake/execute_process/EchoVariable-stdout.txt b/Tests/RunCMake/execute_process/EchoVariable-stdout.txt new file mode 100644 index 0000000..7c868bd --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoVariable-stdout.txt @@ -0,0 +1 @@ +-- Text to stdout diff --git a/Tests/RunCMake/execute_process/EchoVariable.cmake b/Tests/RunCMake/execute_process/EchoVariable.cmake new file mode 100644 index 0000000..99999c7 --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoVariable.cmake @@ -0,0 +1,23 @@ +execute_process( + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/EchoVariableOutput.cmake + OUTPUT_VARIABLE stdout + ERROR_QUIET + ECHO_OUTPUT_VARIABLE +) + +file(READ ${CMAKE_CURRENT_LIST_DIR}/EchoVariable-stdout.txt expected_stdout) +if (NOT stdout MATCHES "${expected_stdout}") + message(FATAL_ERROR "stdout differs from the expected stdout") +endif() + +execute_process( + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/EchoVariableOutput.cmake + ERROR_VARIABLE stderr + OUTPUT_QUIET + ECHO_ERROR_VARIABLE +) + +file(READ ${CMAKE_CURRENT_LIST_DIR}/EchoVariable-stderr.txt expected_stderr) +if (NOT stderr MATCHES "${expected_stderr}") + message(FATAL_ERROR "stderr differs from the expected stderr") +endif() diff --git a/Tests/RunCMake/execute_process/EchoVariableOutput.cmake b/Tests/RunCMake/execute_process/EchoVariableOutput.cmake new file mode 100644 index 0000000..e636567 --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoVariableOutput.cmake @@ -0,0 +1,2 @@ +message(STATUS "Text to stdout") +message(FATAL_ERROR "Text to stderr") diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake index b203aab..89ad6b2 100644 --- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake +++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake @@ -24,3 +24,5 @@ run_cmake_command(EchoCommand2 ${CMAKE_COMMAND} -P run_cmake_command(EchoCommand3 ${CMAKE_COMMAND} -DCHECK_ERROR_OUTPUT_LOCATION=TRUE -P ${RunCMake_SOURCE_DIR}/EchoCommand.cmake) + +run_cmake_command(EchoVariable ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/EchoVariable.cmake) |