diff options
author | Domen Vrankar <domen.vrankar@gmail.com> | 2016-11-26 19:37:07 (GMT) |
---|---|---|
committer | Domen Vrankar <domen.vrankar@gmail.com> | 2016-11-27 22:20:35 (GMT) |
commit | 8575affa4c72e1c0d07f964d2f28eb6ddbadb291 (patch) | |
tree | c3a77601235a27d120bc983cbc56cdc493d7aa26 /Tests/RunCMake/CPack/tests/SOURCE_PACKAGE | |
parent | 79443e1b8b604de00d269e73a977f449bc3fcef2 (diff) | |
download | CMake-8575affa4c72e1c0d07f964d2f28eb6ddbadb291.zip CMake-8575affa4c72e1c0d07f964d2f28eb6ddbadb291.tar.gz CMake-8575affa4c72e1c0d07f964d2f28eb6ddbadb291.tar.bz2 |
Tests: CPack test move and merge VerifyResult
Merge VerifyResult of different generators
pertest and move the file to its test dir.
Diffstat (limited to 'Tests/RunCMake/CPack/tests/SOURCE_PACKAGE')
-rw-r--r-- | Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake new file mode 100644 index 0000000..a84e296 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake @@ -0,0 +1,63 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILD") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILDROOT") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SOURCES") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SPECS") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SRPMS") + +# make sure that we are using the version of cmake and cpack that we are testing +get_filename_component(cpack_path_ "${CMAKE_CPACK_COMMAND}" DIRECTORY) +set(ENV{PATH} "${cpack_path_}:$ENV{PATH}") + +execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}/test_rpm" --rebuild ${FOUND_FILE_1} + RESULT_VARIABLE result_ + ERROR_VARIABLE error_ + OUTPUT_QUIET + ) + +set(output_error_message_ + "\n${RPMBUILD_EXECUTABLE} error: '${error_}';\nresult: '${result_}';\n${output_error_message}") + +set(EXPECTED_FILE_CONTENT_ "^/foo${whitespaces_}/foo/test_prog$") + +file(GLOB_RECURSE FOUND_FILE_ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS" "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS/*.rpm") +list(APPEND foundFiles_ "${FOUND_FILE_}") +list(LENGTH FOUND_FILE_ foundFilesCount_) + +if(foundFilesCount_ EQUAL 1) + unset(PACKAGE_CONTENT) + getPackageContent("${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS/${FOUND_FILE_}" "PACKAGE_CONTENT") + + string(REGEX MATCH "${EXPECTED_FILE_CONTENT_}" + expected_content_list "${PACKAGE_CONTENT}") + + if(NOT expected_content_list) + message(FATAL_ERROR + "Unexpected file content!\n" + " Content: '${PACKAGE_CONTENT}'\n\n" + " Expected: '${EXPECTED_FILE_CONTENT_}'" + "${output_error_message_}") + endif() +else() + message(FATAL_ERROR + "Found more than one file!" + " Found files count '${foundFilesCount_}'." + " Files: '${FOUND_FILE_}'" + "${output_error_message_}") +endif() + +# check that there were no extra files generated +foreach(all_files_glob_ IN LISTS ALL_FILES_GLOB) + file(GLOB foundAll_ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS" "${all_files_glob_}") + list(APPEND allFoundFiles_ "${foundAll_}") +endforeach() + +list(LENGTH foundFiles_ foundFilesCount_) +list(LENGTH allFoundFiles_ allFoundFilesCount_) + +if(NOT foundFilesCount_ EQUAL allFoundFilesCount_) + message(FATAL_ERROR + "Found more files than expected! Found files: '${allFoundFiles_}'" + "${output_error_message_}") +endif() |