Skip to content

Commit

Permalink
Missing required pack msg
Browse files Browse the repository at this point in the history
  • Loading branch information
soumeh01 authored Sep 27, 2024
1 parent 9db8b4c commit f784622
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,16 @@ bool ProjMgrWorker::CollectRequiredPdscFiles(ContextItem& context, const std::st
filteredPack.name +
(reqVersion.empty() ? "" : "@" + reqVersion);
errFound = true;
m_contextErrMap[context.name].insert("required pack: " + packageName + " not installed");
string errMsg = "required pack: " + packageName + " not installed";
const auto& packs = context.csolution->cbuildPack.packs;
auto itr = find_if(packs.begin(), packs.end(), [&](const ResolvedPackItem& item) {
return (item.pack == packageName);
});
// If the pack is from cbuild-pack.yml file, append additional information to the error message
if (itr != packs.end()) {
errMsg += ", version fixed in *.cbuild-pack.yml file";
}
m_contextErrMap[context.name].insert(errMsg);
context.missingPacks.push_back(filteredPack);
}
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::[email protected]
selected-by-pack:
- ARM::RteTest_DFP@>=0.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json

solution:
target-types:
- type: CM0
device: RteTest_ARMCM0@>=0.1.1
packs:
- pack: ARM::RteTest_DFP
projects:
- project: ./project_with_dfp_components.cproject.yml
18 changes: 18 additions & 0 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6469,3 +6469,21 @@ TEST_F(ProjMgrUnitTests, MissingFile) {
const string expectedOutStr = ".*/missing.cproject.yml:7:11 - error csolution: file '.*/TestSolution/missing.c' was not found";
EXPECT_TRUE(regex_search(streamRedirect.GetErrorString(), regex(expectedOutStr)));
}

TEST_F(ProjMgrUnitTests, RunProjMgrSolution_pack_version_not_available) {
char* argv[7];
StdStreamRedirect streamRedirect;
std::string errExpected = "required pack: ARM::[email protected] not installed, version fixed in *.cbuild-pack.yml file";

const string& csolution = testinput_folder + "/TestSolution/PackLocking/pack_version_not_available.csolution.yml";
argv[1] = (char*)"convert";
argv[2] = (char*)"--solution";
argv[3] = (char*)csolution.c_str();
argv[4] = (char*)"-o";
argv[5] = (char*)testoutput_folder.c_str();
argv[6] = (char*)"--cbuildgen";
EXPECT_EQ(1, RunProjMgr(7, argv, 0));

auto errStr = streamRedirect.GetErrorString();
EXPECT_NE(string::npos, errStr.find(errExpected));
}

0 comments on commit f784622

Please sign in to comment.