Skip to content
Merged
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 tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,8 @@
"layer": {
"title": "layer:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#layers",
"type": "string",
"description": "Path to the '*.clayer.yml' file that defines the layer."
"pattern": "^.*[/]([^.+]*\\.clayer\\.(yml|yaml))$|^([^.+]+)\\.clayer\\.(yml|yaml)$|^\\$[^$]+\\$$|^$",
Comment thread
brondani marked this conversation as resolved.
Resolved
"description": "Path to the valid layer file or layer variable. May be empty to leave the layer unspecified."
},
"type": {
"title": "type:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#layer-type",
Expand Down
33 changes: 33 additions & 0 deletions tools/projmgr/test/src/ProjMgrSchemaCheckerUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,39 @@ TEST_F(ProjMgrSchemaCheckerUnitTests, SchemaCheck_Empty_Object) {
EXPECT_TRUE(GetErrors().empty());
}

TEST_F(ProjMgrSchemaCheckerUnitTests, SchemaCheck_LayerPattern) {
const vector<pair<string, bool>> testCases = {
{ "test.clayer.yml", true },
{ "test.clayer.yaml", true },
{ "../path.with+symbols/test.clayer.yml", true },
{ "../path.with+symbols/test.clayer.yaml", true },
{ "$variable$", true },
{ "$Layer_Path$/test.clayer.yml", true },
{ "test.yml", false },
{ "test.cproject.yml", false },
{ "test.clayer.yml.bak", false },
{ "test.layer.clayer.yml", false },
{ "../layers/test+layer.clayer.yml", false },
{ "$variable", false },
{ "variable$", false },
{ "$$", false },
{ "$one$two$", false },
{ "", true },
};
const string filename = testoutput_folder + "/layer-pattern.cproject.yml";
for (const auto& [layer, expected] : testCases) {
{
ofstream fileStream(filename);
fileStream << "project:\n"
" layers:\n"
" - layer: '" << layer << "'\n";
}
EXPECT_EQ(expected, Validate(filename)) << "layer: " << layer;
EXPECT_EQ(expected, GetErrors().empty()) << "layer: " << layer;
}
RteFsUtils::RemoveFile(filename);
}

TEST_F(ProjMgrSchemaCheckerUnitTests, SchemaCheck_Fail) {
vector<std::pair<int, int>> expectedErrPos = {
// line, col
Expand Down
Loading