summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-20 23:39:08 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-21 17:37:41 (GMT)
commit9d8415c17bff2319aa5eb9cbd272b557160d9efc (patch)
tree468e2c135f64b95cf7b287d3e58253b3510a77a0 /Source/CTest
parent61e98ca33baf3fa6762e5e44286fb93b2a4a173c (diff)
downloadCMake-9d8415c17bff2319aa5eb9cbd272b557160d9efc.zip
CMake-9d8415c17bff2319aa5eb9cbd272b557160d9efc.tar.gz
CMake-9d8415c17bff2319aa5eb9cbd272b557160d9efc.tar.bz2
cmCTestMultiProcessHandler: Clarify test-load retry timer infrastructure
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx49
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.h6
2 files changed, 23 insertions, 32 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 5c3e999..bb6bb9d 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -128,10 +128,12 @@ bool cmCTestMultiProcessHandler::Complete()
void cmCTestMultiProcessHandler::InitializeLoop()
{
this->Loop.init();
+ this->StartNextTestsOnTimer_.init(*this->Loop, this);
}
void cmCTestMultiProcessHandler::FinalizeLoop()
{
+ this->StartNextTestsOnTimer_.reset();
this->Loop.reset();
}
@@ -464,22 +466,12 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
void cmCTestMultiProcessHandler::StartNextTests()
{
- if (this->TestLoadRetryTimer.get() != nullptr) {
- // This timer may be waiting to call StartNextTests again.
- // Since we have been called it is no longer needed.
- uv_timer_stop(this->TestLoadRetryTimer);
- }
+ // One or more events may be scheduled to call this method again.
+ // Since this method has been called they are no longer needed.
+ this->StartNextTestsOnTimer_.stop();
- if (this->PendingTests.empty()) {
- this->TestLoadRetryTimer.reset();
- return;
- }
-
- if (this->CheckStopTimePassed()) {
- return;
- }
-
- if (this->CheckStopOnFailure() && !this->Failed->empty()) {
+ if (this->PendingTests.empty() || this->CheckStopTimePassed() ||
+ (this->CheckStopOnFailure() && !this->Failed->empty())) {
return;
}
@@ -627,23 +619,24 @@ void cmCTestMultiProcessHandler::StartNextTests()
}
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "*****" << std::endl);
- // Wait between 1 and 5 seconds before trying again.
- unsigned int milliseconds = (cmSystemTools::RandomSeed() % 5 + 1) * 1000;
- if (this->FakeLoadForTesting) {
- milliseconds = 10;
- }
- if (this->TestLoadRetryTimer.get() == nullptr) {
- this->TestLoadRetryTimer.init(*this->Loop, this);
- }
- this->TestLoadRetryTimer.start(
- &cmCTestMultiProcessHandler::OnTestLoadRetryCB, milliseconds, 0);
+ // Try again later when the load might be lower.
+ this->StartNextTestsOnTimer();
}
}
-void cmCTestMultiProcessHandler::OnTestLoadRetryCB(uv_timer_t* timer)
+void cmCTestMultiProcessHandler::StartNextTestsOnTimer()
{
- auto* self = static_cast<cmCTestMultiProcessHandler*>(timer->data);
- self->StartNextTests();
+ // Wait between 1 and 5 seconds before trying again.
+ unsigned int const milliseconds = this->FakeLoadForTesting
+ ? 10
+ : (cmSystemTools::RandomSeed() % 5 + 1) * 1000;
+ this->StartNextTestsOnTimer_.start(
+ [](uv_timer_t* timer) {
+ uv_timer_stop(timer);
+ auto* self = static_cast<cmCTestMultiProcessHandler*>(timer->data);
+ self->StartNextTests();
+ },
+ milliseconds, 0);
}
void cmCTestMultiProcessHandler::FinishTestProcess(
diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h
index d51a33a..cac35e3 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.h
+++ b/Source/CTest/cmCTestMultiProcessHandler.h
@@ -14,8 +14,6 @@
#include <cm/optional>
-#include <cm3p/uv.h>
-
#include "cmCTest.h"
#include "cmCTestResourceAllocator.h"
#include "cmCTestResourceSpec.h"
@@ -132,7 +130,7 @@ protected:
void ErasePendingTest(int index);
void FinishTestProcess(std::unique_ptr<cmCTestRunTest> runner, bool started);
- static void OnTestLoadRetryCB(uv_timer_t* timer);
+ void StartNextTestsOnTimer();
void RemoveTest(int index);
// Check if we need to resume an interrupted test set
@@ -209,7 +207,7 @@ protected:
unsigned long TestLoad;
unsigned long FakeLoadForTesting;
cm::uv_loop_ptr Loop;
- cm::uv_timer_ptr TestLoadRetryTimer;
+ cm::uv_timer_ptr StartNextTestsOnTimer_;
cmCTestTestHandler* TestHandler;
cmCTest* CTest;
bool HasCycles;