diff options
author | Brad King <brad.king@kitware.com> | 2017-07-13 11:50:43 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-07-13 11:51:05 (GMT) |
commit | 47d9772618bd44a9816731cec25255c3d64b0084 (patch) | |
tree | e4365461cfb7b1c3f45b148341b10aab9a5eaa9a /Source | |
parent | 0f158272d6ad0f681495482530b37d307676a157 (diff) | |
parent | 0c650f39659a62c03012ec07dc32effd3bfba6e8 (diff) | |
download | CMake-47d9772618bd44a9816731cec25255c3d64b0084.zip CMake-47d9772618bd44a9816731cec25255c3d64b0084.tar.gz CMake-47d9772618bd44a9816731cec25255c3d64b0084.tar.bz2 |
Merge topic 'better-exception-reporting'
0c650f39 CTest: Report more detail about system exceptions in tests
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1046
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CTest/cmCTestRunTest.cxx | 5 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 26 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 3 | ||||
-rw-r--r-- | Source/CTest/cmProcess.cxx | 5 | ||||
-rw-r--r-- | Source/CTest/cmProcess.h | 1 |
5 files changed, 26 insertions, 14 deletions
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 0c4269e..9274c01 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -237,6 +237,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) } else if (res == cmsysProcess_State_Exception) { outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure; cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: "); + this->TestResult.ExceptionStatus = + this->TestProcess->GetExitExceptionString(); switch (this->TestProcess->GetExitException()) { case cmsysProcess_Exception_Fault: cmCTestLog(this->CTest, HANDLER_OUTPUT, "SegFault"); @@ -255,7 +257,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) this->TestResult.Status = cmCTestTestHandler::NUMERICAL; break; default: - cmCTestLog(this->CTest, HANDLER_OUTPUT, "Other"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + this->TestResult.ExceptionStatus); this->TestResult.Status = cmCTestTestHandler::OTHER_FAULT; } } else if ("Disabled" == this->TestResult.CompletionStatus) { diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 63d696f..8797204 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1,12 +1,10 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestTestHandler.h" - -#include "cmsys/Base64.h" -#include "cmsys/Directory.hxx" -#include "cmsys/FStream.hxx" -#include "cmsys/RegularExpression.hxx" #include <algorithm> +#include <cmsys/Base64.h> +#include <cmsys/Directory.hxx> +#include <cmsys/RegularExpression.hxx> #include <functional> #include <iomanip> #include <iterator> @@ -33,6 +31,7 @@ #include "cm_auto_ptr.hxx" #include "cm_utf8.h" #include "cmake.h" +#include "cmsys/FStream.hxx" class cmExecutionStatus; @@ -584,10 +583,10 @@ int cmCTestTestHandler::ProcessHandler() !cmHasLiteralPrefix(ftit->CompletionStatus, "SKIP_RETURN_CODE=") && ftit->CompletionStatus != "Disabled") { ofs << ftit->TestCount << ":" << ftit->Name << std::endl; - cmCTestLog( - this->CTest, HANDLER_OUTPUT, "\t" - << std::setw(3) << ftit->TestCount << " - " << ftit->Name << " (" - << this->GetTestStatus(ftit->Status) << ")" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" + << std::setw(3) << ftit->TestCount << " - " + << ftit->Name << " (" << this->GetTestStatus(&*ftit) + << ")" << std::endl); } } } @@ -1413,7 +1412,7 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) xml.StartElement("NamedMeasurement"); xml.Attribute("type", "text/string"); xml.Attribute("name", "Exit Code"); - xml.Element("Value", this->GetTestStatus(result->Status)); + xml.Element("Value", this->GetTestStatus(result)); xml.EndElement(); // NamedMeasurement xml.StartElement("NamedMeasurement"); @@ -1813,17 +1812,20 @@ void cmCTestTestHandler::UseExcludeRegExp() this->UseExcludeRegExpFirst = !this->UseIncludeRegExpFlag; } -const char* cmCTestTestHandler::GetTestStatus(int status) +const char* cmCTestTestHandler::GetTestStatus(const cmCTestTestResult* result) { static const char* statuses[] = { "Not Run", "Timeout", "SEGFAULT", "ILLEGAL", "INTERRUPT", "NUMERICAL", "OTHER_FAULT", "Failed", "BAD_COMMAND", "Completed" }; - + int status = result->Status; if (status < cmCTestTestHandler::NOT_RUN || status > cmCTestTestHandler::COMPLETED) { return "No Status"; } + if (status == cmCTestTestHandler::OTHER_FAULT) { + return result->ExceptionStatus.c_str(); + } return statuses[status]; } diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index b82e382..6dbbcf8 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -149,6 +149,7 @@ public: double ExecutionTime; int ReturnValue; int Status; + std::string ExceptionStatus; bool CompressOutput; std::string CompletionStatus; std::string Output; @@ -269,7 +270,7 @@ private: */ std::string FindTheExecutable(const char* exe); - const char* GetTestStatus(int status); + const char* GetTestStatus(const cmCTestTestResult*); void ExpandTestsToRunInformation(size_t numPossibleTests); void ExpandTestsToRunInformationForRerunFailed(); diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index f4ec6da..9680a69 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -240,3 +240,8 @@ int cmProcess::GetExitException() { return cmsysProcess_GetExitException(this->Process); } + +std::string cmProcess::GetExitExceptionString() +{ + return cmsysProcess_GetExceptionString(this->Process); +} diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h index 86e905a..dfb02fe 100644 --- a/Source/CTest/cmProcess.h +++ b/Source/CTest/cmProcess.h @@ -38,6 +38,7 @@ public: int GetExitValue() { return this->ExitValue; } double GetTotalTime() { return this->TotalTime; } int GetExitException(); + std::string GetExitExceptionString(); /** * Read one line of output but block for no more than timeout. * Returns: |