diff options
Diffstat (limited to 'Tests')
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) |