summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CPack/External/Helpers.cmake
blob: 2c67e0644fa479b839396b0f98183c4ba8df0797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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()