summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CPack/VerifyResult.cmake
diff options
context:
space:
mode:
authorDomen Vrankar <domen.vrankar@gmail.com>2015-06-05 19:03:26 (GMT)
committerBrad King <brad.king@kitware.com>2015-06-15 19:09:07 (GMT)
commite726fc025a3543c0be8a4eb217b0a80f9c16051c (patch)
tree2ed4f4114caff68ff16d06fc2e0e518ff6f5a771 /Tests/RunCMake/CPack/VerifyResult.cmake
parent092f1539af99e031c99a74d5a0f24731f58bf10a (diff)
downloadCMake-e726fc025a3543c0be8a4eb217b0a80f9c16051c.zip
CMake-e726fc025a3543c0be8a4eb217b0a80f9c16051c.tar.gz
CMake-e726fc025a3543c0be8a4eb217b0a80f9c16051c.tar.bz2
Tests: Add RunCMake tests for CPack{Deb,RPM}
Add script structure for easier addition of new CPack related tests.
Diffstat (limited to 'Tests/RunCMake/CPack/VerifyResult.cmake')
-rw-r--r--Tests/RunCMake/CPack/VerifyResult.cmake91
1 files changed, 91 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake
new file mode 100644
index 0000000..809011b
--- /dev/null
+++ b/Tests/RunCMake/CPack/VerifyResult.cmake
@@ -0,0 +1,91 @@
+cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+
+include("${config_file}")
+include("${src_dir}/${GENERATOR_TYPE}/Helpers.cmake")
+
+file(READ "${bin_dir}/test_output.txt" output)
+file(READ "${bin_dir}/test_error.txt" error)
+file(READ "${config_file}" config_file_content)
+
+set(output_error_message
+ "\nCPack output: '${output}'\nCPack error: '${error}';\nconfig file: '${config_file_content}'")
+
+# check that expected generated files exist and contain expected content
+include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-ExpectedFiles.cmake")
+
+if(NOT EXPECTED_FILES_COUNT EQUAL 0)
+ foreach(file_no_ RANGE 1 ${EXPECTED_FILES_COUNT})
+ file(GLOB foundFile_ RELATIVE "${bin_dir}" "${EXPECTED_FILE_${file_no_}}")
+ set(foundFiles_ "${foundFiles_};${foundFile_}")
+ list(LENGTH foundFile_ foundFilesCount_)
+
+ if(foundFilesCount_ EQUAL 1)
+ unset(PACKAGE_CONTENT)
+ getPackageContent("${bin_dir}/${foundFile_}" "PACKAGE_CONTENT")
+
+ string(REGEX MATCH "${EXPECTED_FILE_CONTENT_${file_no_}}"
+ expected_content_list "${PACKAGE_CONTENT}")
+
+ if(NOT expected_content_list)
+ message(FATAL_ERROR
+ "Unexpected file content for file No. '${file_no_}'!"
+ " Content: '${PACKAGE_CONTENT}'"
+ "${output_error_message}")
+ endif()
+ else()
+ message(FATAL_ERROR
+ "Found more than one file for file No. '${file_no_}'!"
+ " Found files count '${foundFilesCount_}'."
+ " Files: '${foundFile_}'"
+ "${output_error_message}")
+ endif()
+ endforeach()
+
+ # check that there were no extra files generated
+ foreach(all_files_glob_ IN LISTS ALL_FILES_GLOB)
+ file(GLOB foundAll_ RELATIVE "${bin_dir}" "${all_files_glob_}")
+ set(allFoundFiles_ "${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()
+
+ # sanity check that we didn't accidentaly list wrong files with our regular
+ # expressions
+ foreach(expected_ IN LISTS allFoundFiles_)
+ list(FIND foundFiles_ "${expected_}" found_)
+
+ if(found_ EQUAL -1)
+ message(FATAL_ERROR
+ "Expected files don't match found files! Found files:"
+ " '${allFoundFiles_}'"
+ "${output_error_message}")
+ endif()
+ endforeach()
+else()
+ # there should be no generated files present
+ foreach(missing_file_glob_ IN LISTS ALL_FILES_GLOB)
+ file(GLOB checkMissingFiles_ RELATIVE "${bin_dir}" "${missing_file_glob_}")
+
+ if(checkMissingFiles_)
+ message(FATAL_ERROR "Unexpected files found: '${checkMissingFiles_}'"
+ "${output_error_message}")
+ endif()
+ endforeach()
+endif()
+
+# handle additional result verifications
+if(EXISTS "${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-VerifyResult.cmake")
+ include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-VerifyResult.cmake")
+else()
+ # by default only print out output and error so that they can be compared by
+ # regex
+ message(STATUS "${output}")
+ message("${error}")
+endif()