mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-01 11:22:21 -06: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();
|
||||
auto* properties = runner->GetTestProperties();
|
||||
|
||||
bool testResult = runner->EndTest(this->Completed, this->Total, started);
|
||||
if (runner->TimedOutForStopTime()) {
|
||||
cmCTestRunTest::EndTestResult testResult =
|
||||
runner->EndTest(this->Completed, this->Total, started);
|
||||
if (testResult.StopTimePassed) {
|
||||
this->SetStopTimePassed();
|
||||
}
|
||||
if (started) {
|
||||
@@ -646,7 +647,7 @@ void cmCTestMultiProcessHandler::FinishTestProcess(
|
||||
}
|
||||
}
|
||||
|
||||
if (testResult) {
|
||||
if (testResult.Passed) {
|
||||
this->Passed->push_back(properties->Name);
|
||||
} else if (!properties->Disabled) {
|
||||
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);
|
||||
std::string reason;
|
||||
bool passed = true;
|
||||
cmProcess::State res =
|
||||
started ? this->TestProcess->GetProcessStatus() : cmProcess::State::Error;
|
||||
if (res != cmProcess::State::Expired) {
|
||||
this->TimeoutIsForStopTime = false;
|
||||
}
|
||||
std::int64_t retVal = this->TestProcess->GetExitValue();
|
||||
bool forceFail = false;
|
||||
bool forceSkip = false;
|
||||
@@ -344,8 +343,15 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
||||
if (!this->NeedsToRepeat()) {
|
||||
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();
|
||||
return passed || skipped;
|
||||
return testResult;
|
||||
}
|
||||
|
||||
bool cmCTestRunTest::StartAgain(std::unique_ptr<cmCTestRunTest> runner,
|
||||
@@ -772,8 +778,8 @@ bool cmCTestRunTest::ForkProcess()
|
||||
timeRemaining = cmDuration::zero();
|
||||
}
|
||||
if (!timeout || timeRemaining < *timeout) {
|
||||
this->TimeoutIsForStopTime = true;
|
||||
timeout = timeRemaining;
|
||||
this->TestProcess->SetTimeoutReason(cmProcess::TimeoutReason::StopTime);
|
||||
}
|
||||
|
||||
if (timeout) {
|
||||
|
||||
@@ -71,10 +71,16 @@ public:
|
||||
std::string const& output,
|
||||
std::string const& detail);
|
||||
|
||||
struct EndTestResult
|
||||
{
|
||||
bool Passed = false;
|
||||
bool StopTimePassed = false;
|
||||
};
|
||||
|
||||
// launch the test process, return whether it started correctly
|
||||
bool StartTest(size_t completed, size_t total);
|
||||
// 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
|
||||
void ComputeArguments();
|
||||
|
||||
@@ -90,8 +96,6 @@ public:
|
||||
|
||||
void FinalizeTest(bool started = true);
|
||||
|
||||
bool TimedOutForStopTime() const { return this->TimeoutIsForStopTime; }
|
||||
|
||||
void SetUseAllocatedResources(bool use)
|
||||
{
|
||||
this->UseAllocatedResources = use;
|
||||
@@ -120,7 +124,6 @@ private:
|
||||
std::string GetTestPrefix(size_t completed, size_t total) const;
|
||||
|
||||
cmCTestTestHandler::cmCTestTestProperties* TestProperties;
|
||||
bool TimeoutIsForStopTime = false;
|
||||
// Pointer back to the "parent"; the handler that invoked this test run
|
||||
cmCTestTestHandler* TestHandler;
|
||||
cmCTest* CTest;
|
||||
|
||||
@@ -41,6 +41,14 @@ public:
|
||||
// Return true if the process starts
|
||||
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
|
||||
{
|
||||
Starting,
|
||||
@@ -79,6 +87,7 @@ public:
|
||||
|
||||
private:
|
||||
cm::optional<cmDuration> Timeout;
|
||||
TimeoutReason TimeoutReason_ = TimeoutReason::Normal;
|
||||
std::chrono::steady_clock::time_point StartTime;
|
||||
cmDuration TotalTime;
|
||||
bool ReadHandleClosed = false;
|
||||
|
||||
Reference in New Issue
Block a user