Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libs/rtemodel/include/RteCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,10 @@ class RteDependencyResult
/**
* @brief gets explanation text for available/incompatible selection
* @param res RteItem::ConditionResult
* @param description aggregate description
* @return explanation text or empty string
*/
static std::string GetAggregateExplanationText(RteItem::ConditionResult res);
static std::string GetAggregateExplanationText(RteItem::ConditionResult res, const std::string& description);

public:
/**
Expand Down
28 changes: 14 additions & 14 deletions libs/rtemodel/src/RteCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ std::string RteDependencyResult::GetComponentExplanationText(RteItem::ConditionR
string message;
switch(res) {
case RteItem::CONFLICT:
message = "Conflict, select exactly one of available matches";
message = "Conflict, select exactly one";
break;
case RteItem::INSTALLED:
case RteItem::SELECTABLE:
Expand All @@ -632,7 +632,7 @@ std::string RteDependencyResult::GetComponentExplanationText(RteItem::ConditionR
case RteItem::INCOMPATIBLE:
case RteItem::INCOMPATIBLE_VERSION:
case RteItem::INCOMPATIBLE_VARIANT:
message = "Incompatible dependency selection";
message = "Incompatible dependency";
break;

default:
Expand All @@ -647,10 +647,10 @@ std::string RteDependencyResult::GetExpressionExplanationText(RteItem::Condition
string message;
switch(res) {
case RteItem::INSTALLED:
message = "Select bundle and component from list";
message = "Select bundle and component";
break;
case RteItem::SELECTABLE:
message = "Select component from list";
message = "Select a component";
break;
case RteItem::MISSING:
message = "Install missing component";
Expand All @@ -668,41 +668,41 @@ std::string RteDependencyResult::GetExpressionExplanationText(RteItem::Condition
message = "Install required API version";
break;
case RteItem::CONFLICT:
message = "Conflict, select exactly one component from list";
message = "Conflict, select exactly one:";
break;
case RteItem::INCOMPATIBLE:
message = "Select compatible component";
message = "Select a compatible component";
break;
case RteItem::INCOMPATIBLE_VERSION:
message = "Select compatible component version";
message = "Select a compatible version";
break;
case RteItem::INCOMPATIBLE_VARIANT:
message = "Select compatible component variant";
message = "Select a compatible variant";
break;
default:
break;
};
return message;
}

std::string RteDependencyResult::GetAggregateExplanationText(RteItem::ConditionResult res)
std::string RteDependencyResult::GetAggregateExplanationText(RteItem::ConditionResult res, const string& description)
{
string message;
switch(res) {
case RteItem::CONFLICT:
message = "conflicted selection";
message = description;
break;
case RteItem::SELECTABLE:
message = "available selection";
message = description;
break;
case RteItem::INCOMPATIBLE:
message = "incompatible selection";
message = "incompatible";
break;
case RteItem::INCOMPATIBLE_VERSION:
message = "incompatible version selection";
message = "incompatible version";
break;
case RteItem::INCOMPATIBLE_VARIANT:
message = "incompatible variant selection";
message = "incompatible variant";
break;
default:
break;
Expand Down
4 changes: 2 additions & 2 deletions tools/projmgr/include/ProjMgrWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ struct ContextTypesItem {
struct ValidationCondition {
RteItem::ConditionResult result;
std::string expression;
StrSet aggregates;
StrMap aggregates;
};

/**
Expand All @@ -295,7 +295,7 @@ struct ValidationCondition {
struct ValidationResult {
RteItem::ConditionResult result;
std::string id;
StrSet aggregates;
StrMap aggregates;
std::vector<ValidationCondition> conditions;
};

Expand Down
6 changes: 4 additions & 2 deletions tools/projmgr/src/ProjMgrRpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,8 @@ RpcArgs::Results RpcHandler::ValidateComponents(const string& context) {
r.result = RteItem::ConditionResultToString(validation.result);
r.id = validation.id;
if(!validation.aggregates.empty()) {
r.aggregates = vector<string>(validation.aggregates.begin(), validation.aggregates.end());
auto aggregateIds = key_set(validation.aggregates);
r.aggregates = vector<string>(aggregateIds.begin(), aggregateIds.end());
}
if(!validation.conditions.empty()) {
RpcArgs::Condition c;
Expand All @@ -748,7 +749,8 @@ RpcArgs::Results RpcHandler::ValidateComponents(const string& context) {
c.expression = condition.expression;
c.result = RteItem::ConditionResultToString(condition.result);
if(!condition.aggregates.empty()) {
c.aggregates = vector<string>(condition.aggregates.begin(), condition.aggregates.end());
auto aggregateIds = key_set(condition.aggregates);
c.aggregates = vector<string>(aggregateIds.begin(), aggregateIds.end());
}
r.conditions->push_back(c);
}
Expand Down
16 changes: 10 additions & 6 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2857,7 +2857,7 @@ RteItem::ConditionResult ProjMgrWorker::ValidateContext(ContextItem& context) {
validation.id = item->ConstructComponentID(true);

for (const auto& aggregate : componentResult.GetComponentAggregates()) {
validation.aggregates.insert(aggregate->ConstructComponentID(true));
validation.aggregates.emplace(aggregate->ConstructComponentID(true), aggregate->GetDescription());
}

const auto& depResults = componentResult.GetResults();
Expand All @@ -2870,7 +2870,7 @@ RteItem::ConditionResult ProjMgrWorker::ValidateContext(ContextItem& context) {
condition.result = conditionRes;
condition.expression = item->GetDependencyExpressionID();
for (const auto& aggregate : result.GetComponentAggregates()) {
condition.aggregates.insert(aggregate->ConstructComponentID(true));
condition.aggregates.emplace(aggregate->ConstructComponentID(true), aggregate->GetDescription());
}
validation.conditions.push_back(condition);
}
Expand Down Expand Up @@ -4801,11 +4801,15 @@ bool ProjMgrWorker::ListTemplates(vector<string>& templates, const string& filte
return true;
}

static string FormatAggregates(RteItem::ConditionResult result, const StrSet& aggregates, unsigned indent) {
static string FormatAggregates(RteItem::ConditionResult result, const StrMap& aggregates, unsigned indent) {
stringstream ss;
for(const auto& id : aggregates) {
for(const auto& [id, desc] : aggregates) {
ss << endl << RteUtils::GetIndent(indent);
ss << "- component " << id << " - " << RteDependencyResult::GetAggregateExplanationText(result);
auto explanation = RteDependencyResult::GetAggregateExplanationText(result, desc);
ss << "- component " << id;
if (!explanation.empty()) {
ss << " # " << explanation;
}
}
return ss.str();
}
Expand All @@ -4822,7 +4826,7 @@ bool ProjMgrWorker::FormatValidationResults(set<string>& results, const ContextI
ss << validation.id << " : " << RteDependencyResult::GetComponentExplanationText(validation.result);

for(const auto& condition : validation.conditions) {
ss << "\n failed '" << condition.expression << "' : " << RteDependencyResult::GetExpressionExplanationText(condition.result);
ss << "\n " << condition.expression << " : " << RteDependencyResult::GetExpressionExplanationText(condition.result);
ss << FormatAggregates(condition.result, condition.aggregates, 4);
}
ss << FormatAggregates(validation.result, validation.aggregates, 2); // API aggregates
Expand Down
29 changes: 16 additions & 13 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4282,24 +4282,24 @@ TEST_F(ProjMgrUnitTests, Convert_ValidationResults_Dependencies) {

map<string, string> testData = {
{"conflict+CM0", "warning csolution: dependency validation for context 'conflict+CM0' failed:\n\
API RteTest:ApiExclusive@1.0.0 : Conflict, select exactly one of available matches\n\
- component ARM::RteTest:ApiExclusive:S1 - conflicted selection\n\
- component ARM::RteTest:ApiExclusive:S2 - conflicted selection" },
API RteTest:ApiExclusive@1.0.0 : Conflict, select exactly one\n\
- component ARM::RteTest:ApiExclusive:S1 # RteTest Exclusive API component S1\n\
- component ARM::RteTest:ApiExclusive:S2 # RteTest Exclusive API component S2\n" },
{"incompatible+CM0", "warning csolution: dependency validation for context 'incompatible+CM0' failed:\n\
component ARM::RteTest:Check:Incompatible@0.9.9 : Incompatible dependency selection\n\
failed 'deny RteTest:Dependency:Incompatible_component' : Select compatible component\n\
- component ARM::RteTest:Dependency:Incompatible_component - incompatible selection" },
component ARM::RteTest:Check:Incompatible@0.9.9 : Incompatible dependency\n\
deny RteTest:Dependency:Incompatible_component : Select a compatible component\n\
- component ARM::RteTest:Dependency:Incompatible_component # incompatible\n" },
{"incompatible-variant+CM0", "warning csolution: dependency validation for context 'incompatible-variant+CM0' failed:\n\
component ARM::RteTest:Check:IncompatibleVariant@0.9.9 : Incompatible dependency selection\n\
failed 'require RteTest:Dependency:Variant&Compatible' : Select compatible component variant\n\
- component ARM::RteTest:Dependency:Variant - incompatible variant selection" },
component ARM::RteTest:Check:IncompatibleVariant@0.9.9 : Incompatible dependency\n\
require RteTest:Dependency:Variant&Compatible : Select a compatible variant\n\
- component ARM::RteTest:Dependency:Variant # incompatible variant\n" },
{"missing+CM0", "warning csolution: dependency validation for context 'missing+CM0' failed:\n\
component ARM::RteTest:Check:Missing@0.9.9 : Unresolved dependencies\n\
failed 'require RteTest:Dependency:Missing' : Install missing component" },
require RteTest:Dependency:Missing : Install missing component\n" },
{"selectable+CM0", "warning csolution: dependency validation for context 'selectable+CM0' failed:\n\
component ARM::Device:Startup&RteTest Startup@2.0.3 : Unresolved dependencies\n\
failed 'require RteTest:CORE' : Select component from list\n\
- component ARM::RteTest:CORE - available selection" }
require RteTest:CORE : Select a component\n\
- component ARM::RteTest:CORE # RteTest CORE component for Cortex-M\n" }
};

for (const auto& [context, expected] : testData) {
Expand All @@ -4308,7 +4308,10 @@ component ARM::Device:Startup&RteTest Startup@2.0.3 : Unresolved dependencies\n\
argv[6] = (char*)context.c_str();
EXPECT_EQ(0, RunProjMgr(7, argv, m_envp));
auto errorStr = streamRedirect.GetErrorString();
EXPECT_NE(string::npos, errorStr.find(expected));
auto pos = errorStr.find("warning csolution: dependency validation");
EXPECT_NE(string::npos, pos);
auto s = errorStr.substr(pos);
EXPECT_EQ(s, expected);
}
}

Expand Down
Loading