mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-05 14:49:39 -06:00
cmProcess: Use explicit enum for process state
Translate the values from KWSys Process.
This commit is contained in:
@@ -154,8 +154,8 @@ bool 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;
|
||||||
int res =
|
cmProcess::State res =
|
||||||
started ? this->TestProcess->GetProcessStatus() : cmsysProcess_State_Error;
|
started ? this->TestProcess->GetProcessStatus() : cmProcess::State::Error;
|
||||||
int retVal = this->TestProcess->GetExitValue();
|
int retVal = this->TestProcess->GetExitValue();
|
||||||
bool forceFail = false;
|
bool forceFail = false;
|
||||||
bool skipped = false;
|
bool skipped = false;
|
||||||
@@ -194,7 +194,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res == cmsysProcess_State_Exited) {
|
if (res == cmProcess::State::Exited) {
|
||||||
bool success = !forceFail &&
|
bool success = !forceFail &&
|
||||||
(retVal == 0 ||
|
(retVal == 0 ||
|
||||||
!this->TestProperties->RequiredRegularExpressions.empty());
|
!this->TestProperties->RequiredRegularExpressions.empty());
|
||||||
@@ -215,11 +215,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
|||||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed " << reason);
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed " << reason);
|
||||||
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
|
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
|
||||||
}
|
}
|
||||||
} else if (res == cmsysProcess_State_Expired) {
|
} else if (res == cmProcess::State::Expired) {
|
||||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout ");
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout ");
|
||||||
this->TestResult.Status = cmCTestTestHandler::TIMEOUT;
|
this->TestResult.Status = cmCTestTestHandler::TIMEOUT;
|
||||||
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
|
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
|
||||||
} else if (res == cmsysProcess_State_Exception) {
|
} else if (res == cmProcess::State::Exception) {
|
||||||
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
|
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
|
||||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: ");
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: ");
|
||||||
this->TestResult.ExceptionStatus =
|
this->TestResult.ExceptionStatus =
|
||||||
@@ -248,7 +248,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
|||||||
}
|
}
|
||||||
} else if ("Disabled" == this->TestResult.CompletionStatus) {
|
} else if ("Disabled" == this->TestResult.CompletionStatus) {
|
||||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run (Disabled) ");
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run (Disabled) ");
|
||||||
} else // cmsysProcess_State_Error
|
} else // cmProcess::State::Error
|
||||||
{
|
{
|
||||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run ");
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run ");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,13 +156,29 @@ int cmProcess::GetNextOutputLine(std::string& line,
|
|||||||
return cmsysProcess_Pipe_None;
|
return cmsysProcess_Pipe_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the process status
|
cmProcess::State cmProcess::GetProcessStatus()
|
||||||
int cmProcess::GetProcessStatus()
|
|
||||||
{
|
{
|
||||||
if (!this->Process) {
|
if (this->Process) {
|
||||||
return cmsysProcess_State_Exited;
|
switch (cmsysProcess_GetState(this->Process)) {
|
||||||
|
case cmsysProcess_State_Starting:
|
||||||
|
return State::Starting;
|
||||||
|
case cmsysProcess_State_Error:
|
||||||
|
return State::Error;
|
||||||
|
case cmsysProcess_State_Exception:
|
||||||
|
return State::Exception;
|
||||||
|
case cmsysProcess_State_Executing:
|
||||||
|
return State::Executing;
|
||||||
|
case cmsysProcess_State_Expired:
|
||||||
|
return State::Expired;
|
||||||
|
case cmsysProcess_State_Killed:
|
||||||
|
return State::Killed;
|
||||||
|
case cmsysProcess_State_Disowned:
|
||||||
|
return State::Disowned;
|
||||||
|
default: // case cmsysProcess_State_Exited:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cmsysProcess_GetState(this->Process);
|
return State::Exited;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmProcess::ChangeTimeout(std::chrono::duration<double> t)
|
void cmProcess::ChangeTimeout(std::chrono::duration<double> t)
|
||||||
|
|||||||
@@ -30,8 +30,19 @@ public:
|
|||||||
// Return true if the process starts
|
// Return true if the process starts
|
||||||
bool StartProcess();
|
bool StartProcess();
|
||||||
|
|
||||||
// return the process status
|
enum class State
|
||||||
int GetProcessStatus();
|
{
|
||||||
|
Starting,
|
||||||
|
Error,
|
||||||
|
Exception,
|
||||||
|
Executing,
|
||||||
|
Exited,
|
||||||
|
Expired,
|
||||||
|
Killed,
|
||||||
|
Disowned
|
||||||
|
};
|
||||||
|
|
||||||
|
State GetProcessStatus();
|
||||||
int GetId() { return this->Id; }
|
int GetId() { return this->Id; }
|
||||||
void SetId(int id) { this->Id = id; }
|
void SetId(int id) { this->Id = id; }
|
||||||
int GetExitValue() { return this->ExitValue; }
|
int GetExitValue() { return this->ExitValue; }
|
||||||
|
|||||||
Reference in New Issue
Block a user