mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-17 12:40:40 -06:00
CTest: Add SKIP_REGULAR_EXPRESSION test property
This commit is contained in:
committed by
Kyle Edwards
parent
e3bd5c5b66
commit
4f1dec86a5
@@ -823,6 +823,11 @@ static Json::Value DumpCTestProperties(
|
|||||||
"FAIL_REGULAR_EXPRESSION",
|
"FAIL_REGULAR_EXPRESSION",
|
||||||
DumpRegExToJsonArray(testProperties.ErrorRegularExpressions)));
|
DumpRegExToJsonArray(testProperties.ErrorRegularExpressions)));
|
||||||
}
|
}
|
||||||
|
if (!testProperties.SkipRegularExpressions.empty()) {
|
||||||
|
properties.append(DumpCTestProperty(
|
||||||
|
"SKIP_REGULAR_EXPRESSION",
|
||||||
|
DumpRegExToJsonArray(testProperties.SkipRegularExpressions)));
|
||||||
|
}
|
||||||
if (!testProperties.FixturesCleanup.empty()) {
|
if (!testProperties.FixturesCleanup.empty()) {
|
||||||
properties.append(DumpCTestProperty(
|
properties.append(DumpCTestProperty(
|
||||||
"FIXTURES_CLEANUP", DumpToJsonArray(testProperties.FixturesCleanup)));
|
"FIXTURES_CLEANUP", DumpToJsonArray(testProperties.FixturesCleanup)));
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
|||||||
}
|
}
|
||||||
std::int64_t retVal = this->TestProcess->GetExitValue();
|
std::int64_t retVal = this->TestProcess->GetExitValue();
|
||||||
bool forceFail = false;
|
bool forceFail = false;
|
||||||
|
bool forceSkip = false;
|
||||||
bool skipped = false;
|
bool skipped = false;
|
||||||
bool outputTestErrorsToConsole = false;
|
bool outputTestErrorsToConsole = false;
|
||||||
if (!this->TestProperties->RequiredRegularExpressions.empty() &&
|
if (!this->TestProperties->RequiredRegularExpressions.empty() &&
|
||||||
@@ -116,16 +117,34 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!this->TestProperties->SkipRegularExpressions.empty() &&
|
||||||
|
this->FailedDependencies.empty()) {
|
||||||
|
for (auto& skip : this->TestProperties->SkipRegularExpressions) {
|
||||||
|
if (skip.first.find(this->ProcessOutput)) {
|
||||||
|
reason = "Skip regular expression found in output.";
|
||||||
|
reason += " Regex=[";
|
||||||
|
reason += skip.second;
|
||||||
|
reason += "]";
|
||||||
|
forceSkip = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
std::ostringstream outputStream;
|
std::ostringstream outputStream;
|
||||||
if (res == cmProcess::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());
|
||||||
if (this->TestProperties->SkipReturnCode >= 0 &&
|
if ((this->TestProperties->SkipReturnCode >= 0 &&
|
||||||
this->TestProperties->SkipReturnCode == retVal) {
|
this->TestProperties->SkipReturnCode == retVal) ||
|
||||||
|
forceSkip) {
|
||||||
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
|
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << "SKIP_RETURN_CODE=" << this->TestProperties->SkipReturnCode;
|
if (forceSkip) {
|
||||||
|
s << "SKIP_REGULAR_EXPRESSION_MATCHED";
|
||||||
|
} else {
|
||||||
|
s << "SKIP_RETURN_CODE=" << this->TestProperties->SkipReturnCode;
|
||||||
|
}
|
||||||
this->TestResult.CompletionStatus = s.str();
|
this->TestResult.CompletionStatus = s.str();
|
||||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Skipped ");
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Skipped ");
|
||||||
skipped = true;
|
skipped = true;
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ int cmCTestTestHandler::ProcessHandler()
|
|||||||
std::vector<cmCTestTestHandler::cmCTestTestResult> disabledTests;
|
std::vector<cmCTestTestHandler::cmCTestTestResult> disabledTests;
|
||||||
|
|
||||||
for (cmCTestTestResult const& ft : resultsSet) {
|
for (cmCTestTestResult const& ft : resultsSet) {
|
||||||
if (cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_RETURN_CODE=") ||
|
if (cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_") ||
|
||||||
ft.CompletionStatus == "Disabled") {
|
ft.CompletionStatus == "Disabled") {
|
||||||
disabledTests.push_back(ft);
|
disabledTests.push_back(ft);
|
||||||
}
|
}
|
||||||
@@ -599,7 +599,7 @@ int cmCTestTestHandler::ProcessHandler()
|
|||||||
|
|
||||||
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_") &&
|
||||||
ft.CompletionStatus != "Disabled") {
|
ft.CompletionStatus != "Disabled") {
|
||||||
ofs << ft.TestCount << ":" << ft.Name << std::endl;
|
ofs << ft.TestCount << ":" << ft.Name << std::endl;
|
||||||
auto testColor = cmCTest::Color::RED;
|
auto testColor = cmCTest::Color::RED;
|
||||||
@@ -2229,6 +2229,13 @@ bool cmCTestTestHandler::SetTestsProperties(
|
|||||||
rt.ErrorRegularExpressions.emplace_back(cr, cr);
|
rt.ErrorRegularExpressions.emplace_back(cr, cr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (key == "SKIP_REGULAR_EXPRESSION") {
|
||||||
|
std::vector<std::string> lval;
|
||||||
|
cmSystemTools::ExpandListArgument(val, lval);
|
||||||
|
for (std::string const& cr : lval) {
|
||||||
|
rt.SkipRegularExpressions.emplace_back(cr, cr);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (key == "PROCESSORS") {
|
if (key == "PROCESSORS") {
|
||||||
rt.Processors = atoi(val.c_str());
|
rt.Processors = atoi(val.c_str());
|
||||||
if (rt.Processors < 1) {
|
if (rt.Processors < 1) {
|
||||||
|
|||||||
@@ -117,6 +117,8 @@ public:
|
|||||||
ErrorRegularExpressions;
|
ErrorRegularExpressions;
|
||||||
std::vector<std::pair<cmsys::RegularExpression, std::string>>
|
std::vector<std::pair<cmsys::RegularExpression, std::string>>
|
||||||
RequiredRegularExpressions;
|
RequiredRegularExpressions;
|
||||||
|
std::vector<std::pair<cmsys::RegularExpression, std::string>>
|
||||||
|
SkipRegularExpressions;
|
||||||
std::vector<std::pair<cmsys::RegularExpression, std::string>>
|
std::vector<std::pair<cmsys::RegularExpression, std::string>>
|
||||||
TimeoutRegularExpressions;
|
TimeoutRegularExpressions;
|
||||||
std::map<std::string, std::string> Measurements;
|
std::map<std::string, std::string> Measurements;
|
||||||
|
|||||||
Reference in New Issue
Block a user