summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx8
-rw-r--r--Source/CTest/cmCTestGIT.cxx98
-rw-r--r--Source/CTest/cmCTestGIT.h4
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx15
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.h1
-rw-r--r--Source/CTest/cmCTestRunTest.cxx15
-rw-r--r--Source/CTest/cmCTestRunTest.h3
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx4
-rw-r--r--Source/CTest/cmCTestUpdateCommand.cxx2
9 files changed, 125 insertions, 25 deletions
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 3235bfd..55a5225 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -2038,8 +2038,12 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
for(std::vector<std::string>::iterator f = files.begin();
f != files.end(); ++f)
{
- extraMatches.insert(this->CTest->GetShortPathToFile(
- f->c_str()));
+ if(this->ShouldIDoCoverage(f->c_str(),
+ cont->SourceDir.c_str(), cont->BinaryDir.c_str()))
+ {
+ extraMatches.insert(this->CTest->GetShortPathToFile(
+ f->c_str()));
+ }
}
}
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index f5ba361..6c3631c 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -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);
+
+ // 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))
+ {
+ 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);
+ }
+ }
+ }
+ }
- OutputLogger out(this->Log, "pull-out> ");
- OutputLogger err(this->Log, "pull-err> ");
- if(this->RunUpdateCommand(&git_pull[0], &out, &err))
+ // 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)
{
- 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);
+ git_custom.push_back(i->c_str());
}
- return false;
+ 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);
}
//----------------------------------------------------------------------------
diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h
index 0b6ad2e..d8681fe 100644
--- a/Source/CTest/cmCTestGIT.h
+++ b/Source/CTest/cmCTestGIT.h
@@ -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();
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 8a69780..9b8cef5 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -23,6 +23,7 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler()
this->ParallelLevel = 1;
this->Completed = 0;
this->RunningCount = 0;
+ this->StopTimePassed = false;
}
cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler()
@@ -69,6 +70,10 @@ void cmCTestMultiProcessHandler::RunTests()
this->StartNextTests();
while(this->Tests.size() != 0)
{
+ if(this->StopTimePassed)
+ {
+ return;
+ }
this->CheckOutput();
this->StartNextTests();
}
@@ -102,6 +107,12 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
{
this->RunningTests.insert(testRun);
}
+ else if(testRun->IsStopTimePassed())
+ {
+ this->StopTimePassed = true;
+ delete testRun;
+ return;
+ }
else
{
this->UnlockResources(test);
@@ -251,6 +262,10 @@ void cmCTestMultiProcessHandler::StartNextTests()
}
if(this->StartTest(*test))
{
+ if(this->StopTimePassed)
+ {
+ return;
+ }
numToStart -= processors;
this->RunningCount += processors;
}
diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h
index d4f6c71..4f51b0b 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.h
+++ b/Source/CTest/cmCTestMultiProcessHandler.h
@@ -94,6 +94,7 @@ protected:
//Number of tests that are complete
size_t Completed;
size_t RunningCount;
+ bool StopTimePassed;
//list of test properties (indices concurrent to the test map)
PropertiesMap Properties;
std::map<int, bool> TestRunningMap;
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 4c9675b..9fb8827 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -32,6 +32,7 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
this->ProcessOutput = "";
this->CompressedOutput = "";
this->CompressionRatio = 2;
+ this->StopTimePassed = false;
}
cmCTestRunTest::~cmCTestRunTest()
@@ -436,8 +437,13 @@ bool cmCTestRunTest::StartTest(size_t total)
}
this->StartTime = this->CTest->CurrentTime();
- return this->ForkProcess(this->ResolveTimeout(),
- &this->TestProperties->Environment);
+ double timeout = this->ResolveTimeout();
+
+ if(this->StopTimePassed)
+ {
+ return false;
+ }
+ return this->ForkProcess(timeout, &this->TestProperties->Environment);
}
//----------------------------------------------------------------------
@@ -569,8 +575,9 @@ double cmCTestRunTest::ResolveTimeout()
if(stop_timeout <= 0 || stop_timeout > this->CTest->LastStopTimeout)
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
- "Exiting ctest." << std::endl);
- exit(-1);
+ "Stopping all tests." << std::endl);
+ this->StopTimePassed = true;
+ return 0;
}
return timeout == 0 ? stop_timeout :
(timeout < stop_timeout ? timeout : stop_timeout);
diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h
index d7d3a2f..e0cb888 100644
--- a/Source/CTest/cmCTestRunTest.h
+++ b/Source/CTest/cmCTestRunTest.h
@@ -39,6 +39,8 @@ public:
std::string GetProcessOutput() { return this->ProcessOutput; }
+ bool IsStopTimePassed() { return this->StopTimePassed; }
+
cmCTestTestHandler::cmCTestTestResult GetTestResults()
{ return this->TestResult; }
@@ -90,6 +92,7 @@ private:
std::string TestCommand;
std::string ActualCommand;
std::vector<std::string> Arguments;
+ bool StopTimePassed;
};
inline int getNumWidth(size_t n)
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index b9cee6c..d2742ec 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1036,9 +1036,9 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
bool randomSchedule = this->CTest->GetScheduleType() == "Random";
if(randomSchedule)
- {
+ {
srand((unsigned)time(0));
- }
+ }
for (ListOfTests::iterator it = this->TestList.begin();
it != this->TestList.end(); ++it)
diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx
index 571745d..8414349 100644
--- a/Source/CTest/cmCTestUpdateCommand.cxx
+++ b/Source/CTest/cmCTestUpdateCommand.cxx
@@ -52,6 +52,8 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
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,
"HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS");