diff options
author | Matt McCormick <matt.mccormick@kitware.com> | 2012-07-27 16:26:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-11-13 18:34:22 (GMT) |
commit | 2619f4d87a0080cbe6e739529913bf28c0d93d12 (patch) | |
tree | 30a828b365729ae15c34fa74ad97eb11b45b6a3c /Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake | |
parent | 378aa127b4f335af77ddfe132e03343d8709c148 (diff) | |
download | CMake-2619f4d87a0080cbe6e739529913bf28c0d93d12.zip CMake-2619f4d87a0080cbe6e739529913bf28c0d93d12.tar.gz CMake-2619f4d87a0080cbe6e739529913bf28c0d93d12.tar.bz2 |
ExternalProject: Add tests for UPDATE_COMMAND.
Tests are added for UPDATE_COMMAND to ensure it is working properly. Testing
infrastructure is added along with tests for Git, but tests for other version
control systems could easily be added in the future.
Diffstat (limited to 'Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake')
-rw-r--r-- | Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake new file mode 100644 index 0000000..fed40ef --- /dev/null +++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake @@ -0,0 +1,58 @@ +# Set the ExternalProject GIT_TAG to desired_tag, and make sure the +# resulting checked out version is resulting_sha and a rebuild. +# This check's the viability of the ExternalProject UPDATE_COMMAND. +macro(check_a_tag desired_tag resulting_sha) + # Configure + execute_process(COMMAND ${CMAKE_COMMAND} + -G ${CMAKE_TEST_GENERATOR} + -DTEST_GIT_TAG:STRING=${desired_tag} + ${ExternalProjectUpdate_SOURCE_DIR} + WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR} + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR "Could not configure the project.") + endif() + + # Build + execute_process(COMMAND ${CMAKE_COMMAND} + --build ${ExternalProjectUpdate_BINARY_DIR} + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR "Could not build the project.") + endif() + + # Check the resulting SHA + execute_process(COMMAND ${GIT_EXECUTABLE} + rev-list --max-count=1 HEAD + WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals/Source/TutorialStep1-GIT + RESULT_VARIABLE error_code + OUTPUT_VARIABLE tag_sha + ) + if(error_code) + message(FATAL_ERROR "Could not check the sha.") + endif() + + string(STRIP "${tag_sha}" tag_sha) + if(NOT (${tag_sha} STREQUAL ${resulting_sha})) + message(FATAL_ERROR "UPDATE_COMMAND produced + ${tag_sha} +when + ${resulting_sha} +was expected." + ) + endif() +endmacro() + +find_package(Git) +if(GIT_EXECUTABLE) + check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7) + check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a) + # With the Git UPDATE_COMMAND performance patch, this will not required a + # 'git fetch' + check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a) + check_a_tag(tag2 5842b503ba4113976d9bb28d57b5aee1ad2736b7) + check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a) + check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7) +endif() |