From f784622d345e5e0d716e9a50d984979180eaa185 Mon Sep 17 00:00:00 2001 From: Sourabh Mehta <73165318+soumeh01@users.noreply.github.com> Date: Fri, 27 Sep 2024 15:43:13 +0200 Subject: [PATCH] Missing required pack msg --- tools/projmgr/src/ProjMgrWorker.cpp | 11 ++++++++++- .../pack_version_not_available.cbuild-pack.yml | 5 +++++ .../pack_version_not_available.csolution.yml | 10 ++++++++++ tools/projmgr/test/src/ProjMgrUnitTests.cpp | 18 ++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tools/projmgr/test/data/TestSolution/PackLocking/pack_version_not_available.cbuild-pack.yml create mode 100644 tools/projmgr/test/data/TestSolution/PackLocking/pack_version_not_available.csolution.yml diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index 439593849..2e578a7bf 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -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; diff --git a/tools/projmgr/test/data/TestSolution/PackLocking/pack_version_not_available.cbuild-pack.yml b/tools/projmgr/test/data/TestSolution/PackLocking/pack_version_not_available.cbuild-pack.yml new file mode 100644 index 000000000..e88a405cd --- /dev/null +++ b/tools/projmgr/test/data/TestSolution/PackLocking/pack_version_not_available.cbuild-pack.yml @@ -0,0 +1,5 @@ +cbuild-pack: + resolved-packs: + - resolved-pack: ARM::RteTest_DFP@0.1.0 + selected-by-pack: + - ARM::RteTest_DFP@>=0.1.1 diff --git a/tools/projmgr/test/data/TestSolution/PackLocking/pack_version_not_available.csolution.yml b/tools/projmgr/test/data/TestSolution/PackLocking/pack_version_not_available.csolution.yml new file mode 100644 index 000000000..d9fc129ee --- /dev/null +++ b/tools/projmgr/test/data/TestSolution/PackLocking/pack_version_not_available.csolution.yml @@ -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 diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp index 2ddb8ef0a..dc42ddd41 100644 --- a/tools/projmgr/test/src/ProjMgrUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -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::RteTest_DFP@0.1.0 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)); +}