Merge branch 'ctest-git-flexibility'
This commit is contained in:
commit
b4aa834900
|
@ -15,6 +15,7 @@ Changes since CMake 2.8.1
|
|||
- CTest: Report failure in Update.xml
|
||||
- CTest: Submit author email in Update.xml
|
||||
- CTest: Teach ctest_update about Git submodules
|
||||
- CTest: Teach ctest_update to handle Git upstream branch rewrites
|
||||
- Cygwin: Export all symbols with ENABLE_EXPORTS (#10122)
|
||||
- Do not list file names during 'cmake -E tar xz'
|
||||
- Documentation: Comply with "XHTML 1.0 Strict"
|
||||
|
|
|
@ -49,6 +49,7 @@ SVNUpdateOptions: @SVN_UPDATE_OPTIONS@
|
|||
# Git options
|
||||
GITCommand: @GITCOMMAND@
|
||||
GITUpdateOptions: @GIT_UPDATE_OPTIONS@
|
||||
GITUpdateCustom: @CTEST_GIT_UPDATE_CUSTOM@
|
||||
|
||||
# Generic update command
|
||||
UpdateCommand: @UPDATE_COMMAND@
|
||||
|
|
|
@ -85,16 +85,14 @@ void cmCTestGIT::NoteNewRevision()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmCTestGIT::UpdateImpl()
|
||||
bool cmCTestGIT::UpdateByFetchAndReset()
|
||||
{
|
||||
const char* git = this->CommandLineTool.c_str();
|
||||
|
||||
// Use "git pull" to update the working tree.
|
||||
std::vector<char const*> git_pull;
|
||||
git_pull.push_back(git);
|
||||
git_pull.push_back("pull");
|
||||
|
||||
// TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
|
||||
// Use "git fetch" to get remote commits.
|
||||
std::vector<char const*> git_fetch;
|
||||
git_fetch.push_back(git);
|
||||
git_fetch.push_back("fetch");
|
||||
|
||||
// Add user-specified update options.
|
||||
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
|
||||
|
@ -106,22 +104,88 @@ bool cmCTestGIT::UpdateImpl()
|
|||
for(std::vector<cmStdString>::const_iterator ai = args.begin();
|
||||
ai != args.end(); ++ai)
|
||||
{
|
||||
git_pull.push_back(ai->c_str());
|
||||
git_fetch.push_back(ai->c_str());
|
||||
}
|
||||
|
||||
// Sentinel argument.
|
||||
git_pull.push_back(0);
|
||||
git_fetch.push_back(0);
|
||||
|
||||
OutputLogger out(this->Log, "pull-out> ");
|
||||
OutputLogger err(this->Log, "pull-err> ");
|
||||
if(this->RunUpdateCommand(&git_pull[0], &out, &err))
|
||||
// Fetch upstream refs.
|
||||
OutputLogger fetch_out(this->Log, "fetch-out> ");
|
||||
OutputLogger fetch_err(this->Log, "fetch-err> ");
|
||||
if(!this->RunUpdateCommand(&git_fetch[0], &fetch_out, &fetch_err))
|
||||
{
|
||||
char const* git_submodule[] = {git, "submodule", "update", 0};
|
||||
OutputLogger out2(this->Log, "submodule-out> ");
|
||||
OutputLogger err2(this->Log, "submodule-err> ");
|
||||
return this->RunChild(git_submodule, &out2, &err2);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
// Identify the merge head that would be used by "git pull".
|
||||
std::string sha1;
|
||||
{
|
||||
std::string fetch_head = this->SourceDirectory + "/.git/FETCH_HEAD";
|
||||
std::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary);
|
||||
std::string line;
|
||||
while(sha1.empty() && cmSystemTools::GetLineFromStream(fin, line))
|
||||
{
|
||||
if(line.find("\tnot-for-merge\t") == line.npos)
|
||||
{
|
||||
std::string::size_type pos = line.find('\t');
|
||||
if(pos != line.npos)
|
||||
{
|
||||
sha1 = line.substr(0, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the local branch to point at that tracked from upstream.
|
||||
char const* git_reset[] = {git, "reset", "--hard", sha1.c_str(), 0};
|
||||
OutputLogger reset_out(this->Log, "reset-out> ");
|
||||
OutputLogger reset_err(this->Log, "reset-err> ");
|
||||
return this->RunChild(&git_reset[0], &reset_out, &reset_err);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmCTestGIT::UpdateByCustom(std::string const& custom)
|
||||
{
|
||||
std::vector<std::string> git_custom_command;
|
||||
cmSystemTools::ExpandListArgument(custom, git_custom_command, true);
|
||||
std::vector<char const*> git_custom;
|
||||
for(std::vector<std::string>::const_iterator
|
||||
i = git_custom_command.begin(); i != git_custom_command.end(); ++i)
|
||||
{
|
||||
git_custom.push_back(i->c_str());
|
||||
}
|
||||
git_custom.push_back(0);
|
||||
|
||||
OutputLogger custom_out(this->Log, "custom-out> ");
|
||||
OutputLogger custom_err(this->Log, "custom-err> ");
|
||||
return this->RunUpdateCommand(&git_custom[0], &custom_out, &custom_err);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmCTestGIT::UpdateInternal()
|
||||
{
|
||||
std::string custom = this->CTest->GetCTestConfiguration("GITUpdateCustom");
|
||||
if(!custom.empty())
|
||||
{
|
||||
return this->UpdateByCustom(custom);
|
||||
}
|
||||
return this->UpdateByFetchAndReset();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmCTestGIT::UpdateImpl()
|
||||
{
|
||||
if(!this->UpdateInternal())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* git = this->CommandLineTool.c_str();
|
||||
char const* git_submodule[] = {git, "submodule", "update", 0};
|
||||
OutputLogger submodule_out(this->Log, "submodule-out> ");
|
||||
OutputLogger submodule_err(this->Log, "submodule-err> ");
|
||||
return this->RunChild(git_submodule, &submodule_out, &submodule_err);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -32,6 +32,10 @@ private:
|
|||
virtual void NoteNewRevision();
|
||||
virtual bool UpdateImpl();
|
||||
|
||||
bool UpdateByFetchAndReset();
|
||||
bool UpdateByCustom(std::string const& custom);
|
||||
bool UpdateInternal();
|
||||
|
||||
void LoadRevisions();
|
||||
void LoadModifications();
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
|
|||
"GITCommand", "CTEST_GIT_COMMAND");
|
||||
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
|
||||
"GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS");
|
||||
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
|
||||
"GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM");
|
||||
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
|
||||
"HGCommand", "CTEST_HG_COMMAND");
|
||||
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
|
||||
|
|
|
@ -142,7 +142,7 @@ run_dashboard_command_line(user-binary)
|
|||
# Test initial checkout and update with a dashboard script.
|
||||
message("Running CTest Dashboard Script...")
|
||||
|
||||
create_dashboard_script(dashboard.cmake
|
||||
create_dashboard_script(dash-binary
|
||||
"# bzr command configuration
|
||||
set(CTEST_BZR_COMMAND \"${BZR}\")
|
||||
set(CTEST_CHECKOUT_COMMAND
|
||||
|
@ -150,4 +150,4 @@ set(CTEST_CHECKOUT_COMMAND
|
|||
")
|
||||
|
||||
# Run the dashboard script with CTest.
|
||||
run_dashboard_script(dashboard.cmake)
|
||||
run_dashboard_script(dash-binary)
|
||||
|
|
|
@ -147,7 +147,7 @@ run_dashboard_command_line(user-binary)
|
|||
# Test initial checkout and update with a dashboard script.
|
||||
message("Running CTest Dashboard Script...")
|
||||
|
||||
create_dashboard_script(dashboard.cmake
|
||||
create_dashboard_script(dash-binary
|
||||
"# CVS command configuration
|
||||
set(CTEST_CVS_COMMAND \"${CVS}\")
|
||||
set(CTEST_CVS_UPDATE_OPTIONS -dAP)
|
||||
|
@ -156,4 +156,4 @@ set(CTEST_CHECKOUT_COMMAND
|
|||
")
|
||||
|
||||
# Run the dashboard script with CTest.
|
||||
run_dashboard_script(dashboard.cmake)
|
||||
run_dashboard_script(dash-binary)
|
||||
|
|
|
@ -165,15 +165,15 @@ endfunction(create_build_tree)
|
|||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Function to write the dashboard test script.
|
||||
function(create_dashboard_script name custom_text)
|
||||
function(create_dashboard_script bin_dir custom_text)
|
||||
# Write the dashboard script.
|
||||
file(WRITE ${TOP}/dashboard.cmake
|
||||
file(WRITE ${TOP}/${bin_dir}.cmake
|
||||
"# CTest Dashboard Script
|
||||
set(CTEST_DASHBOARD_ROOT \"${TOP}\")
|
||||
set(CTEST_SITE test.site)
|
||||
set(CTEST_BUILD_NAME dash-test)
|
||||
set(CTEST_SOURCE_DIRECTORY \${CTEST_DASHBOARD_ROOT}/dash-source)
|
||||
set(CTEST_BINARY_DIRECTORY \${CTEST_DASHBOARD_ROOT}/dash-binary)
|
||||
set(CTEST_BINARY_DIRECTORY \${CTEST_DASHBOARD_ROOT}/${bin_dir})
|
||||
${custom_text}
|
||||
# Start a dashboard and run the update step
|
||||
ctest_start(Experimental)
|
||||
|
@ -191,27 +191,31 @@ function(run_dashboard_command_line bin_dir)
|
|||
|
||||
# Verify the updates reported by CTest.
|
||||
list(APPEND UPDATE_MAYBE Updated{subdir})
|
||||
set(_modified Modified{CTestConfig.cmake})
|
||||
if(UPDATE_NO_MODIFIED)
|
||||
set(_modified "")
|
||||
endif()
|
||||
check_updates(${bin_dir}
|
||||
Updated{foo.txt}
|
||||
Updated{bar.txt}
|
||||
Updated{zot.txt}
|
||||
Updated{subdir/foo.txt}
|
||||
Updated{subdir/bar.txt}
|
||||
Modified{CTestConfig.cmake}
|
||||
${_modified}
|
||||
)
|
||||
endfunction(run_dashboard_command_line)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Function to run the dashboard through a script
|
||||
function(run_dashboard_script name)
|
||||
function(run_dashboard_script bin_dir)
|
||||
run_child(
|
||||
WORKING_DIRECTORY ${TOP}
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} -S ${name} -V
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} -S ${bin_dir}.cmake -V
|
||||
)
|
||||
|
||||
# Verify the updates reported by CTest.
|
||||
list(APPEND UPDATE_MAYBE Updated{subdir})
|
||||
check_updates(dash-binary
|
||||
check_updates(${bin_dir}
|
||||
Updated{foo.txt}
|
||||
Updated{bar.txt}
|
||||
Updated{zot.txt}
|
||||
|
|
|
@ -192,15 +192,18 @@ run_child(
|
|||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Go back to before the changes so we can test updating.
|
||||
message("Backing up to revision 1...")
|
||||
run_child(
|
||||
WORKING_DIRECTORY ${TOP}/user-source
|
||||
COMMAND ${GIT} reset --hard master~2
|
||||
)
|
||||
run_child(
|
||||
WORKING_DIRECTORY ${TOP}/user-source
|
||||
COMMAND ${GIT} submodule update
|
||||
)
|
||||
macro(rewind_source src_dir)
|
||||
message("Backing up to revision 1...")
|
||||
run_child(
|
||||
WORKING_DIRECTORY ${TOP}/${src_dir}
|
||||
COMMAND ${GIT} reset --hard origin/master~2
|
||||
)
|
||||
run_child(
|
||||
WORKING_DIRECTORY ${TOP}/${src_dir}
|
||||
COMMAND ${GIT} submodule update
|
||||
)
|
||||
endmacro(rewind_source)
|
||||
rewind_source(user-source)
|
||||
|
||||
# Make sure pull does not try to rebase (which does not work with
|
||||
# modified files) even if ~/.gitconfig sets "branch.master.rebase".
|
||||
|
@ -224,13 +227,31 @@ UpdateCommand: ${GIT}
|
|||
")
|
||||
|
||||
# Run the dashboard command line interface.
|
||||
set(UPDATE_NO_MODIFIED 1)
|
||||
run_dashboard_command_line(user-binary)
|
||||
set(UPDATE_NO_MODIFIED 0)
|
||||
|
||||
rewind_source(user-source)
|
||||
modify_content(user-source)
|
||||
|
||||
message("Running CTest Dashboard Command Line (custom update)...")
|
||||
|
||||
# Create the user build tree.
|
||||
create_build_tree(user-source user-binary-custom)
|
||||
file(APPEND ${TOP}/user-binary-custom/CTestConfiguration.ini
|
||||
"# GIT command configuration
|
||||
UpdateCommand: ${GIT}
|
||||
GITUpdateCustom: ${GIT};pull;origin;master
|
||||
")
|
||||
|
||||
# Run the dashboard command line interface.
|
||||
run_dashboard_command_line(user-binary-custom)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Test initial checkout and update with a dashboard script.
|
||||
message("Running CTest Dashboard Script...")
|
||||
|
||||
create_dashboard_script(dashboard.cmake
|
||||
create_dashboard_script(dash-binary
|
||||
"# git command configuration
|
||||
set(CTEST_GIT_COMMAND \"${GIT}\")
|
||||
set(CTEST_GIT_UPDATE_OPTIONS)
|
||||
|
@ -253,4 +274,20 @@ execute_process(
|
|||
")
|
||||
|
||||
# Run the dashboard script with CTest.
|
||||
run_dashboard_script(dashboard.cmake)
|
||||
run_dashboard_script(dash-binary)
|
||||
|
||||
rewind_source(dash-source)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Test custom update with a dashboard script.
|
||||
message("Running CTest Dashboard Script (custom update)...")
|
||||
|
||||
create_dashboard_script(dash-binary-custom
|
||||
"# git command configuration
|
||||
set(CTEST_GIT_COMMAND \"${GIT}\")
|
||||
set(CTEST_GIT_UPDATE_OPTIONS)
|
||||
set(CTEST_GIT_UPDATE_CUSTOM \${CTEST_GIT_COMMAND} pull origin master)
|
||||
")
|
||||
|
||||
# Run the dashboard script with CTest.
|
||||
run_dashboard_script(dash-binary-custom)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
if test "x$1" = "xpull"; then
|
||||
if test "x$1" = "xpull" -o "x$1" = "xreset"; then
|
||||
"@GIT@" "$@" && sleep 1 && touch foo.txt
|
||||
else
|
||||
exec "@GIT@" "$@"
|
||||
|
|
|
@ -145,7 +145,7 @@ run_dashboard_command_line(user-binary)
|
|||
# Test initial checkout and update with a dashboard script.
|
||||
message("Running CTest Dashboard Script...")
|
||||
|
||||
create_dashboard_script(dashboard.cmake
|
||||
create_dashboard_script(dash-binary
|
||||
"# hg command configuration
|
||||
set(CTEST_HG_COMMAND \"${HG}\")
|
||||
set(CTEST_HG_UPDATE_OPTIONS)
|
||||
|
@ -160,4 +160,4 @@ execute_process(
|
|||
")
|
||||
|
||||
# Run the dashboard script with CTest.
|
||||
run_dashboard_script(dashboard.cmake)
|
||||
run_dashboard_script(dash-binary)
|
||||
|
|
|
@ -127,7 +127,7 @@ run_dashboard_command_line(user-binary)
|
|||
# Test initial checkout and update with a dashboard script.
|
||||
message("Running CTest Dashboard Script...")
|
||||
|
||||
create_dashboard_script(dashboard.cmake
|
||||
create_dashboard_script(dash-binary
|
||||
"# Subversion command configuration
|
||||
set(CTEST_SVN_COMMAND \"${SVN}\")
|
||||
set(CTEST_SVN_UPDATE_OPTIONS
|
||||
|
@ -137,4 +137,4 @@ set(CTEST_CHECKOUT_COMMAND
|
|||
")
|
||||
|
||||
# Run the dashboard script with CTest.
|
||||
run_dashboard_script(dashboard.cmake)
|
||||
run_dashboard_script(dash-binary)
|
||||
|
|
Loading…
Reference in New Issue