From 3f5a5a5856790107bba5cad6d9d45d1170b986f1 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Thu, 10 Aug 2023 16:44:29 -0400 Subject: cmCTestRunTest::StartFailure(): Add total argument This function was being called when TotalNumberOfTests hadn't been initialized, resulting in undefined output. It's not clear why this was never apparent until now. Accept a total argument to ensure it's initialized. --- Source/CTest/cmCTestMultiProcessHandler.cxx | 4 ++-- Source/CTest/cmCTestRunTest.cxx | 11 ++++++----- Source/CTest/cmCTestRunTest.h | 5 +++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 7d22a87..caca04a 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -230,14 +230,14 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test) e << "\n"; } e << "Resource spec file:\n\n " << this->TestHandler->ResourceSpecFile; - cmCTestRunTest::StartFailure(std::move(testRun), e.str(), + cmCTestRunTest::StartFailure(std::move(testRun), this->Total, e.str(), "Insufficient resources"); return false; } cmWorkingDirectory workdir(this->Properties[test]->Directory); if (workdir.Failed()) { - cmCTestRunTest::StartFailure(std::move(testRun), + cmCTestRunTest::StartFailure(std::move(testRun), this->Total, "Failed to change working directory to " + this->Properties[test]->Directory + " : " + std::strerror(workdir.GetLastResult()), diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 563439a..45933a5 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -372,7 +372,8 @@ bool cmCTestRunTest::StartAgain(std::unique_ptr runner, // change to tests directory cmWorkingDirectory workdir(testRun->TestProperties->Directory); if (workdir.Failed()) { - testRun->StartFailure("Failed to change working directory to " + + testRun->StartFailure(testRun->TotalNumberOfTests, + "Failed to change working directory to " + testRun->TestProperties->Directory + " : " + std::strerror(workdir.GetLastResult()), "Failed to change working directory"); @@ -437,25 +438,25 @@ void cmCTestRunTest::MemCheckPostProcess() } void cmCTestRunTest::StartFailure(std::unique_ptr runner, - std::string const& output, + size_t total, std::string const& output, std::string const& detail) { auto* testRun = runner.get(); testRun->TestProcess = cm::make_unique(std::move(runner)); - testRun->StartFailure(output, detail); + testRun->StartFailure(total, output, detail); testRun->FinalizeTest(false); } -void cmCTestRunTest::StartFailure(std::string const& output, +void cmCTestRunTest::StartFailure(size_t total, std::string const& output, std::string const& detail) { // Still need to log the Start message so the test summary records our // attempt to start this test if (!this->CTest->GetTestProgressOutput()) { cmCTestLog(this->CTest, HANDLER_OUTPUT, - std::setw(2 * getNumWidth(this->TotalNumberOfTests) + 8) + std::setw(2 * getNumWidth(total) + 8) << "Start " << std::setw(getNumWidth(this->TestHandler->GetMaxIndex())) << this->TestProperties->Index << ": " diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index fed7296..34f23c4 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -68,7 +68,7 @@ public: size_t completed); static void StartFailure(std::unique_ptr runner, - std::string const& output, + size_t total, std::string const& output, std::string const& detail); struct EndTestResult @@ -86,7 +86,8 @@ public: void ComputeWeightedCost(); - void StartFailure(std::string const& output, std::string const& detail); + void StartFailure(size_t total, std::string const& output, + std::string const& detail); cmCTest* GetCTest() const { return this->CTest; } -- cgit v0.12