"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Source/CTest/cmCTestTestHandler.cxx" between
cmake-3.13.4.tar.gz and cmake-3.14.0-rc1.tar.gz

About: CMake is a cross-platform build system designed to build, test and package software. Release candidate.

cmCTestTestHandler.cxx  (cmake-3.13.4):cmCTestTestHandler.cxx  (cmake-3.14.0-rc1)
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestTestHandler.h" #include "cmCTestTestHandler.h"
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <cmath>
#include <cmsys/Base64.h> #include <cmsys/Base64.h>
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cstring> #include <cstring>
#include <functional> #include <functional>
#include <iomanip> #include <iomanip>
#include <iterator> #include <iterator>
#include <memory> // IWYU pragma: keep #include <memory> // IWYU pragma: keep
#include <set> #include <set>
#include <sstream> #include <sstream>
skipping to change at line 106 skipping to change at line 107
testFilename = "CTestTestfile.cmake"; testFilename = "CTestTestfile.cmake";
} else if (cmSystemTools::FileExists("DartTestfile.txt")) { } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
// does the DartTestfile.txt exist ? // does the DartTestfile.txt exist ?
testFilename = "DartTestfile.txt"; testFilename = "DartTestfile.txt";
} else { } else {
// No CTestTestfile? Who cares... // No CTestTestfile? Who cares...
continue; continue;
} }
fname += "/"; fname += "/";
fname += testFilename; fname += testFilename;
readit = this->Makefile->ReadDependentFile(fname.c_str()); readit = this->Makefile->ReadDependentFile(fname);
} }
if (!readit) { if (!readit) {
std::string m = "Could not find include file: "; std::string m = "Could not find include file: ";
m += fname; m += fname;
this->SetError(m); this->SetError(m);
return false; return false;
} }
} }
return true; return true;
} }
skipping to change at line 172 skipping to change at line 173
testFilename = "CTestTestfile.cmake"; testFilename = "CTestTestfile.cmake";
} else if (cmSystemTools::FileExists("DartTestfile.txt")) { } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
// does the DartTestfile.txt exist ? // does the DartTestfile.txt exist ?
testFilename = "DartTestfile.txt"; testFilename = "DartTestfile.txt";
} else { } else {
// No CTestTestfile? Who cares... // No CTestTestfile? Who cares...
return true; return true;
} }
fname += "/"; fname += "/";
fname += testFilename; fname += testFilename;
readit = this->Makefile->ReadDependentFile(fname.c_str()); readit = this->Makefile->ReadDependentFile(fname);
} }
if (!readit) { if (!readit) {
std::string m = "Could not find include file: "; std::string m = "Could not find include file: ";
m += fname; m += fname;
this->SetError(m); this->SetError(m);
return false; return false;
} }
return true; return true;
} }
skipping to change at line 538 skipping to change at line 539
ft.CompletionStatus == "Disabled") { ft.CompletionStatus == "Disabled") {
disabledTests.push_back(ft); disabledTests.push_back(ft);
} }
} }
float percent = float(passed.size()) * 100.0f / float(total); float percent = float(passed.size()) * 100.0f / float(total);
if (!failed.empty() && percent > 99) { if (!failed.empty() && percent > 99) {
percent = 99; percent = 99;
} }
std::string passColorCode;
std::string failedColorCode;
if (failed.empty()) {
passColorCode = this->CTest->GetColorCode(cmCTest::Color::GREEN);
} else {
failedColorCode = this->CTest->GetColorCode(cmCTest::Color::RED);
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestLog(this->CTest, HANDLER_OUTPUT,
std::endl std::endl
<< static_cast<int>(percent + .5f) << "% tests passed, " << passColorCode << std::lround(percent) << "% tests passed"
<< failed.size() << " tests failed out of " << total << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
<< std::endl); << ", " << failedColorCode << failed.size() << " tests failed"
<< this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
<< " out of " << total << std::endl);
if ((!this->CTest->GetLabelsForSubprojects().empty() && if ((!this->CTest->GetLabelsForSubprojects().empty() &&
this->CTest->GetSubprojectSummary())) { this->CTest->GetSubprojectSummary())) {
this->PrintLabelOrSubprojectSummary(true); this->PrintLabelOrSubprojectSummary(true);
} }
if (this->CTest->GetLabelSummary()) { if (this->CTest->GetLabelSummary()) {
this->PrintLabelOrSubprojectSummary(false); this->PrintLabelOrSubprojectSummary(false);
} }
char realBuf[1024]; char realBuf[1024];
cmDuration durationInSecs = clock_finish - clock_start; cmDuration durationInSecs = clock_finish - clock_start;
sprintf(realBuf, "%6.2f sec", durationInSecs.count()); sprintf(realBuf, "%6.2f sec", durationInSecs.count());
skipping to change at line 565 skipping to change at line 575
this->Quiet); this->Quiet);
if (!disabledTests.empty()) { if (!disabledTests.empty()) {
cmGeneratedFileStream ofs; cmGeneratedFileStream ofs;
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestLog(this->CTest, HANDLER_OUTPUT,
std::endl std::endl
<< "The following tests did not run:" << std::endl); << "The following tests did not run:" << std::endl);
this->StartLogFile("TestsDisabled", ofs); this->StartLogFile("TestsDisabled", ofs);
const char* disabled_reason; const char* disabled_reason;
cmCTestLog(this->CTest, HANDLER_OUTPUT,
this->CTest->GetColorCode(cmCTest::Color::BLUE));
for (cmCTestTestResult const& dt : disabledTests) { for (cmCTestTestResult const& dt : disabledTests) {
ofs << dt.TestCount << ":" << dt.Name << std::endl; ofs << dt.TestCount << ":" << dt.Name << std::endl;
if (dt.CompletionStatus == "Disabled") { if (dt.CompletionStatus == "Disabled") {
disabled_reason = "Disabled"; disabled_reason = "Disabled";
} else { } else {
disabled_reason = "Skipped"; disabled_reason = "Skipped";
} }
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestLog(this->CTest, HANDLER_OUTPUT,
"\t" << std::setw(3) << dt.TestCount << " - " << dt.Name "\t" << std::setw(3) << dt.TestCount << " - " << dt.Name
<< " (" << disabled_reason << ")" << std::endl); << " (" << disabled_reason << ")" << std::endl);
} }
cmCTestLog(this->CTest, HANDLER_OUTPUT,
this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR));
} }
if (!failed.empty()) { if (!failed.empty()) {
cmGeneratedFileStream ofs; cmGeneratedFileStream ofs;
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestLog(this->CTest, HANDLER_OUTPUT,
std::endl std::endl
<< "The following tests FAILED:" << std::endl); << "The following tests FAILED:" << std::endl);
this->StartLogFile("TestsFailed", ofs); this->StartLogFile("TestsFailed", ofs);
for (cmCTestTestResult const& ft : resultsSet) { for (cmCTestTestResult const& ft : resultsSet) {
if (ft.Status != cmCTestTestHandler::COMPLETED && if (ft.Status != cmCTestTestHandler::COMPLETED &&
!cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_RETURN_CODE=") && !cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_RETURN_CODE=") &&
ft.CompletionStatus != "Disabled") { ft.CompletionStatus != "Disabled") {
ofs << ft.TestCount << ":" << ft.Name << std::endl; ofs << ft.TestCount << ":" << ft.Name << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, auto testColor = cmCTest::Color::RED;
"\t" << std::setw(3) << ft.TestCount << " - " << ft.Name if (this->GetTestStatus(ft) == "Not Run") {
<< " (" << this->GetTestStatus(ft) << ")" testColor = cmCTest::Color::YELLOW;
<< std::endl); }
cmCTestLog(
this->CTest, HANDLER_OUTPUT,
"\t" << this->CTest->GetColorCode(testColor) << std::setw(3)
<< ft.TestCount << " - " << ft.Name << " ("
<< this->GetTestStatus(ft) << ")"
<< this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
<< std::endl);
} }
} }
} }
} }
if (this->CTest->GetProduceXML()) { if (this->CTest->GetProduceXML()) {
cmGeneratedFileStream xmlfile; cmGeneratedFileStream xmlfile;
if (!this->StartResultingXML( if (!this->StartResultingXML(
(this->MemCheck ? cmCTest::PartMemCheck : cmCTest::PartTest), (this->MemCheck ? cmCTest::PartMemCheck : cmCTest::PartTest),
(this->MemCheck ? "DynamicAnalysis" : "Test"), xmlfile)) { (this->MemCheck ? "DynamicAnalysis" : "Test"), xmlfile)) {
skipping to change at line 1506 skipping to change at line 1527
std::vector<std::string>& attemptedConfigs, std::string filepath, std::vector<std::string>& attemptedConfigs, std::string filepath,
std::string& filename) std::string& filename)
{ {
std::string tempPath; std::string tempPath;
if (!filepath.empty() && filepath[filepath.size() - 1] != '/') { if (!filepath.empty() && filepath[filepath.size() - 1] != '/') {
filepath += "/"; filepath += "/";
} }
tempPath = filepath + filename; tempPath = filepath + filename;
attempted.push_back(tempPath); attempted.push_back(tempPath);
attemptedConfigs.push_back(""); attemptedConfigs.emplace_back();
if (!ctest->GetConfigType().empty()) { if (!ctest->GetConfigType().empty()) {
tempPath = filepath; tempPath = filepath;
tempPath += ctest->GetConfigType(); tempPath += ctest->GetConfigType();
tempPath += "/"; tempPath += "/";
tempPath += filename; tempPath += filename;
attempted.push_back(tempPath); attempted.push_back(tempPath);
attemptedConfigs.push_back(ctest->GetConfigType()); attemptedConfigs.push_back(ctest->GetConfigType());
// If the file is an OSX bundle then the configtype // If the file is an OSX bundle then the configtype
// will be at the start of the path // will be at the start of the path
skipping to change at line 1529 skipping to change at line 1550
tempPath += filepath; tempPath += filepath;
tempPath += filename; tempPath += filename;
attempted.push_back(tempPath); attempted.push_back(tempPath);
attemptedConfigs.push_back(ctest->GetConfigType()); attemptedConfigs.push_back(ctest->GetConfigType());
} else { } else {
// no config specified - try some options... // no config specified - try some options...
tempPath = filepath; tempPath = filepath;
tempPath += "Release/"; tempPath += "Release/";
tempPath += filename; tempPath += filename;
attempted.push_back(tempPath); attempted.push_back(tempPath);
attemptedConfigs.push_back("Release"); attemptedConfigs.emplace_back("Release");
tempPath = filepath; tempPath = filepath;
tempPath += "Debug/"; tempPath += "Debug/";
tempPath += filename; tempPath += filename;
attempted.push_back(tempPath); attempted.push_back(tempPath);
attemptedConfigs.push_back("Debug"); attemptedConfigs.emplace_back("Debug");
tempPath = filepath; tempPath = filepath;
tempPath += "MinSizeRel/"; tempPath += "MinSizeRel/";
tempPath += filename; tempPath += filename;
attempted.push_back(tempPath); attempted.push_back(tempPath);
attemptedConfigs.push_back("MinSizeRel"); attemptedConfigs.emplace_back("MinSizeRel");
tempPath = filepath; tempPath = filepath;
tempPath += "RelWithDebInfo/"; tempPath += "RelWithDebInfo/";
tempPath += filename; tempPath += filename;
attempted.push_back(tempPath); attempted.push_back(tempPath);
attemptedConfigs.push_back("RelWithDebInfo"); attemptedConfigs.emplace_back("RelWithDebInfo");
tempPath = filepath; tempPath = filepath;
tempPath += "Deployment/"; tempPath += "Deployment/";
tempPath += filename; tempPath += filename;
attempted.push_back(tempPath); attempted.push_back(tempPath);
attemptedConfigs.push_back("Deployment"); attemptedConfigs.emplace_back("Deployment");
tempPath = filepath; tempPath = filepath;
tempPath += "Development/"; tempPath += "Development/";
tempPath += filename; tempPath += filename;
attempted.push_back(tempPath); attempted.push_back(tempPath);
attemptedConfigs.push_back("Deployment"); attemptedConfigs.emplace_back("Deployment");
} }
} }
// Find the appropriate executable to run for a test // Find the appropriate executable to run for a test
std::string cmCTestTestHandler::FindExecutable( std::string cmCTestTestHandler::FindExecutable(
cmCTest* ctest, const char* testCommand, std::string& resultingConfig, cmCTest* ctest, const char* testCommand, std::string& resultingConfig,
std::vector<std::string>& extraPaths, std::vector<std::string>& failed) std::vector<std::string>& extraPaths, std::vector<std::string>& failed)
{ {
// now run the compiled test if we can find it // now run the compiled test if we can find it
std::vector<std::string> attempted; std::vector<std::string> attempted;
skipping to change at line 1658 skipping to change at line 1679
this->ExcludeLabelRegExp.c_str()); this->ExcludeLabelRegExp.c_str());
} }
if (!this->IncludeRegExp.empty()) { if (!this->IncludeRegExp.empty()) {
this->IncludeTestsRegularExpression.compile(this->IncludeRegExp.c_str()); this->IncludeTestsRegularExpression.compile(this->IncludeRegExp.c_str());
} }
if (!this->ExcludeRegExp.empty()) { if (!this->ExcludeRegExp.empty()) {
this->ExcludeTestsRegularExpression.compile(this->ExcludeRegExp.c_str()); this->ExcludeTestsRegularExpression.compile(this->ExcludeRegExp.c_str());
} }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Constructing a list of tests" << std::endl, this->Quiet); "Constructing a list of tests" << std::endl, this->Quiet);
cmake cm(cmake::RoleScript); cmake cm(cmake::RoleScript, cmState::CTest);
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmMakefile mf(&gg, cm.GetCurrentSnapshot()); cmMakefile mf(&gg, cm.GetCurrentSnapshot());
mf.AddDefinition("CTEST_CONFIGURATION_TYPE", mf.AddDefinition("CTEST_CONFIGURATION_TYPE",
this->CTest->GetConfigType().c_str()); this->CTest->GetConfigType().c_str());
// Add handler for ADD_TEST // Add handler for ADD_TEST
cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand; cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand;
skipping to change at line 1728 skipping to change at line 1749
{ {
this->UseIncludeRegExpFlag = true; this->UseIncludeRegExpFlag = true;
} }
void cmCTestTestHandler::UseExcludeRegExp() void cmCTestTestHandler::UseExcludeRegExp()
{ {
this->UseExcludeRegExpFlag = true; this->UseExcludeRegExpFlag = true;
this->UseExcludeRegExpFirst = !this->UseIncludeRegExpFlag; this->UseExcludeRegExpFirst = !this->UseIncludeRegExpFlag;
} }
const char* cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result) std::string cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result)
{ {
static const char* statuses[] = { "Not Run", "Timeout", "SEGFAULT", static const char* statuses[] = { "Not Run", "Timeout", "SEGFAULT",
"ILLEGAL", "INTERRUPT", "NUMERICAL", "ILLEGAL", "INTERRUPT", "NUMERICAL",
"OTHER_FAULT", "Failed", "BAD_COMMAND", "OTHER_FAULT", "Failed", "BAD_COMMAND",
"Completed" }; "Completed" };
int status = result.Status; int status = result.Status;
if (status < cmCTestTestHandler::NOT_RUN || if (status < cmCTestTestHandler::NOT_RUN ||
status > cmCTestTestHandler::COMPLETED) { status > cmCTestTestHandler::COMPLETED) {
return "No Status"; return "No Status";
} }
if (status == cmCTestTestHandler::OTHER_FAULT) { if (status == cmCTestTestHandler::OTHER_FAULT) {
return result.ExceptionStatus.c_str(); return result.ExceptionStatus;
} }
return statuses[status]; return statuses[status];
} }
void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests) void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests)
{ {
if (this->TestsToRunString.empty()) { if (this->TestsToRunString.empty()) {
return; return;
} }
skipping to change at line 2129 skipping to change at line 2150
for (; it != args.end(); ++it) { for (; it != args.end(); ++it) {
std::string key = *it; std::string key = *it;
++it; ++it;
if (it == args.end()) { if (it == args.end()) {
break; break;
} }
std::string val = *it; std::string val = *it;
for (std::string const& t : tests) { for (std::string const& t : tests) {
for (cmCTestTestProperties& rt : this->TestList) { for (cmCTestTestProperties& rt : this->TestList) {
if (t == rt.Name) { if (t == rt.Name) {
if (key == "_BACKTRACE_TRIPLES") {
std::vector<std::string> triples;
// allow empty args in the triples
cmSystemTools::ExpandListArgument(val, triples, true);
// Ensure we have complete triples otherwise the data is corrupt.
if (triples.size() % 3 == 0) {
cmState state;
rt.Backtrace = cmListFileBacktrace(state.CreateBaseSnapshot());
// the first entry represents the top of the trace so we need to
// reconstruct the backtrace in reverse
for (size_t i = triples.size(); i >= 3; i -= 3) {
cmListFileContext fc;
fc.FilePath = triples[i - 3];
long line = 0;
if (!cmSystemTools::StringToLong(triples[i - 2].c_str(),
&line)) {
line = 0;
}
fc.Line = line;
fc.Name = triples[i - 1];
rt.Backtrace = rt.Backtrace.Push(fc);
}
}
}
if (key == "WILL_FAIL") { if (key == "WILL_FAIL") {
rt.WillFail = cmSystemTools::IsOn(val); rt.WillFail = cmSystemTools::IsOn(val);
} }
if (key == "DISABLED") { if (key == "DISABLED") {
rt.Disabled = cmSystemTools::IsOn(val); rt.Disabled = cmSystemTools::IsOn(val);
} }
if (key == "ATTACHED_FILES") { if (key == "ATTACHED_FILES") {
cmSystemTools::ExpandListArgument(val, rt.AttachedFiles); cmSystemTools::ExpandListArgument(val, rt.AttachedFiles);
} }
if (key == "ATTACHED_FILES_ON_FAIL") { if (key == "ATTACHED_FILES_ON_FAIL") {
 End of changes. 19 change blocks. 
19 lines changed or deleted 66 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)