From 45935ac973a280ea9602ba17aa448d94a66a056d Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jun 2021 10:51:49 -0400 Subject: Tests: Improve CPackComponentsForAll test error formatting Format message content for `message(FATAL_ERROR)`. --- Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index 31e843a..3e1c13d 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -115,8 +115,17 @@ execute_process(COMMAND ${CMAKE_CPACK_COMMAND} ${config_verbose} -G ${CPackGen} ERROR_VARIABLE CPack_error WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR}) +string(REPLACE "\n" "\n cpack-out> " cpack_out "\n${CPack_output}") +string(REPLACE "\n" "\n cpack-err> " cpack_err "\n${CPack_error}") +string(REPLACE "\n" "\n cpack-res> " cpack_res "\n${CPack_result}") +string(CONCAT output_error_message + "CPack output:${cpack_out}\n" + "CPack error:${cpack_err}\n" + "CPack result:${cpack_res}\n" + ) + if(CPack_result) - message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}") + message(FATAL_ERROR "error: CPack execution went wrong!,\n${output_error_message}") else () message(STATUS "CPack_output=${CPack_output}") endif() @@ -132,13 +141,13 @@ if(expected_file_mask) message(STATUS "expected_file_mask='${expected_file_mask}'") if(NOT expected_file) - message(FATAL_ERROR "error: expected_file does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}") + message(FATAL_ERROR "error: expected_file does not exist: CPackComponentsForAll test fails.\n${output_error_message}") endif() list(LENGTH expected_file actual_count) message(STATUS "actual_count='${actual_count}'") if(NOT actual_count EQUAL expected_count) - message(FATAL_ERROR "error: expected_count=${expected_count} does not match actual_count=${actual_count}: CPackComponents test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error})") + message(FATAL_ERROR "error: expected_count=${expected_count} does not match actual_count=${actual_count}: CPackComponents test fails.\n${output_error_message}") endif() if(expect_dmg_sla) -- cgit v0.12