Skip to content

Commit d0c0775

Browse files
[projmgr] Check pack identifier case consistency
1 parent 7b3c54e commit d0c0775

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

libs/rtefsutils/src/RteFsUtils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,9 @@ string RteFsUtils::FindFirstFileWithExt(const std::string &folder, const char *e
641641
void RteFsUtils::GetFilesSorted(const string &folder, set<string, VersionCmp::Greater> &files) {
642642
error_code ec;
643643
// Path does not exist, nothing to do
644-
if (folder.empty() || !fs::exists(folder, ec) || !fs::is_directory(folder, ec)) {
644+
if ((folder.empty() || !fs::exists(folder, ec) || !fs::is_directory(folder, ec)) ||
645+
// Check case consistency
646+
(fs::canonical(folder, ec).generic_string().find(fs::path(folder).lexically_normal().generic_string()) == string::npos)) {
645647
return;
646648
}
647649
for (auto entry : fs::directory_iterator(folder, ec)) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json
2+
3+
solution:
4+
target-types:
5+
- type: CM0
6+
device: RteTest_ARMCM0
7+
8+
packs:
9+
- pack: ARM::RteTest_DFP
10+
- pack: Arm::RteTest_DFP
11+
12+
projects:
13+
- project: pack_path.cproject.yml

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6549,3 +6549,14 @@ TEST_F(ProjMgrUnitTests, GetToolboxVersion) {
65496549

65506550
RteFsUtils::RemoveDir(testdir);
65516551
}
6552+
6553+
TEST_F(ProjMgrUnitTests, PackCaseSensitive) {
6554+
char* argv[3];
6555+
const string& csolution = testinput_folder + "/TestSolution/pack_case_sensitive.csolution.yml";
6556+
argv[1] = (char*)"convert";
6557+
argv[2] = (char*)csolution.c_str();
6558+
EXPECT_EQ(1, RunProjMgr(3, argv, 0));
6559+
const YAML::Node& cbuild = YAML::LoadFile(testinput_folder + "/TestSolution/pack_case_sensitive.cbuild-idx.yml");
6560+
EXPECT_EQ("required pack: Arm::RteTest_DFP not installed",
6561+
cbuild["build-idx"]["cbuilds"][0]["messages"]["errors"][0].as<string>());
6562+
}

0 commit comments

Comments
 (0)