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.
This commit is contained in:
Matt McCormick 2012-11-01 20:21:29 +00:00 committed by Brad King
parent 0a34433dfb
commit de760c1fa3
1 changed files with 26 additions and 10 deletions

View File

@ -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()