mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-04 05:10:10 -05:00
CTest/cmProcess: Adopt field tracking reason for the process timeout
A test process may timeout either because the test timeout was reached, or the overall stop time was reached. Shorten the lifetime for which we track this state in `cmCTestRunTest`.
This commit is contained in:
@@ -634,8 +634,9 @@ void cmCTestMultiProcessHandler::FinishTestProcess(
|
|||||||
int test = runner->GetIndex();
|
int test = runner->GetIndex();
|
||||||
auto* properties = runner->GetTestProperties();
|
auto* properties = runner->GetTestProperties();
|
||||||
|
|
||||||
bool testResult = runner->EndTest(this->Completed, this->Total, started);
|
cmCTestRunTest::EndTestResult testResult =
|
||||||
if (runner->TimedOutForStopTime()) {
|
runner->EndTest(this->Completed, this->Total, started);
|
||||||
|
if (testResult.StopTimePassed) {
|
||||||
this->SetStopTimePassed();
|
this->SetStopTimePassed();
|
||||||
}
|
}
|
||||||
if (started) {
|
if (started) {
|
||||||
@@ -646,7 +647,7 @@ void cmCTestMultiProcessHandler::FinishTestProcess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testResult) {
|
if (testResult.Passed) {
|
||||||
this->Passed->push_back(properties->Name);
|
this->Passed->push_back(properties->Name);
|
||||||
} else if (!properties->Disabled) {
|
} else if (!properties->Disabled) {
|
||||||
this->Failed->push_back(properties->Name);
|
this->Failed->push_back(properties->Name);
|
||||||
|
|||||||
@@ -95,16 +95,15 @@ void cmCTestRunTest::CheckOutput(std::string const& line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
cmCTestRunTest::EndTestResult cmCTestRunTest::EndTest(size_t completed,
|
||||||
|
size_t total,
|
||||||
|
bool started)
|
||||||
{
|
{
|
||||||
this->WriteLogOutputTop(completed, total);
|
this->WriteLogOutputTop(completed, total);
|
||||||
std::string reason;
|
std::string reason;
|
||||||
bool passed = true;
|
bool passed = true;
|
||||||
cmProcess::State res =
|
cmProcess::State res =
|
||||||
started ? this->TestProcess->GetProcessStatus() : cmProcess::State::Error;
|
started ? this->TestProcess->GetProcessStatus() : cmProcess::State::Error;
|
||||||
if (res != cmProcess::State::Expired) {
|
|
||||||
this->TimeoutIsForStopTime = false;
|
|
||||||
}
|
|
||||||
std::int64_t retVal = this->TestProcess->GetExitValue();
|
std::int64_t retVal = this->TestProcess->GetExitValue();
|
||||||
bool forceFail = false;
|
bool forceFail = false;
|
||||||
bool forceSkip = false;
|
bool forceSkip = false;
|
||||||
@@ -344,8 +343,15 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
|||||||
if (!this->NeedsToRepeat()) {
|
if (!this->NeedsToRepeat()) {
|
||||||
this->TestHandler->TestResults.push_back(this->TestResult);
|
this->TestHandler->TestResults.push_back(this->TestResult);
|
||||||
}
|
}
|
||||||
|
cmCTestRunTest::EndTestResult testResult;
|
||||||
|
testResult.Passed = passed || skipped;
|
||||||
|
if (res == cmProcess::State::Expired &&
|
||||||
|
this->TestProcess->GetTimeoutReason() ==
|
||||||
|
cmProcess::TimeoutReason::StopTime) {
|
||||||
|
testResult.StopTimePassed = true;
|
||||||
|
}
|
||||||
this->TestProcess.reset();
|
this->TestProcess.reset();
|
||||||
return passed || skipped;
|
return testResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestRunTest::StartAgain(std::unique_ptr<cmCTestRunTest> runner,
|
bool cmCTestRunTest::StartAgain(std::unique_ptr<cmCTestRunTest> runner,
|
||||||
@@ -772,8 +778,8 @@ bool cmCTestRunTest::ForkProcess()
|
|||||||
timeRemaining = cmDuration::zero();
|
timeRemaining = cmDuration::zero();
|
||||||
}
|
}
|
||||||
if (!timeout || timeRemaining < *timeout) {
|
if (!timeout || timeRemaining < *timeout) {
|
||||||
this->TimeoutIsForStopTime = true;
|
|
||||||
timeout = timeRemaining;
|
timeout = timeRemaining;
|
||||||
|
this->TestProcess->SetTimeoutReason(cmProcess::TimeoutReason::StopTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
|
|||||||
@@ -71,10 +71,16 @@ public:
|
|||||||
std::string const& output,
|
std::string const& output,
|
||||||
std::string const& detail);
|
std::string const& detail);
|
||||||
|
|
||||||
|
struct EndTestResult
|
||||||
|
{
|
||||||
|
bool Passed = false;
|
||||||
|
bool StopTimePassed = false;
|
||||||
|
};
|
||||||
|
|
||||||
// launch the test process, return whether it started correctly
|
// launch the test process, return whether it started correctly
|
||||||
bool StartTest(size_t completed, size_t total);
|
bool StartTest(size_t completed, size_t total);
|
||||||
// capture and report the test results
|
// capture and report the test results
|
||||||
bool EndTest(size_t completed, size_t total, bool started);
|
EndTestResult EndTest(size_t completed, size_t total, bool started);
|
||||||
// Called by ctest -N to log the command string
|
// Called by ctest -N to log the command string
|
||||||
void ComputeArguments();
|
void ComputeArguments();
|
||||||
|
|
||||||
@@ -90,8 +96,6 @@ public:
|
|||||||
|
|
||||||
void FinalizeTest(bool started = true);
|
void FinalizeTest(bool started = true);
|
||||||
|
|
||||||
bool TimedOutForStopTime() const { return this->TimeoutIsForStopTime; }
|
|
||||||
|
|
||||||
void SetUseAllocatedResources(bool use)
|
void SetUseAllocatedResources(bool use)
|
||||||
{
|
{
|
||||||
this->UseAllocatedResources = use;
|
this->UseAllocatedResources = use;
|
||||||
@@ -120,7 +124,6 @@ private:
|
|||||||
std::string GetTestPrefix(size_t completed, size_t total) const;
|
std::string GetTestPrefix(size_t completed, size_t total) const;
|
||||||
|
|
||||||
cmCTestTestHandler::cmCTestTestProperties* TestProperties;
|
cmCTestTestHandler::cmCTestTestProperties* TestProperties;
|
||||||
bool TimeoutIsForStopTime = false;
|
|
||||||
// Pointer back to the "parent"; the handler that invoked this test run
|
// Pointer back to the "parent"; the handler that invoked this test run
|
||||||
cmCTestTestHandler* TestHandler;
|
cmCTestTestHandler* TestHandler;
|
||||||
cmCTest* CTest;
|
cmCTest* CTest;
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ public:
|
|||||||
// Return true if the process starts
|
// Return true if the process starts
|
||||||
bool StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity);
|
bool StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity);
|
||||||
|
|
||||||
|
enum class TimeoutReason
|
||||||
|
{
|
||||||
|
Normal,
|
||||||
|
StopTime,
|
||||||
|
};
|
||||||
|
void SetTimeoutReason(TimeoutReason r) { this->TimeoutReason_ = r; }
|
||||||
|
TimeoutReason GetTimeoutReason() const { return this->TimeoutReason_; }
|
||||||
|
|
||||||
enum class State
|
enum class State
|
||||||
{
|
{
|
||||||
Starting,
|
Starting,
|
||||||
@@ -79,6 +87,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
cm::optional<cmDuration> Timeout;
|
cm::optional<cmDuration> Timeout;
|
||||||
|
TimeoutReason TimeoutReason_ = TimeoutReason::Normal;
|
||||||
std::chrono::steady_clock::time_point StartTime;
|
std::chrono::steady_clock::time_point StartTime;
|
||||||
cmDuration TotalTime;
|
cmDuration TotalTime;
|
||||||
bool ReadHandleClosed = false;
|
bool ReadHandleClosed = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user