Tests: Teach RunCMake to optionally merge command output to stdout

Some tests may need to read "cmake --build" output passed through from
native build tools and do not know if it will be on stdout or stderr.
Optionally use the same variable for the execute_process output so
that it merges them and we can always match using expected stdout.
This commit is contained in:
Brad King 2015-04-07 09:06:51 -04:00
parent 9b7213dc47
commit 1535dcd894
1 changed files with 8 additions and 2 deletions

View File

@ -54,12 +54,18 @@ function(run_cmake test)
if(RunCMake_MAKE_PROGRAM)
list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}")
endif()
if(RunCMake_TEST_OUTPUT_MERGE)
set(actual_stderr_var actual_stdout)
set(actual_stderr "")
else()
set(actual_stderr_var actual_stderr)
endif()
if(RunCMake_TEST_COMMAND)
execute_process(
COMMAND ${RunCMake_TEST_COMMAND}
WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
OUTPUT_VARIABLE actual_stdout
ERROR_VARIABLE actual_stderr
ERROR_VARIABLE ${actual_stderr_var}
RESULT_VARIABLE actual_result
)
else()
@ -73,7 +79,7 @@ function(run_cmake test)
${RunCMake_TEST_OPTIONS}
WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
OUTPUT_VARIABLE actual_stdout
ERROR_VARIABLE actual_stderr
ERROR_VARIABLE ${actual_stderr_var}
RESULT_VARIABLE actual_result
)
endif()