diff options
author | Brad King <brad.king@kitware.com> | 2024-03-07 13:53:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-03-10 14:27:05 (GMT) |
commit | bbcbcff7d94bb3dd4b47ed5484207dc960911f4c (patch) | |
tree | ef4c2af16945e658fda781d82fed6f7cb70e2f76 /Source | |
parent | 7457b474a1d6eb2165d657852e25f3a8e5a2f8ee (diff) | |
download | CMake-bbcbcff7d94bb3dd4b47ed5484207dc960911f4c.zip CMake-bbcbcff7d94bb3dd4b47ed5484207dc960911f4c.tar.gz CMake-bbcbcff7d94bb3dd4b47ed5484207dc960911f4c.tar.bz2 |
cmCTestMultiProcessHandler: Modernize member initialization
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CTest/cmCTestMultiProcessHandler.cxx | 17 | ||||
-rw-r--r-- | Source/CTest/cmCTestMultiProcessHandler.h | 35 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 5 |
3 files changed, 23 insertions, 34 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 7b72f30..6efe008 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -66,18 +66,13 @@ private: cmCTestMultiProcessHandler* Handler; }; -cmCTestMultiProcessHandler::cmCTestMultiProcessHandler() +cmCTestMultiProcessHandler::cmCTestMultiProcessHandler( + cmCTest* ctest, cmCTestTestHandler* handler) + : CTest(ctest) + , TestHandler(handler) + , ProcessorsAvailable(cmAffinity::GetProcessorsAvailable()) + , HaveAffinity(this->ProcessorsAvailable.size()) { - this->ParallelLevel = 1; - this->TestLoad = 0; - this->FakeLoadForTesting = 0; - this->Completed = 0; - this->RunningCount = 0; - this->ProcessorsAvailable = cmAffinity::GetProcessorsAvailable(); - this->HaveAffinity = this->ProcessorsAvailable.size(); - this->HasCycles = false; - this->HasInvalidGeneratedResourceSpec = false; - this->SerialTestRunning = false; } cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler() = default; diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index 02589ca..bbbfc7b 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -58,7 +58,7 @@ public: unsigned int Slots; }; - cmCTestMultiProcessHandler(); + cmCTestMultiProcessHandler(cmCTest* ctest, cmCTestTestHandler* handler); virtual ~cmCTestMultiProcessHandler(); // Set the tests void SetTests(TestMap tests, PropertiesMap properties); @@ -81,13 +81,6 @@ public: this->TestResults = r; } - void SetCTest(cmCTest* ctest) { this->CTest = ctest; } - - void SetTestHandler(cmCTestTestHandler* handler) - { - this->TestHandler = handler; - } - cmCTestTestHandler* GetTestHandler() { return this->TestHandler; } void SetRepeatMode(cmCTest::Repeat mode, int count) @@ -171,22 +164,26 @@ protected: bool InitResourceAllocator(std::string& error); bool CheckGeneratedResourceSpec(); +private: + cmCTest* CTest; + cmCTestTestHandler* TestHandler; + bool UseResourceSpec = false; cmCTestResourceSpec ResourceSpec; std::string ResourceSpecFile; std::string ResourceSpecSetupFixture; cm::optional<std::size_t> ResourceSpecSetupTest; - bool HasInvalidGeneratedResourceSpec; + bool HasInvalidGeneratedResourceSpec = false; // Tests pending selection to start. They may have dependencies. TestMap PendingTests; // List of pending test indexes, ordered by cost. std::list<int> OrderedTests; // Total number of tests we'll be running - size_t Total; + size_t Total = 0; // Number of tests that are complete - size_t Completed; - size_t RunningCount; + size_t Completed = 0; + size_t RunningCount = 0; std::set<size_t> ProcessorsAvailable; size_t HaveAffinity; bool StopTimePassed = false; @@ -204,7 +201,7 @@ protected: ResourceAvailabilityErrors; cmCTestResourceAllocator ResourceAllocator; std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults; - size_t ParallelLevel; // max number of process that can be run at once + size_t ParallelLevel = 1; // max number of process that can be run at once // 'make' jobserver client. If connected, we acquire a token // for each test before running its process. @@ -214,16 +211,14 @@ protected: // Callback invoked when a token is received. void JobServerReceivedToken(); - unsigned long TestLoad; - unsigned long FakeLoadForTesting; + unsigned long TestLoad = 0; + unsigned long FakeLoadForTesting = 0; cm::uv_loop_ptr Loop; cm::uv_idle_ptr StartNextTestsOnIdle_; cm::uv_timer_ptr StartNextTestsOnTimer_; - cmCTestTestHandler* TestHandler; - cmCTest* CTest; - bool HasCycles; + bool HasCycles = false; cmCTest::Repeat RepeatMode = cmCTest::Repeat::Never; int RepeatCount = 1; - bool Quiet; - bool SerialTestRunning; + bool Quiet = false; + bool SerialTestRunning = false; }; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index dc16f66..921ab1e 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1359,10 +1359,9 @@ bool cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, this->StartTestTime = std::chrono::system_clock::now(); auto elapsed_time_start = std::chrono::steady_clock::now(); - auto parallel = cm::make_unique<cmCTestMultiProcessHandler>(); - parallel->SetCTest(this->CTest); + auto parallel = + cm::make_unique<cmCTestMultiProcessHandler>(this->CTest, this); parallel->SetParallelLevel(this->CTest->GetParallelLevel()); - parallel->SetTestHandler(this); if (this->RepeatMode != cmCTest::Repeat::Never) { parallel->SetRepeatMode(this->RepeatMode, this->RepeatCount); } else { |