summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestMultiProcessHandler.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-02-24 15:53:32 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-02-24 20:44:01 (GMT)
commitf0df3ed5b99257ab8109fcbe09e8ff97565c00c8 (patch)
tree08e8d41d91e733e624c80127672c65501ee5ce00 /Source/CTest/cmCTestMultiProcessHandler.cxx
parentf1c34443b7fa828150e4e13b0dea3c5fbd29b6eb (diff)
downloadCMake-f0df3ed5b99257ab8109fcbe09e8ff97565c00c8.zip
CMake-f0df3ed5b99257ab8109fcbe09e8ff97565c00c8.tar.gz
CMake-f0df3ed5b99257ab8109fcbe09e8ff97565c00c8.tar.bz2
Refactor: Provide more detailed error information from TryAllocateResources()
Diffstat (limited to 'Source/CTest/cmCTestMultiProcessHandler.cxx')
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx41
1 files changed, 27 insertions, 14 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 758ea57..6343353 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -196,7 +196,7 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
// working directory because FinishTestProcess() will try to unlock them
this->LockResources(test);
- if (!this->TestsHaveSufficientResources[test]) {
+ if (!this->ResourceAllocationErrors[test].empty()) {
testRun->StartFailure("Insufficient resources", "Failed to start");
this->FinishTestProcess(testRun, false);
return false;
@@ -250,7 +250,8 @@ bool cmCTestMultiProcessHandler::AllocateResources(int index)
bool cmCTestMultiProcessHandler::TryAllocateResources(
int index,
- std::map<std::string, std::vector<cmCTestBinPackerAllocation>>& allocations)
+ std::map<std::string, std::vector<cmCTestBinPackerAllocation>>& allocations,
+ std::map<std::string, ResourceAllocationError>* errors)
{
allocations.clear();
@@ -265,18 +266,28 @@ bool cmCTestMultiProcessHandler::TryAllocateResources(
++processIndex;
}
+ bool result = true;
auto const& availableResources = this->ResourceAllocator.GetResources();
for (auto& it : allocations) {
if (!availableResources.count(it.first)) {
- return false;
- }
- if (!cmAllocateCTestResourcesRoundRobin(availableResources.at(it.first),
- it.second)) {
- return false;
+ if (errors) {
+ (*errors)[it.first] = ResourceAllocationError::NoResourceType;
+ result = false;
+ } else {
+ return false;
+ }
+ } else if (!cmAllocateCTestResourcesRoundRobin(
+ availableResources.at(it.first), it.second)) {
+ if (errors) {
+ (*errors)[it.first] = ResourceAllocationError::InsufficientResources;
+ result = false;
+ } else {
+ return false;
+ }
}
}
- return true;
+ return result;
}
void cmCTestMultiProcessHandler::DeallocateResources(int index)
@@ -317,11 +328,13 @@ bool cmCTestMultiProcessHandler::AllResourcesAvailable()
void cmCTestMultiProcessHandler::CheckResourcesAvailable()
{
- for (auto test : this->SortedTests) {
- std::map<std::string, std::vector<cmCTestBinPackerAllocation>> allocations;
- this->TestsHaveSufficientResources[test] =
- !this->TestHandler->UseResourceSpec ||
- this->TryAllocateResources(test, allocations);
+ if (this->TestHandler->UseResourceSpec) {
+ for (auto test : this->SortedTests) {
+ std::map<std::string, std::vector<cmCTestBinPackerAllocation>>
+ allocations;
+ this->TryAllocateResources(test, allocations,
+ &this->ResourceAllocationErrors[test]);
+ }
}
}
@@ -408,7 +421,7 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
}
// Allocate resources
- if (this->TestsHaveSufficientResources[test] &&
+ if (this->ResourceAllocationErrors[test].empty() &&
!this->AllocateResources(test)) {
this->DeallocateResources(test);
return false;