diff options
Diffstat (limited to 'Tests/TryCompile/CMakeLists.txt')
-rw-r--r-- | Tests/TryCompile/CMakeLists.txt | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 000fd2c..7c6f970 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -259,11 +259,32 @@ endif() if("${COMPILE_OUTPUT}" MATCHES "hello world") message(SEND_ERROR " COMPILE_OUT contains the run output: \"${COMPILE_OUTPUT}\"") endif() -# check the run output, it should stdout +# check the run output, it should contain stdout if(NOT "${RUN_OUTPUT}" MATCHES "hello world") message(SEND_ERROR " RUN_OUTPUT didn't contain \"hello world\": \"${RUN_OUTPUT}\"") endif() +# try to run a file and parse stdout and stderr separately +try_run(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE + ${TryCompile_BINARY_DIR} + ${TryCompile_SOURCE_DIR}/stdout_and_stderr.c + COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT + RUN_OUTPUT_STDOUT_VARIABLE RUN_OUTPUT_STDOUT + RUN_OUTPUT_STDERR_VARIABLE RUN_OUTPUT_STDERR) + +if(NOT SHOULD_COMPILE) + message(STATUS " exit_with_error failed compiling: ${COMPILE_OUTPUT}") +endif() + +# check the run stdout output +if(NOT "${RUN_OUTPUT_STDOUT}" MATCHES "hello world") + message(SEND_ERROR " RUN_OUTPUT_STDOUT didn't contain \"hello world\": \"${RUN_OUTPUT_STDOUT}\"") +endif() +# check the run stderr output +if(NOT "${RUN_OUTPUT_STDERR}" MATCHES "error") + message(SEND_ERROR " RUN_OUTPUT_STDERR didn't contain \"error\": \"${RUN_OUTPUT_STDERR}\"") +endif() + ####################################################################### # # also test that the CHECK_C_SOURCE_COMPILES, CHECK_CXX_SOURCE_COMPILES |