Merge topic 'test-RunCMake-fail-info'

e8065554a8 Tests: Teach RunCMake to always print the command on failure
5f03744e36 Tests: Move RunCMake option construction closer to use
f4d154755a Tests: Reverse RunCMake code path order
6fd7e8c53f Tests: Make RunCMake.Generator{Platform,Toolset} two-flag cases explicit

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5892
This commit is contained in:
Brad King
2021-03-10 16:21:45 +00:00
committed by Kitware Robot
3 changed files with 49 additions and 53 deletions
@@ -11,9 +11,9 @@ else()
run_cmake(BadPlatform)
endif()
set(RunCMake_GENERATOR_TOOLSET "")
set(RunCMake_GENERATOR_PLATFORM "")
set(RunCMake_TEST_OPTIONS -A "Extra Platform")
set(RunCMake_TEST_OPTIONS -A "Test Platform" -A "Extra Platform")
run_cmake(TwoPlatforms)
unset(RunCMake_TEST_OPTIONS)
@@ -76,7 +76,7 @@ endif()
set(RunCMake_GENERATOR_TOOLSET "")
set(RunCMake_TEST_OPTIONS -T "Extra Toolset")
set(RunCMake_TEST_OPTIONS -T "Test Toolset" -T "Extra Toolset")
run_cmake(TwoToolsets)
unset(RunCMake_TEST_OPTIONS)
+46 -50
View File
@@ -64,15 +64,6 @@ function(run_cmake test)
else()
include(${top_src}/${test}-prep.cmake OPTIONAL)
endif()
if(NOT DEFINED RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS "")
endif()
if(APPLE)
list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW)
endif()
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 "")
@@ -91,50 +82,51 @@ function(run_cmake test)
else()
set(maybe_input_file "")
endif()
if(RunCMake_TEST_COMMAND)
if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY)
set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
if(NOT RunCMake_TEST_COMMAND)
if(NOT DEFINED RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS "")
endif()
execute_process(
COMMAND ${RunCMake_TEST_COMMAND}
WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}"
OUTPUT_VARIABLE actual_stdout
ERROR_VARIABLE ${actual_stderr_var}
RESULT_VARIABLE actual_result
ENCODING UTF8
${maybe_timeout}
${maybe_input_file}
if(APPLE)
list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW)
endif()
if(RunCMake_MAKE_PROGRAM)
list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}")
endif()
set(RunCMake_TEST_COMMAND ${CMAKE_COMMAND})
if(NOT RunCMake_TEST_NO_SOURCE_DIR)
list(APPEND RunCMake_TEST_COMMAND "${RunCMake_TEST_SOURCE_DIR}")
endif()
list(APPEND RunCMake_TEST_COMMAND -G "${RunCMake_GENERATOR}")
if(RunCMake_GENERATOR_PLATFORM)
list(APPEND RunCMake_TEST_COMMAND -A "${RunCMake_GENERATOR_PLATFORM}")
endif()
if(RunCMake_GENERATOR_TOOLSET)
list(APPEND RunCMake_TEST_COMMAND -T "${RunCMake_GENERATOR_TOOLSET}")
endif()
if(RunCMake_GENERATOR_INSTANCE)
list(APPEND RunCMake_TEST_COMMAND "-DCMAKE_GENERATOR_INSTANCE=${RunCMake_GENERATOR_INSTANCE}")
endif()
list(APPEND RunCMake_TEST_COMMAND
-DRunCMake_TEST=${test}
--no-warn-unused-cli
)
else()
if(RunCMake_GENERATOR_INSTANCE)
set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE=${RunCMake_GENERATOR_INSTANCE}")
else()
set(_D_CMAKE_GENERATOR_INSTANCE "")
endif()
if(NOT RunCMake_TEST_NO_SOURCE_DIR)
set(maybe_source_dir "${RunCMake_TEST_SOURCE_DIR}")
else()
set(maybe_source_dir "")
endif()
execute_process(
COMMAND ${CMAKE_COMMAND}
${maybe_source_dir}
-G "${RunCMake_GENERATOR}"
-A "${RunCMake_GENERATOR_PLATFORM}"
-T "${RunCMake_GENERATOR_TOOLSET}"
${_D_CMAKE_GENERATOR_INSTANCE}
-DRunCMake_TEST=${test}
--no-warn-unused-cli
${RunCMake_TEST_OPTIONS}
WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
OUTPUT_VARIABLE actual_stdout
ERROR_VARIABLE ${actual_stderr_var}
RESULT_VARIABLE actual_result
ENCODING UTF8
${maybe_timeout}
${maybe_input_file}
)
set(RunCMake_TEST_OPTIONS "")
endif()
if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY)
set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
endif()
execute_process(
COMMAND ${RunCMake_TEST_COMMAND}
${RunCMake_TEST_OPTIONS}
WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}"
OUTPUT_VARIABLE actual_stdout
ERROR_VARIABLE ${actual_stderr_var}
RESULT_VARIABLE actual_result
ENCODING UTF8
${maybe_timeout}
${maybe_input_file}
)
set(msg "")
if(NOT "${actual_result}" MATCHES "${expect_result}")
string(APPEND msg "Result is [${actual_result}], not [${expect_result}].\n")
@@ -190,8 +182,12 @@ function(run_cmake test)
if(RunCMake_TEST_FAILED)
set(msg "${RunCMake_TEST_FAILED}\n${msg}")
endif()
if(msg AND RunCMake_TEST_COMMAND)
if(msg)
string(REPLACE ";" "\" \"" command "\"${RunCMake_TEST_COMMAND}\"")
if(RunCMake_TEST_OPTIONS)
string(REPLACE ";" "\" \"" options "\"${RunCMake_TEST_OPTIONS}\"")
string(APPEND command " ${options}")
endif()
string(APPEND msg "Command was:\n command> ${command}\n")
endif()
if(msg)