diff options
author | Bryon Bean <bryon.bean@kitware.com> | 2017-10-23 12:16:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-01-10 15:19:14 (GMT) |
commit | 3dd2edf4ab94f5044b73b20151592c8e94a5160a (patch) | |
tree | 06fa23b1b2e78bd60231c50786fa2402a0bb376a /Source | |
parent | 5238e6db70d275e42048479b737781fc97d82ea1 (diff) | |
download | CMake-3dd2edf4ab94f5044b73b20151592c8e94a5160a.zip CMake-3dd2edf4ab94f5044b73b20151592c8e94a5160a.tar.gz CMake-3dd2edf4ab94f5044b73b20151592c8e94a5160a.tar.bz2 |
cmProcess: Use explicit enum for process state
Translate the values from KWSys Process.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CTest/cmCTestRunTest.cxx | 12 | ||||
-rw-r--r-- | Source/CTest/cmProcess.cxx | 26 | ||||
-rw-r--r-- | Source/CTest/cmProcess.h | 15 |
3 files changed, 40 insertions, 13 deletions
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 904f148..1f7516c 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -154,8 +154,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) this->WriteLogOutputTop(completed, total); std::string reason; bool passed = true; - int res = - started ? this->TestProcess->GetProcessStatus() : cmsysProcess_State_Error; + cmProcess::State res = + started ? this->TestProcess->GetProcessStatus() : cmProcess::State::Error; int retVal = this->TestProcess->GetExitValue(); bool forceFail = 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 && (retVal == 0 || !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); outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure; } - } else if (res == cmsysProcess_State_Expired) { + } else if (res == cmProcess::State::Expired) { cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout "); this->TestResult.Status = cmCTestTestHandler::TIMEOUT; outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure; - } else if (res == cmsysProcess_State_Exception) { + } else if (res == cmProcess::State::Exception) { outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure; cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: "); this->TestResult.ExceptionStatus = @@ -248,7 +248,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) } } else if ("Disabled" == this->TestResult.CompletionStatus) { cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run (Disabled) "); - } else // cmsysProcess_State_Error + } else // cmProcess::State::Error { cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run "); } diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index a599454..fac0df9 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -156,13 +156,29 @@ int cmProcess::GetNextOutputLine(std::string& line, return cmsysProcess_Pipe_None; } -// return the process status -int cmProcess::GetProcessStatus() +cmProcess::State cmProcess::GetProcessStatus() { - if (!this->Process) { - return cmsysProcess_State_Exited; + if (this->Process) { + 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) diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h index 32c4c74..79379aa 100644 --- a/Source/CTest/cmProcess.h +++ b/Source/CTest/cmProcess.h @@ -30,8 +30,19 @@ public: // Return true if the process starts bool StartProcess(); - // return the process status - int GetProcessStatus(); + enum class State + { + Starting, + Error, + Exception, + Executing, + Exited, + Expired, + Killed, + Disowned + }; + + State GetProcessStatus(); int GetId() { return this->Id; } void SetId(int id) { this->Id = id; } int GetExitValue() { return this->ExitValue; } |