Skip to content

Commit

Permalink
ExternalProject: Verify when a fetch occurs during update test.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thewtex committed Nov 1, 2012
1 parent bb93797 commit 4dee3a0
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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(GIT_EXECUTABLE)

6 comments on commit 4dee3a0

@dlrdave
Copy link

@dlrdave dlrdave commented on 4dee3a0 Nov 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I'll do my best to get this into CMake 'next' soon, so it can be in 'master' well in time for the anticipated end-of-January 2.8.11 release.

@dlrdave
Copy link

@dlrdave dlrdave commented on 4dee3a0 Nov 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rebased your ExternalProjectUpdate branch on current 'master' and pushed it to the cmake stage repository at git://cmake.org/stage/cmake.git as the "only-git-fetch-when-necessary" branch.

When I build it and run the tests on my Mac, though:

$ ctest -R ExternalProjectUpdate --output-on-failure
Test project /Users/davidcole/Dashboards/My Tests/CMake Mac-unix-Debug
Guessing configuration NoConfig
    Start 115: ExternalProjectUpdateSetup
1/2 Test #115: ExternalProjectUpdateSetup .......   Passed    1.86 sec
    Start 116: ExternalProjectUpdate
2/2 Test #116: ExternalProjectUpdate ............***Failed    2.37 sec
-- Found Git: /usr/bin/git (found version "1.7.5.4") 
-- Checking ExternalProjectUpdate to tag: origin/master
-- git_version='1.7.5.4'
-- do_git_tests='1'
-- GIT_EXECUTABLE='/usr/bin/git'
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/davidcole/Dashboards/My Tests/CMake Mac-unix-Debug/Tests/ExternalProjectUpdate
[  6%] Creating directories for 'SetupLocalGITRepository'
[ 12%] Performing download step (verify and extract) for 'SetupLocalGITRepository'
-- verifying file...
     file='/Users/davidcole/Dashboards/My Tests/CMake/Tests/ExternalProjectUpdate/gitrepo.tgz'
-- verifying file... warning: did not verify file - no URL_HASH specified?
-- extracting...
     src='/Users/davidcole/Dashboards/My Tests/CMake/Tests/ExternalProjectUpdate/gitrepo.tgz'
     dst='/Users/davidcole/Dashboards/My Tests/CMake Mac-unix-Debug/Tests/ExternalProjectUpdate/LocalRepositories/GIT'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 18%] No patch step for 'SetupLocalGITRepository'
[ 25%] No update step for 'SetupLocalGITRepository'
[ 31%] Performing configure step for 'SetupLocalGITRepository'
git version 1.7.5.4
[ 37%] No build step for 'SetupLocalGITRepository'
[ 43%] No install step for 'SetupLocalGITRepository'
[ 50%] Completed 'SetupLocalGITRepository'
[ 50%] Built target SetupLocalGITRepository
[ 56%] Creating directories for 'TutorialStep1-GIT'
[ 62%] Performing download step (git clone) for 'TutorialStep1-GIT'
-- Avoiding repeated git clone, stamp file is up to date: '/Users/davidcole/Dashboards/My Tests/CMake Mac-unix-Debug/Tests/ExternalProjectUpdate/CMakeExternals/Stamp/TutorialStep1-GIT/TutorialStep1-GIT-gitclone-lastrun.txt'
[ 68%] No patch step for 'TutorialStep1-GIT'
[ 75%] Performing update step (git fetch) for 'TutorialStep1-GIT'
Previous HEAD position was d197073... Initial import into repo.
HEAD is now at 5842b50... Improve comment formatting.
[ 81%] Performing configure step for 'TutorialStep1-GIT'
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/davidcole/Dashboards/My Tests/CMake Mac-unix-Debug/Tests/ExternalProjectUpdate/CMakeExternals/Build/TutorialStep1-GIT
[ 87%] Performing build step for 'TutorialStep1-GIT'
Linking CXX executable Tutorial
[100%] Built target Tutorial
[ 93%] No install step for 'TutorialStep1-GIT'
[100%] Completed 'TutorialStep1-GIT'
[100%] Built target TutorialStep1-GIT
-- Checking ExternalProjectUpdate to tag: tag1
-- git_version='1.7.5.4'
-- do_git_tests='1'
-- GIT_EXECUTABLE='/usr/bin/git'
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/davidcole/Dashboards/My Tests/CMake Mac-unix-Debug/Tests/ExternalProjectUpdate
[ 50%] Built target SetupLocalGITRepository
[ 56%] Performing update step (git fetch) for 'TutorialStep1-GIT'
Previous HEAD position was 5842b50... Improve comment formatting.
HEAD is now at d197073... Initial import into repo.
[ 62%] Performing configure step for 'TutorialStep1-GIT'
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/davidcole/Dashboards/My Tests/CMake Mac-unix-Debug/Tests/ExternalProjectUpdate/CMakeExternals/Build/TutorialStep1-GIT
[ 68%] Performing build step for 'TutorialStep1-GIT'
[100%] Built target Tutorial
[ 75%] No install step for 'TutorialStep1-GIT'
[ 81%] Completed 'TutorialStep1-GIT'
[100%] Built target TutorialStep1-GIT
-- Checking ExternalProjectUpdate to tag: tag1
-- git_version='1.7.5.4'
-- do_git_tests='1'
-- GIT_EXECUTABLE='/usr/bin/git'
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/davidcole/Dashboards/My Tests/CMake Mac-unix-Debug/Tests/ExternalProjectUpdate
[ 50%] Built target SetupLocalGITRepository
[ 56%] Performing update step (git fetch) for 'TutorialStep1-GIT'
HEAD is now at d197073... Initial import into repo.
[ 62%] Performing configure step for 'TutorialStep1-GIT'
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/davidcole/Dashboards/My Tests/CMake Mac-unix-Debug/Tests/ExternalProjectUpdate/CMakeExternals/Build/TutorialStep1-GIT
[ 68%] Performing build step for 'TutorialStep1-GIT'
[100%] Built target Tutorial
[ 75%] No install step for 'TutorialStep1-GIT'
[ 81%] Completed 'TutorialStep1-GIT'
[100%] Built target TutorialStep1-GIT
CMake Error at ExternalProjectUpdateTest.cmake:59 (message):
  Fetch DID occur when it was not expected.
Call Stack (most recent call first):
  ExternalProjectUpdateTest.cmake:69 (check_a_tag)




50% tests passed, 1 tests failed out of 2

Total Test time (real) =   5.50 sec

The following tests FAILED:
    116 - ExternalProjectUpdate (Failed)
Errors while running CTest

Do the tests pass for you?

@thewtex
Copy link
Owner Author

@thewtex thewtex commented on 4dee3a0 Nov 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for giving it a try. I'll try your rebased version and also in a path with spaces, ...

@thewtex
Copy link
Owner Author

@thewtex thewtex commented on 4dee3a0 Nov 6, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have confirmed the test failure on a Mac/Git 1.7.4.4 (dash5) as opposed to where I did the development (Linux/Git 1.7.8.6). Will take a further look...

@thewtex
Copy link
Owner Author

@thewtex thewtex commented on 4dee3a0 Nov 8, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear internets:

David helped me figure out the problem here: we made sure the test was using the built cmake instead of the cmake associated with the ctest used to drive the test. The fix has been added to the branch on the "stage" remote.

Thanks to Dave!

@dlrdave
Copy link

@dlrdave dlrdave commented on 4dee3a0 Nov 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear thewtex:

Dave says you're welcome. And the stage branch has been merged to next for dashboard testing. Now we're almost done: we just have to get it running/passing on all the dashboard clients.

Fondly,
internets

Please sign in to comment.