summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt McCormick <matt.mccormick@kitware.com>2012-11-01 20:21:29 (GMT)
committerBrad King <brad.king@kitware.com>2012-11-13 18:35:07 (GMT)
commitde760c1fa39ba6d052344dc1052b4b47086998ae (patch)
treeab55c693109b0fa0a3e4688b153fd7ca1a337d37
parent0a34433dfbd001c5144a2a5889a35a98579f9760 (diff)
downloadCMake-de760c1fa39ba6d052344dc1052b4b47086998ae.zip
CMake-de760c1fa39ba6d052344dc1052b4b47086998ae.tar.gz
CMake-de760c1fa39ba6d052344dc1052b4b47086998ae.tar.bz2
ExternalProject: Verify when a fetch occurs during update test.
The performance feature of only performing a git fetch when needed during the ExternalProject update step is verified during the test. A fetch is identified by removing the FETCH_HEAD file and checking for its reincarnation.
-rw-r--r--Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake36
1 files changed, 26 insertions, 10 deletions
diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
index 0f9a999..080dd4a 100644
--- a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
+++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
@@ -1,7 +1,15 @@
# 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)
+# resulting checked out version is resulting_sha and rebuild.
+# This check's the correct behavior of the ExternalProject UPDATE_COMMAND.
+# Also verify that a fetch only occurs when fetch_expected is 1.
+macro(check_a_tag desired_tag resulting_sha fetch_expected)
+ message( STATUS "Checking ExternalProjectUpdate to tag: ${desired_tag}" )
+
+ # Remove the FETCH_HEAD file, so we can check if it gets replaced with a 'git
+ # fetch'.
+ set( FETCH_HEAD_file ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals/Source/TutorialStep1-GIT/.git/FETCH_HEAD )
+ file( REMOVE ${FETCH_HEAD_file} )
+
# Configure
execute_process(COMMAND ${CMAKE_COMMAND}
-G ${CMAKE_TEST_GENERATOR}
@@ -43,18 +51,26 @@ when
was expected."
)
endif()
+
+ if( NOT EXISTS ${FETCH_HEAD_file} AND ${fetch_expected})
+ message( FATAL_ERROR "Fetch did NOT occur when it was expected.")
+ endif()
+ if( EXISTS ${FETCH_HEAD_file} AND NOT ${fetch_expected})
+ message( FATAL_ERROR "Fetch DID occur when it was not expected.")
+ endif()
endmacro()
find_package(Git)
if(GIT_EXECUTABLE)
- check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7)
- check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a)
+ check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1)
+ check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a 1)
# 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)
+ check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a 0)
+ check_a_tag(tag2 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1)
+ check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a 1)
+ check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a 0)
+ check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1)
# This is a remote symbolic ref, so it will always trigger a 'git fetch'
- check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7)
+ check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1)
endif()