1 # This script drives creation of a git repository and checks
2 # that CTest can update from it.
4 #-----------------------------------------------------------------------------
5 # Test in a directory next to this script.
6 get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH)
7 set(TOP "${TOP}/@CTestUpdateGIT_DIR@")
9 # Include code common to all update tests.
10 include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake")
12 #-----------------------------------------------------------------------------
13 # Report git tools in use.
14 message("Using GIT tools:")
15 set(GIT "@GIT_EXECUTABLE@")
16 message(" git = ${GIT}")
18 set(AUTHOR_CONFIG "[user]
20 \temail = testauthor@cmake.org
23 #-----------------------------------------------------------------------------
24 # Initialize the testing directory.
25 message("Creating test directory...")
28 #-----------------------------------------------------------------------------
29 # Create the repository.
30 message("Creating repository...")
31 file(MAKE_DIRECTORY ${TOP}/repo.git)
33 WORKING_DIRECTORY ${TOP}/repo.git
34 COMMAND ${GIT} --bare init
36 file(REMOVE_RECURSE ${TOP}/repo.git/hooks)
37 set(REPO file://${TOP}/repo.git)
39 #-----------------------------------------------------------------------------
40 # Import initial content into the repository.
41 message("Importing content...")
42 create_content(import)
44 # Import the content into the repository.
45 run_child(WORKING_DIRECTORY ${TOP}/import
48 file(REMOVE_RECURSE ${TOP}/import/.git/hooks)
49 file(APPEND ${TOP}/import/.git/config "
52 \tfetch = +refs/heads/*:refs/remotes/origin/*
54 run_child(WORKING_DIRECTORY ${TOP}/import
57 run_child(WORKING_DIRECTORY ${TOP}/import
58 COMMAND ${GIT} commit -m "Initial content"
60 run_child(WORKING_DIRECTORY ${TOP}/import
61 COMMAND ${GIT} push origin master:refs/heads/master
64 #-----------------------------------------------------------------------------
65 # Create a working tree.
66 message("Checking out revision 1...")
68 WORKING_DIRECTORY ${TOP}
69 COMMAND ${GIT} clone ${REPO} user-source
71 file(REMOVE_RECURSE ${TOP}/user-source/.git/hooks)
72 file(APPEND ${TOP}/user-source/.git/config "${AUTHOR_CONFIG}")
74 #-----------------------------------------------------------------------------
75 # Make changes in the working tree.
76 message("Changing content...")
77 update_content(user-source files_added files_removed dirs_added)
80 WORKING_DIRECTORY ${TOP}/user-source
81 COMMAND ${GIT} add ${dirs_added}
85 WORKING_DIRECTORY ${TOP}/user-source
86 COMMAND ${GIT} add ${files_added}
89 WORKING_DIRECTORY ${TOP}/user-source
90 COMMAND ${GIT} rm ${files_removed}
93 WORKING_DIRECTORY ${TOP}/user-source
97 #-----------------------------------------------------------------------------
98 # Commit the changes to the repository.
99 message("Committing revision 2...")
101 WORKING_DIRECTORY ${TOP}/user-source
102 COMMAND ${GIT} commit -m "Changed content"
105 WORKING_DIRECTORY ${TOP}/user-source
106 COMMAND ${GIT} push origin
109 #-----------------------------------------------------------------------------
110 # Make changes in the working tree.
111 message("Changing content again...")
112 change_content(user-source)
114 WORKING_DIRECTORY ${TOP}/user-source
115 COMMAND ${GIT} add -u
118 #-----------------------------------------------------------------------------
119 # Commit the changes to the repository.
120 message("Committing revision 3...")
122 WORKING_DIRECTORY ${TOP}/user-source
123 COMMAND ${GIT} commit -m "Changed content again"
126 WORKING_DIRECTORY ${TOP}/user-source
127 COMMAND ${GIT} push origin
130 #-----------------------------------------------------------------------------
131 # Go back to before the changes so we can test updating.
132 message("Backing up to revision 1...")
134 WORKING_DIRECTORY ${TOP}/user-source
135 COMMAND ${GIT} reset --hard master~2
138 # Create a modified file.
139 modify_content(user-source)
141 #-----------------------------------------------------------------------------
142 # Test updating the user work directory with the command-line interface.
143 message("Running CTest Dashboard Command Line...")
145 # Create the user build tree.
146 create_build_tree(user-source user-binary)
147 file(APPEND ${TOP}/user-binary/CTestConfiguration.ini
148 "# GIT command configuration
149 UpdateCommand: ${GIT}
152 # Run the dashboard command line interface.
153 run_dashboard_command_line(user-binary)
155 #-----------------------------------------------------------------------------
156 # Test initial checkout and update with a dashboard script.
157 message("Running CTest Dashboard Script...")
159 create_dashboard_script(dashboard.cmake
160 "# git command configuration
161 set(CTEST_GIT_COMMAND \"${GIT}\")
162 set(CTEST_GIT_UPDATE_OPTIONS)
164 WORKING_DIRECTORY \"${TOP}\"
165 COMMAND \"${GIT}\" clone \"${REPO}\" dash-source
168 WORKING_DIRECTORY \"${TOP}/dash-source\"
169 COMMAND \"${GIT}\" reset --hard master~2
173 # Run the dashboard script with CTest.
174 run_dashboard_script(dashboard.cmake)