Merge branch 'test-RunCMake-check' into enhance-include_external_msproject

This commit is contained in:
Brad King 2012-04-19 08:34:56 -04:00
commit f3191f5bc0
2 changed files with 19 additions and 9 deletions

View File

@ -24,11 +24,16 @@
# 4.) Create a <SubTest>.cmake file for each sub-test named above # 4.) Create a <SubTest>.cmake file for each sub-test named above
# containing the actual test code. Optionally create files # containing the actual test code. Optionally create files
# containing expected test results: # containing expected test results:
# <SubTest>-result.txt = Process result expected if not "0" # <SubTest>-result.txt = Process result expected if not "0"
# <SubTest>-stdout.txt = Regex matching expected stdout content # <SubTest>-stdout.txt = Regex matching expected stdout content
# <SubTest>-stderr.txt = Regex matching expected stderr content # <SubTest>-stderr.txt = Regex matching expected stderr content
# <SubTest>-check.cmake = Custom result check
# Note that trailing newlines will be stripped from actual test # Note that trailing newlines will be stripped from actual test
# output before matching against the stdout and stderr expressions. # output before matching against the stdout and stderr expressions.
# The code in <SubTest>-check.cmake may use variables
# RunCMake_TEST_SOURCE_DIR = Top of test source tree
# RunCMake_TEST_BINARY_DIR = Top of test binary tree
# and an failure must store a message in RunCMake_TEST_FAILED.
macro(add_RunCMake_test test) macro(add_RunCMake_test test)
add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND} add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND}

View File

@ -25,14 +25,14 @@ function(run_cmake test)
unset(expect_std${o}) unset(expect_std${o})
endif() endif()
endforeach() endforeach()
set(source_dir "${top_src}") set(RunCMake_TEST_SOURCE_DIR "${top_src}")
set(binary_dir "${top_bin}/${test}-build") set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build")
file(REMOVE_RECURSE "${binary_dir}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${binary_dir}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
execute_process( execute_process(
COMMAND ${CMAKE_COMMAND} "${source_dir}" COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}"
-G "${RunCMake_GENERATOR}" -DRunCMake_TEST=${test} -G "${RunCMake_GENERATOR}" -DRunCMake_TEST=${test}
WORKING_DIRECTORY "${binary_dir}" WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
OUTPUT_VARIABLE actual_stdout OUTPUT_VARIABLE actual_stdout
ERROR_VARIABLE actual_stderr ERROR_VARIABLE actual_stderr
RESULT_VARIABLE actual_result RESULT_VARIABLE actual_result
@ -53,6 +53,11 @@ function(run_cmake test)
endif() endif()
endif() endif()
endforeach() endforeach()
unset(RunCMake_TEST_FAILED)
include(${top_src}/${test}-check.cmake OPTIONAL)
if(RunCMake_TEST_FAILED)
set(msg "${RunCMake_TEST_FAILED}\n${msg}")
endif()
if(msg) if(msg)
string(REGEX REPLACE "\n" "\n actual-out> " actual_out " actual-out> ${actual_stdout}") string(REGEX REPLACE "\n" "\n actual-out> " actual_out " actual-out> ${actual_stdout}")
string(REGEX REPLACE "\n" "\n actual-err> " actual_err " actual-err> ${actual_stderr}") string(REGEX REPLACE "\n" "\n actual-err> " actual_err " actual-err> ${actual_stderr}")