Skip to content

Commit c0d1a76

Browse files
grasci-armsoumeh01
andauthored
Hover info on Setup node and correct error type
Co-authored-by: Sourabh Mehta <73165318+soumeh01@users.noreply.github.com>
1 parent bdeed3f commit c0d1a76

File tree

2 files changed

+133
-4
lines changed

2 files changed

+133
-4
lines changed

tools/projmgr/schemas/common.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@
17451745
"SetupType": {
17461746
"type": "object",
17471747
"properties": {
1748-
"setup": {
1748+
"setup": {
17491749
"title": "setup:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#setups",
17501750
"type": "string",
17511751
"description": "Description of the setup."
@@ -1773,7 +1773,7 @@
17731773
"undefine": { "$ref": "#/definitions/UndefinesType" },
17741774
"warnings": { "$ref": "#/definitions/WarningsType" }
17751775
},
1776-
"oneOf": [
1776+
"allOf": [
17771777
{ "$ref": "#/definitions/TypeListMutualExclusion" }
17781778
],
17791779
"additionalProperties": false
@@ -1851,7 +1851,7 @@
18511851
"not-for-context": { "$ref": "#/definitions/NotForContext" },
18521852
"for-compiler": { "$ref": "#/definitions/CompilersType" }
18531853
},
1854-
"oneOf": [
1854+
"allOf": [
18551855
{ "$ref": "#/definitions/TypeListMutualExclusion" }
18561856
],
18571857
"additionalProperties": false

tools/projmgr/test/src/ProjMgrSchemaCheckerUnitTests.cpp

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2021 Arm Limited. All rights reserved.
2+
* Copyright (c) 2020-2026 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -408,6 +408,135 @@ vector<ErrInfo> expectedErrPos = {
408408
}
409409
}
410410

411+
TEST_F(ProjMgrSchemaCheckerUnitTests, SchemaCheck_Setup_Linker) {
412+
typedef std::pair<int, int> ErrInfo;
413+
414+
// only for-context
415+
const char* valid_setup_schema_Ex1 = "\
416+
project:\n\
417+
setups:\n\
418+
- setup: debug Setup\n\
419+
for-context: +Debug\n\
420+
define:\n\
421+
- TEST: 1\n\
422+
";
423+
424+
//only not-for-context
425+
const char* valid_setup_schema_Ex2 = "\
426+
project:\n\
427+
setups:\n\
428+
- setup: Release Setup\n\
429+
not-for-context: +Release\n\
430+
optimize: speed\n\
431+
";
432+
433+
// neither for-context not not-for-context present
434+
const char* valid_setup_schema_Ex3 = "\
435+
project:\n\
436+
setups:\n\
437+
- setup: test\n\
438+
misc:\n\
439+
- Link:\n\
440+
- --verbose\n\
441+
";
442+
443+
// both for-context and not-for-context
444+
const char* invalid_setup_schema_Ex1 = "\
445+
project:\n\
446+
setups:\n\
447+
- setup: test\n\
448+
for-context: +Debug\n\
449+
not-for-context: +Release\n\
450+
";
451+
452+
// No setup string
453+
const char* invalid_setup_schema_Ex2 = "\
454+
project:\n\
455+
setups:\n\
456+
- setup:\n\
457+
for-context: +Debug\n\
458+
";
459+
460+
const char* valid_linker_schema_Ex1 = "\
461+
project:\n\
462+
linker:\n\
463+
- script: MyLinker.scf.src\n\
464+
for-context: +Debug\n\
465+
";
466+
467+
const char* valid_linker_schema_Ex2 = "\
468+
project:\n\
469+
linker:\n\
470+
- script: MyLinker.scf.src\n\
471+
not-for-context: +Debug\n\
472+
";
473+
474+
const char* valid_linker_schema_Ex3 = "\
475+
project:\n\
476+
linker:\n\
477+
- script: MyLinker.scf.src\n\
478+
for-compiler: AC6\n\
479+
- script: MyLinker.ld\n\
480+
for-compiler: CLANG\n\
481+
";
482+
483+
const char* invalid_linker_schema_Ex1 = "\
484+
project:\n\
485+
linker:\n\
486+
- script: MyLinker.scf.src\n\
487+
for-context: +Debug\n\
488+
not-for-context: +Release\n\
489+
";
490+
491+
const char* invalid_linker_schema_Ex2 = "\
492+
project:\n\
493+
linker:\n\
494+
- script: MyLinker.scf.src\n\
495+
for-context: +Debug\n\
496+
invalid: 1\n\
497+
";
498+
499+
vector<std::tuple<const char*, bool, vector<ErrInfo>>> vecTestData = {
500+
// data, expectedRetVal, errorPos
501+
{ valid_setup_schema_Ex1, true, vector<ErrInfo>{ } },
502+
{ valid_setup_schema_Ex2, true, vector<ErrInfo>{ } },
503+
{ valid_setup_schema_Ex3, true, vector<ErrInfo>{ } },
504+
{ invalid_setup_schema_Ex1, false, vector<ErrInfo>{ {3,7} } },
505+
{ invalid_setup_schema_Ex2, false, vector<ErrInfo>{ {3,7} } },
506+
{ valid_linker_schema_Ex1, true, vector<ErrInfo>{ } },
507+
{ valid_linker_schema_Ex2, true, vector<ErrInfo>{ } },
508+
{ valid_linker_schema_Ex3, true, vector<ErrInfo>{ } },
509+
{ invalid_linker_schema_Ex1, false, vector<ErrInfo>{ {3,7} } },
510+
{ invalid_linker_schema_Ex2, false, vector<ErrInfo>{ {5,7} } }
511+
};
512+
513+
auto writeFile = [](const string& filePath, const char* data) {
514+
ofstream fileStream(filePath);
515+
fileStream << data;
516+
fileStream << endl;
517+
fileStream << flush;
518+
fileStream.close();
519+
};
520+
521+
const string& filename = testoutput_folder +
522+
"/test_schema_validation.cproject.yml";
523+
for (auto [data, expectRetVal, errorPos] : vecTestData) {
524+
writeFile(filename, data);
525+
EXPECT_EQ(expectRetVal, Validate(filename)) << "failed for: " << data;
526+
527+
// Check errors
528+
auto errList = GetErrors();
529+
EXPECT_EQ(errList.size(), expectRetVal ? 0 : errorPos.size()) << "failed for: " << data;
530+
for (auto& err : errList) {
531+
auto errItr = find_if(errorPos.begin(), errorPos.end(),
532+
[&](const std::pair<int, int>& errPos) {
533+
return err.m_line == errPos.first && err.m_col == errPos.second;
534+
});
535+
EXPECT_TRUE(errorPos.end() != errItr) << "failed for: " << data;
536+
}
537+
}
538+
}
539+
411540
TEST_F(ProjMgrSchemaCheckerUnitTests, SchemaCheck_define) {
412541
vector<std::pair<int, int>> expectedErrPos = {
413542
// line, col

0 commit comments

Comments
 (0)