summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestTestHandler.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-03-11 14:18:38 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-03-11 14:18:50 (GMT)
commit89e99cca63e834901649da45b5e68fd50840e5a7 (patch)
treeb19c572bc48eb332447f54913ef0f755500cc6d9 /Source/CTest/cmCTestTestHandler.cxx
parent91feb31577f772a22aa25988a18cf5e24374b558 (diff)
parent5de1e21659090ca83e39e223d351e353347eb88e (diff)
downloadCMake-89e99cca63e834901649da45b5e68fd50840e5a7.zip
CMake-89e99cca63e834901649da45b5e68fd50840e5a7.tar.gz
CMake-89e99cca63e834901649da45b5e68fd50840e5a7.tar.bz2
Merge topic 'ctest-j-default'
5de1e21659 ctest: Allow passing -j without value to choose a contextual default bbcbcff7d9 cmCTestMultiProcessHandler: Modernize member initialization 7457b474a1 Tests: Remove unnecessary parallel suppression from CTestCoverageCollectGCOV ae69801d96 Tests: Convert CTestTestSkipReturnCode to RunCMake.ctest_test case 30dda49416 Tests: Convert CTestTestSerialOrder to RunCMake.ctest_test case Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Acked-by: scivision <michael@scivision.dev> Merge-request: !9315
Diffstat (limited to 'Source/CTest/cmCTestTestHandler.cxx')
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx23
1 files changed, 17 insertions, 6 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 957806a..b75df27 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -550,9 +550,21 @@ bool cmCTestTestHandler::ProcessOptions()
return false;
}
}
- if (this->GetOption("ParallelLevel")) {
- this->CTest->SetParallelLevel(
- std::stoi(*this->GetOption("ParallelLevel")));
+ if (cmValue parallelLevel = this->GetOption("ParallelLevel")) {
+ if (parallelLevel.IsEmpty()) {
+ // An empty value tells ctest to choose a default.
+ this->CTest->SetParallelLevel(cm::nullopt);
+ } else {
+ // A non-empty value must be a non-negative integer.
+ unsigned long plevel = 0;
+ if (!cmStrToULong(*parallelLevel, &plevel)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "ParallelLevel invalid value: " << *parallelLevel
+ << std::endl);
+ return false;
+ }
+ this->CTest->SetParallelLevel(plevel);
+ }
}
if (this->GetOption("StopOnFailure")) {
@@ -1360,10 +1372,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 {