diff options
Diffstat (limited to 'Tests/RunCMake/CPack/External/Helpers.cmake')
-rw-r--r-- | Tests/RunCMake/CPack/External/Helpers.cmake | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPack/External/Helpers.cmake b/Tests/RunCMake/CPack/External/Helpers.cmake new file mode 100644 index 0000000000..2c67e0644f --- /dev/null +++ b/Tests/RunCMake/CPack/External/Helpers.cmake @@ -0,0 +1,31 @@ +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + set(${RESULT_VAR} "${NAME}-${VERSION}-*.json" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + set("${RESULT_VAR}" "" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + set("${CONTENT_VAR}" "" PARENT_SCOPE) +endfunction() + +set(ALL_FILES_GLOB "*.json") + +function(check_ext_json EXPECTED_FILE ACTUAL_FILE) + file(READ "${EXPECTED_FILE}" _expected_regex) + file(READ "${ACTUAL_FILE}" _actual_contents) + + string(REGEX REPLACE "\n+$" "" _expected_regex "${_expected_regex}") + string(REGEX REPLACE "\n+$" "" _actual_contents "${_actual_contents}") + + if(NOT "${_actual_contents}" MATCHES "${_expected_regex}") + message(FATAL_ERROR + "Output JSON does not match expected regex.\n" + "Expected regex:\n" + "${_expected_regex}\n" + "Actual output:\n" + "${_actual_contents}\n" + ) + endif() +endfunction() |