diff --git a/JsonPreprocessor/CJsonPreprocessor.py b/JsonPreprocessor/CJsonPreprocessor.py index 8322a923..9b98d13c 100644 --- a/JsonPreprocessor/CJsonPreprocessor.py +++ b/JsonPreprocessor/CJsonPreprocessor.py @@ -273,7 +273,9 @@ def __processImportFiles(self, input_data : dict) -> dict: for key, value in input_data: if re.match('^\s*\[\s*import\s*\]\s*', key.lower()): if not isinstance(value, str): - errorMsg = f"The value of [import] parameter must be 'str' but receiving the value '{value}'" + typeValue = re.search(r"^$", str(type(value))) + typeValue = typeValue[1] if typeValue is not None else type(value) + errorMsg = f"The [import] key requires a value of type 'str', but the type is {typeValue}" self.__reset() raise Exception(errorMsg) if '${' in value: @@ -299,8 +301,6 @@ def __processImportFiles(self, input_data : dict) -> dict: out_dict[key] = value if '${' not in value: if re.match(r'^\[\s*import\s*\]_\d+$', key): - if value in self.lDynamicImports: - raise Exception(f"Cyclic imported json file '{value}'!") dynamicIpmportIndex = re.search(r'_(\d+)$', key)[1] self.lDynamicImports[int(dynamicIpmportIndex)-1] = value currJsonPath = self.jsonPath @@ -316,6 +316,11 @@ def __processImportFiles(self, input_data : dict) -> dict: raise Exception(f"Cyclic imported json file '{abs_path_file}'!") oJsonImport = self.jsonLoad(abs_path_file) + bDynamicImportCheck = False + for k, v in oJsonImport.items(): + if re.match('^\s*\[\s*import\s*\]\s*', k) and '${' in v: + bDynamicImportCheck = True + break self.jsonPath = currJsonPath tmpOutdict = copy.deepcopy(out_dict) for k1, v1 in tmpOutdict.items(): @@ -324,8 +329,8 @@ def __processImportFiles(self, input_data : dict) -> dict: del out_dict[k1] del tmpOutdict out_dict.update(oJsonImport) - - self.recursive_level = self.recursive_level - 1 # descrease recursive level + if not bDynamicImportCheck: + self.recursive_level = self.recursive_level - 1 # descrease recursive level else: if not self.bJSONPreCheck: specialCharacters = r'$[]{}' @@ -1201,16 +1206,22 @@ def __handleList(lInput : list, bNested : bool) -> list: if re.search(r'\${.+\..+}', v): paramInValue = self.__handleDotInNestedParam(v) paramInValue = self.__multipleReplace(paramInValue, {'${':'', '}':''}) + # Check datatype of [import] value + if re.match(r'^\[\s*import\s*\]_\d+$', k): + dynamicImported = re.search(rf'^(.*){CNameMangling.DYNAMICIMPORTED.value}(.*)$', v) + importValue = dynamicImported[2] + importValue = __loadNestedValue(importValue, importValue) + if not isinstance(importValue, str): + typeValue = re.search(r"^$", str(type(importValue))) + typeValue = typeValue[1] if typeValue is not None else type(importValue) + errorMsg = f"The [import] key requires a value of type 'str', but the type is {typeValue}" + self.__reset() + raise Exception(errorMsg) v = __loadNestedValue(initValue, v, key=k) # Handle dynamic import value if re.match(r'^\[\s*import\s*\]_\d+$', k): if '${' not in v and CNameMangling.DYNAMICIMPORTED.value in v: dynamicImported = re.search(rf'^(.*){CNameMangling.DYNAMICIMPORTED.value}(.*)$', v) - if re.match(r'^[\d\.]+$', dynamicImported[2]) or \ - re.search(r'(\[[^\[]+\])|(\([^\(]+\))|({[^{]+})', dynamicImported[2]): - errorMsg = f"The value of [import] parameter must be 'str' but receiving the value '{dynamicImported[2]}'" - self.__reset() - raise Exception(errorMsg) if re.match(r'^[/|\\].+$', dynamicImported[2]): v = dynamicImported[2] else: @@ -1858,6 +1869,8 @@ def __handleLastElement(sInput : str) -> str: self.bJSONPreCheck = True sDummyData = self.__preCheckJsonFile(sJsonDataUpdated, CJSONDecoder) self.iDynamicImport = 0 + self.recursive_level = 0 + self.lImportedFiles = [] if self.masterFile is None else [self.masterFile] self.bJSONPreCheck = False # Load Json object with checking duplicated keys feature is enabled. diff --git a/JsonPreprocessor/JsonPreprocessor.pdf b/JsonPreprocessor/JsonPreprocessor.pdf index b6c2e7a2..8ca3617e 100644 Binary files a/JsonPreprocessor/JsonPreprocessor.pdf and b/JsonPreprocessor/JsonPreprocessor.pdf differ diff --git a/JsonPreprocessor/version.py b/JsonPreprocessor/version.py index 0f8f463f..997cae0e 100644 --- a/JsonPreprocessor/version.py +++ b/JsonPreprocessor/version.py @@ -18,6 +18,6 @@ # # Version and date of JsonPreprocessor # -VERSION = "0.8.2" -VERSION_DATE = "30.10.2024" +VERSION = "0.8.3" +VERSION_DATE = "25.11.2024" diff --git a/packagedoc/additional_docs/History.tex b/packagedoc/additional_docs/History.tex index 1effe64b..a40203c7 100644 --- a/packagedoc/additional_docs/History.tex +++ b/packagedoc/additional_docs/History.tex @@ -89,4 +89,7 @@ \historyversiondate{0.8.2}{10/2024} \historychange{- Enhanced import JSON file feature which allows dynamic path of imported file} +\historyversiondate{0.8.3}{11/2024} +\historychange{- Fixed bugs and updated error messages related to dynamic imports} + \end{packagehistory} diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index 278e4680..e30040b1 100644 --- a/test/JPP_TestUsecases.csv +++ b/test/JPP_TestUsecases.csv @@ -128,13 +128,25 @@ JPP_1108|FILE_IMPORTS|GOODCASE|JSON file import based on parameters (dynamic imp JPP_1109|FILE_IMPORTS|GOODCASE|JSON file import based on dictionary key values JPP_1110|FILE_IMPORTS|GOODCASE|JSON file import based on list elemens JPP_1111|FILE_IMPORTS|GOODCASE|JSON file import based on parameters (dynamic import (7)) +JPP_1112|FILE_IMPORTS|GOODCASE|JSON file containing an import of the same file in different levels (within the same file) +JPP_1113|FILE_IMPORTS|GOODCASE|JSON file containing an import of the same file in different levels (within imported files) JPP_1150|FILE_IMPORTS|BADCASE|JSON file with cyclic imports (JSON file imports itself, fix path) JPP_1151|FILE_IMPORTS|BADCASE|JSON file with cyclic imports (JSON file imports another file, that is already imported, fix path) +JPP_1152|FILE_IMPORTS|BADCASE|JSON file with cyclic imports (JSON file imports itself, dynamic path) +JPP_1153|FILE_IMPORTS|BADCASE|JSON file with cyclic imports (JSON file imports another file, that is already imported, dynamic path) JPP_1154|FILE_IMPORTS|BADCASE|JSON file with not existing parameter within dynamic import path JPP_1155|FILE_IMPORTS|BADCASE|JSON file with not existing import file +JPP_1156|FILE_IMPORTS|BADCASE|JSON file with syntax error in import path (1) +JPP_1157|FILE_IMPORTS|BADCASE|JSON file with syntax error in import path (2) JPP_1158|FILE_IMPORTS|BADCASE|JSON file with error in [import] key (1) JPP_1159|FILE_IMPORTS|BADCASE|JSON file with error in [import] key (2) JPP_1160|FILE_IMPORTS|BADCASE|JSON file with error in imported file +JPP_1161|FILE_IMPORTS|BADCASE|JSON file with invalid data type of [import] key (1) +JPP_1162|FILE_IMPORTS|BADCASE|JSON file with invalid data type of [import] key (2) +JPP_1163|FILE_IMPORTS|BADCASE|JSON file with invalid data type of [import] key (3) +JPP_1164|FILE_IMPORTS|BADCASE|JSON file with invalid data type of [import] key (4) +JPP_1165|FILE_IMPORTS|BADCASE|JSON file with cyclic imports (sawtooth, stopped) +JPP_1166|FILE_IMPORTS|BADCASE|JSON file with cyclic imports (sawtooth, endless) JPP_1200|PATH_FORMATS|GOODCASE|Relative path to JSON file JPP_1350|BLOCKED_SLICING|BADCASE|JSON file with blocked slicing notation (-1) JPP_1351|BLOCKED_SLICING|BADCASE|JSON file with blocked slicing notation (-1) diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index 133a4e2b..702f9e26 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -4292,6 +4292,72 @@ 129 + + + +JPP_1112 + + + + +FILE_IMPORTS + + + + +GOODCASE + + + + +JSON file containing an import of the same file in different levels (within the same file)
+Expected: JsonPreprocessor returns values + + +
+ + + + + + + +130 + + + + + +JPP_1113 + + + + +FILE_IMPORTS + + + + +GOODCASE + + + + +JSON file containing an import of the same file in different levels (within imported files)
+Expected: JsonPreprocessor returns values + + +
+ + + + + + + +131 + + @@ -4323,7 +4389,7 @@ -130 +132 @@ -4357,7 +4423,75 @@ -131 +133 + + + + + +JPP_1152 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with cyclic imports (JSON file imports itself, dynamic path)
+Expected: No values are returned, and JsonPreprocessor throws an exception +
+Cyclic import + +
+ + + + + + + +134 + + + + + +JPP_1153 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with cyclic imports (JSON file imports another file, that is already imported, dynamic path)
+Expected: No values are returned, and JsonPreprocessor throws an exception +
+Cyclic import + +
+ + + + + + + +135 @@ -4390,7 +4524,7 @@ -132 +136 @@ -4423,7 +4557,73 @@ -133 +137 + + + + + +JPP_1156 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with syntax error in import path (1)
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +138 + + + + + +JPP_1157 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with syntax error in import path (2)
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +139 @@ -4456,7 +4656,7 @@ -134 +140 @@ -4489,7 +4689,7 @@ -135 +141 @@ -4522,7 +4722,211 @@ -136 +142 + + + + + +JPP_1161 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with invalid data type of [import] key (1)
+Expected: No values are returned, and JsonPreprocessor throws an exception + +
+'int' instead of 'str' +
+ + + + + + + +143 + + + + + +JPP_1162 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with invalid data type of [import] key (2)
+Expected: No values are returned, and JsonPreprocessor throws an exception + +
+'list' instead of 'str' +
+ + + + + + + +144 + + + + + +JPP_1163 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with invalid data type of [import] key (3)
+Expected: No values are returned, and JsonPreprocessor throws an exception + +
+'dict' instead of 'str' +
+ + + + + + + +145 + + + + + +JPP_1164 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with invalid data type of [import] key (4)
+Expected: No values are returned, and JsonPreprocessor throws an exception + +
+'int' instead of 'str' (from 'dict') +
+ + + + + + + +146 + + + + + +JPP_1165 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with cyclic imports (sawtooth, stopped)
+Expected: No values are returned, and JsonPreprocessor throws an exception +
+Cyclic import + +
+ + + + + + + +147 + + + + + +JPP_1166 + + + + +FILE_IMPORTS + + + + +BADCASE + + + + +JSON file with cyclic imports (sawtooth, endless)
+Expected: No values are returned, and JsonPreprocessor throws an exception +
+Cyclic import + +
+ + + + + + + +148 @@ -4556,7 +4960,7 @@ -137 +149 @@ -4589,7 +4993,7 @@ -138 +150 @@ -4622,7 +5026,7 @@ -139 +151 @@ -4655,7 +5059,7 @@ -140 +152 @@ -4688,7 +5092,7 @@ -141 +153 @@ -4721,7 +5125,7 @@ -142 +154 @@ -4754,7 +5158,7 @@ -143 +155 @@ -4787,7 +5191,7 @@ -144 +156 @@ -4820,7 +5224,7 @@ -145 +157 @@ -4853,7 +5257,7 @@ -146 +158 @@ -4886,7 +5290,7 @@ -147 +159 @@ -4919,7 +5323,7 @@ -148 +160 @@ -4952,7 +5356,7 @@ -149 +161 @@ -4985,7 +5389,7 @@ -150 +162 @@ -5018,7 +5422,7 @@ -151 +163 @@ -5051,7 +5455,7 @@ -152 +164 @@ -5084,7 +5488,7 @@ -153 +165 @@ -5117,7 +5521,7 @@ -154 +166 @@ -5150,7 +5554,7 @@ -155 +167 @@ -5183,7 +5587,7 @@ -156 +168 @@ -5216,7 +5620,7 @@ -157 +169 @@ -5249,7 +5653,7 @@ -158 +170 @@ -5282,7 +5686,7 @@ -159 +171 @@ -5315,7 +5719,7 @@ -160 +172 @@ -5348,7 +5752,7 @@ -161 +173 @@ -5381,7 +5785,7 @@ -162 +174 @@ -5414,7 +5818,7 @@ -163 +175 @@ -5447,7 +5851,7 @@ -164 +176 @@ -5480,7 +5884,7 @@ -165 +177 @@ -5513,7 +5917,7 @@ -166 +178 @@ -5546,7 +5950,7 @@ -167 +179 @@ -5579,7 +5983,7 @@ -168 +180 @@ -5612,7 +6016,7 @@ -169 +181 @@ -5645,7 +6049,7 @@ -170 +182 @@ -5678,7 +6082,7 @@ -171 +183 @@ -5711,7 +6115,7 @@ -172 +184 @@ -5744,7 +6148,7 @@ -173 +185 @@ -5777,7 +6181,7 @@ -174 +186 @@ -5810,7 +6214,7 @@ -175 +187 @@ -5843,7 +6247,7 @@ -176 +188 @@ -5876,7 +6280,7 @@ -177 +189 @@ -5909,7 +6313,7 @@ -178 +190 @@ -5942,7 +6346,7 @@ -179 +191 @@ -5975,7 +6379,7 @@ -180 +192 @@ -6008,7 +6412,7 @@ -181 +193 @@ -6041,7 +6445,7 @@ -182 +194 @@ -6074,7 +6478,7 @@ -183 +195 @@ -6107,7 +6511,7 @@ -184 +196 @@ -6140,7 +6544,7 @@ -185 +197 @@ -6173,7 +6577,7 @@ -186 +198 @@ -6206,7 +6610,7 @@ -187 +199 @@ -6239,7 +6643,7 @@
 

-
Generated: 14.11.2024 - 15:38:04
+
Generated: 26.11.2024 - 12:36:07
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index 310f6569..2de6fc89 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -1363,6 +1363,26 @@ Test Use Cases ---- +* **Test JPP_1112** + + [FILE_IMPORTS / GOODCASE] + + **JSON file containing an import of the same file in different levels (within the same file)** + + Expected: JsonPreprocessor returns values + +---- + +* **Test JPP_1113** + + [FILE_IMPORTS / GOODCASE] + + **JSON file containing an import of the same file in different levels (within imported files)** + + Expected: JsonPreprocessor returns values + +---- + * **Test JPP_1150** [FILE_IMPORTS / BADCASE] @@ -1387,6 +1407,30 @@ Test Use Cases ---- +* **Test JPP_1152** + + [FILE_IMPORTS / BADCASE] + + **JSON file with cyclic imports (JSON file imports itself, dynamic path)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + + *Comment: Cyclic import* + +---- + +* **Test JPP_1153** + + [FILE_IMPORTS / BADCASE] + + **JSON file with cyclic imports (JSON file imports another file, that is already imported, dynamic path)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + + *Comment: Cyclic import* + +---- + * **Test JPP_1154** [FILE_IMPORTS / BADCASE] @@ -1407,6 +1451,26 @@ Test Use Cases ---- +* **Test JPP_1156** + + [FILE_IMPORTS / BADCASE] + + **JSON file with syntax error in import path (1)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_1157** + + [FILE_IMPORTS / BADCASE] + + **JSON file with syntax error in import path (2)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + * **Test JPP_1158** [FILE_IMPORTS / BADCASE] @@ -1437,6 +1501,78 @@ Test Use Cases ---- +* **Test JPP_1161** + + [FILE_IMPORTS / BADCASE] + + **JSON file with invalid data type of [import] key (1)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + + *Hint: 'int' instead of 'str'* + +---- + +* **Test JPP_1162** + + [FILE_IMPORTS / BADCASE] + + **JSON file with invalid data type of [import] key (2)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + + *Hint: 'list' instead of 'str'* + +---- + +* **Test JPP_1163** + + [FILE_IMPORTS / BADCASE] + + **JSON file with invalid data type of [import] key (3)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + + *Hint: 'dict' instead of 'str'* + +---- + +* **Test JPP_1164** + + [FILE_IMPORTS / BADCASE] + + **JSON file with invalid data type of [import] key (4)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + + *Hint: 'int' instead of 'str' (from 'dict')* + +---- + +* **Test JPP_1165** + + [FILE_IMPORTS / BADCASE] + + **JSON file with cyclic imports (sawtooth, stopped)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + + *Comment: Cyclic import* + +---- + +* **Test JPP_1166** + + [FILE_IMPORTS / BADCASE] + + **JSON file with cyclic imports (sawtooth, endless)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + + *Comment: Cyclic import* + +---- + * **Test JPP_1200** [PATH_FORMATS / GOODCASE] @@ -1959,5 +2095,5 @@ Test Use Cases ---- -Generated: 14.11.2024 - 15:38:04 +Generated: 26.11.2024 - 12:36:07 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index 860b0c68..e168fcf5 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -561,6 +561,14 @@ Test JPP_1111 / FILE_IMPORTS / GOODCASE Description: JSON file import based on parameters (dynamic import (7)) Expectation: JsonPreprocessor returns values ------------------------------------------------------------------------------------------------------------------------ +Test JPP_1112 / FILE_IMPORTS / GOODCASE +Description: JSON file containing an import of the same file in different levels (within the same file) +Expectation: JsonPreprocessor returns values +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1113 / FILE_IMPORTS / GOODCASE +Description: JSON file containing an import of the same file in different levels (within imported files) +Expectation: JsonPreprocessor returns values +------------------------------------------------------------------------------------------------------------------------ Test JPP_1150 / FILE_IMPORTS / BADCASE Description: JSON file with cyclic imports (JSON file imports itself, fix path) Expectation: No values are returned, and JsonPreprocessor throws an exception @@ -571,6 +579,16 @@ Description: JSON file with cyclic imports (JSON file imports another file, that Expectation: No values are returned, and JsonPreprocessor throws an exception Comment....: Cyclic import ------------------------------------------------------------------------------------------------------------------------ +Test JPP_1152 / FILE_IMPORTS / BADCASE +Description: JSON file with cyclic imports (JSON file imports itself, dynamic path) +Expectation: No values are returned, and JsonPreprocessor throws an exception +Comment....: Cyclic import +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1153 / FILE_IMPORTS / BADCASE +Description: JSON file with cyclic imports (JSON file imports another file, that is already imported, dynamic path) +Expectation: No values are returned, and JsonPreprocessor throws an exception +Comment....: Cyclic import +------------------------------------------------------------------------------------------------------------------------ Test JPP_1154 / FILE_IMPORTS / BADCASE Description: JSON file with not existing parameter within dynamic import path Expectation: No values are returned, and JsonPreprocessor throws an exception @@ -579,6 +597,14 @@ Test JPP_1155 / FILE_IMPORTS / BADCASE Description: JSON file with not existing import file Expectation: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ +Test JPP_1156 / FILE_IMPORTS / BADCASE +Description: JSON file with syntax error in import path (1) +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1157 / FILE_IMPORTS / BADCASE +Description: JSON file with syntax error in import path (2) +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ Test JPP_1158 / FILE_IMPORTS / BADCASE Description: JSON file with error in [import] key (1) Expectation: No values are returned, and JsonPreprocessor throws an exception @@ -591,6 +617,36 @@ Test JPP_1160 / FILE_IMPORTS / BADCASE Description: JSON file with error in imported file Expectation: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ +Test JPP_1161 / FILE_IMPORTS / BADCASE +Description: JSON file with invalid data type of [import] key (1) +Expectation: No values are returned, and JsonPreprocessor throws an exception +Hint.......: 'int' instead of 'str' +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1162 / FILE_IMPORTS / BADCASE +Description: JSON file with invalid data type of [import] key (2) +Expectation: No values are returned, and JsonPreprocessor throws an exception +Hint.......: 'list' instead of 'str' +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1163 / FILE_IMPORTS / BADCASE +Description: JSON file with invalid data type of [import] key (3) +Expectation: No values are returned, and JsonPreprocessor throws an exception +Hint.......: 'dict' instead of 'str' +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1164 / FILE_IMPORTS / BADCASE +Description: JSON file with invalid data type of [import] key (4) +Expectation: No values are returned, and JsonPreprocessor throws an exception +Hint.......: 'int' instead of 'str' (from 'dict') +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1165 / FILE_IMPORTS / BADCASE +Description: JSON file with cyclic imports (sawtooth, stopped) +Expectation: No values are returned, and JsonPreprocessor throws an exception +Comment....: Cyclic import +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1166 / FILE_IMPORTS / BADCASE +Description: JSON file with cyclic imports (sawtooth, endless) +Expectation: No values are returned, and JsonPreprocessor throws an exception +Comment....: Cyclic import +------------------------------------------------------------------------------------------------------------------------ Test JPP_1200 / PATH_FORMATS / GOODCASE Description: Relative path to JSON file Expectation: JsonPreprocessor resolves the relative path and returns values from JSON file @@ -800,5 +856,5 @@ Test JPP_2058 / PARAMETER_SCOPE / BADCASE Description: JSON file containing a parameter with missing scope (9) Expectation: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ -Generated: 14.11.2024 - 15:38:04 +Generated: 26.11.2024 - 12:36:07 diff --git a/test/component_test.py b/test/component_test.py index 29dbbc3b..83b74563 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -22,8 +22,8 @@ # # -------------------------------------------------------------------------------------------------------------- # -VERSION = "0.52.0" -VERSION_DATE = "14.11.2024" +VERSION = "0.55.0" +VERSION_DATE = "26.11.2024" # # -------------------------------------------------------------------------------------------------------------- #TM*** diff --git a/test/pytest/pytestfiles/test_15_FILE_IMPORTS_GOODCASE.py b/test/pytest/pytestfiles/test_15_FILE_IMPORTS_GOODCASE.py index c3680cec..b027495b 100644 --- a/test/pytest/pytestfiles/test_15_FILE_IMPORTS_GOODCASE.py +++ b/test/pytest/pytestfiles/test_15_FILE_IMPORTS_GOODCASE.py @@ -18,7 +18,7 @@ # # XC-HWP/ESW3-Queckenstedt # -# 14.11.2024 - 15:38:04 +# 26.11.2024 - 12:36:07 # # -------------------------------------------------------------------------------------------------------------- @@ -125,4 +125,20 @@ def test_JPP_1110(self, Description): def test_JPP_1111(self, Description): nReturn = CExecute.Execute("JPP_1111") assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns values + @pytest.mark.parametrize( + "Description", ["JSON file containing an import of the same file in different levels (within the same file)",] + ) + def test_JPP_1112(self, Description): + nReturn = CExecute.Execute("JPP_1112") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns values + @pytest.mark.parametrize( + "Description", ["JSON file containing an import of the same file in different levels (within imported files)",] + ) + def test_JPP_1113(self, Description): + nReturn = CExecute.Execute("JPP_1113") + assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- diff --git a/test/pytest/pytestfiles/test_16_FILE_IMPORTS_BADCASE.py b/test/pytest/pytestfiles/test_16_FILE_IMPORTS_BADCASE.py index 929e4fe1..e2b392ab 100644 --- a/test/pytest/pytestfiles/test_16_FILE_IMPORTS_BADCASE.py +++ b/test/pytest/pytestfiles/test_16_FILE_IMPORTS_BADCASE.py @@ -18,7 +18,7 @@ # # XC-HWP/ESW3-Queckenstedt # -# 14.11.2024 - 15:38:04 +# 26.11.2024 - 12:36:07 # # -------------------------------------------------------------------------------------------------------------- @@ -45,6 +45,22 @@ def test_JPP_1150(self, Description): def test_JPP_1151(self, Description): nReturn = CExecute.Execute("JPP_1151") assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with cyclic imports (JSON file imports itself, dynamic path)",] + ) + def test_JPP_1152(self, Description): + nReturn = CExecute.Execute("JPP_1152") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with cyclic imports (JSON file imports another file, that is already imported, dynamic path)",] + ) + def test_JPP_1153(self, Description): + nReturn = CExecute.Execute("JPP_1153") + assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- # Expected: No values are returned, and JsonPreprocessor throws an exception @pytest.mark.parametrize( @@ -61,6 +77,22 @@ def test_JPP_1154(self, Description): def test_JPP_1155(self, Description): nReturn = CExecute.Execute("JPP_1155") assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with syntax error in import path (1)",] + ) + def test_JPP_1156(self, Description): + nReturn = CExecute.Execute("JPP_1156") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with syntax error in import path (2)",] + ) + def test_JPP_1157(self, Description): + nReturn = CExecute.Execute("JPP_1157") + assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- # Expected: No values are returned, and JsonPreprocessor throws an exception @pytest.mark.parametrize( @@ -85,4 +117,52 @@ def test_JPP_1159(self, Description): def test_JPP_1160(self, Description): nReturn = CExecute.Execute("JPP_1160") assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with invalid data type of [import] key (1)",] + ) + def test_JPP_1161(self, Description): + nReturn = CExecute.Execute("JPP_1161") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with invalid data type of [import] key (2)",] + ) + def test_JPP_1162(self, Description): + nReturn = CExecute.Execute("JPP_1162") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with invalid data type of [import] key (3)",] + ) + def test_JPP_1163(self, Description): + nReturn = CExecute.Execute("JPP_1163") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with invalid data type of [import] key (4)",] + ) + def test_JPP_1164(self, Description): + nReturn = CExecute.Execute("JPP_1164") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with cyclic imports (sawtooth, stopped)",] + ) + def test_JPP_1165(self, Description): + nReturn = CExecute.Execute("JPP_1165") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with cyclic imports (sawtooth, endless)",] + ) + def test_JPP_1166(self, Description): + nReturn = CExecute.Execute("JPP_1166") + assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- diff --git a/test/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index e93bec79..e5480bda 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -# 14.11.2024 +# 26.11.2024 # # !!! Temporarily tests are deactivated by the following line commented out: # # # listofdictUsecases.append(dictUsecase) @@ -3049,6 +3049,61 @@ listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_1112" +dictUsecase['DESCRIPTION'] = "JSON file containing an import of the same file in different levels (within the same file)" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns values" +dictUsecase['SECTION'] = "FILE_IMPORTS" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1112.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DOTDICT] (4/1) > {AA} [STR] : 'AA' +[DOTDICT] (4/2) > {root} [STR] : '../' +[DOTDICT] (4/3) > {values_AA_1} [DOTDICT] (3/1) > {AA_1_a} [INT] : 1 +[DOTDICT] (4/3) > {values_AA_1} [DOTDICT] (3/2) > {common_sublevel_param} [STR] : 'common_sublevel_param value' +[DOTDICT] (4/3) > {values_AA_1} [DOTDICT] (3/3) > {AA_1_b} [INT] : 2 +[DOTDICT] (4/4) > {values_AA_2} [DOTDICT] (3/1) > {AA_2_a} [INT] : 1 +[DOTDICT] (4/4) > {values_AA_2} [DOTDICT] (3/2) > {common_sublevel_param} [STR] : 'common_sublevel_param value' +[DOTDICT] (4/4) > {values_AA_2} [DOTDICT] (3/3) > {AA_2_b} [INT] : 2 +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_1113" +dictUsecase['DESCRIPTION'] = "JSON file containing an import of the same file in different levels (within imported files)" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns values" +dictUsecase['SECTION'] = "FILE_IMPORTS" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1113.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DOTDICT] (9/1) > {AA} [STR] : 'AA' +[DOTDICT] (9/2) > {values_AA} [DOTDICT] (3/1) > {AA_1} [INT] : 1 +[DOTDICT] (9/2) > {values_AA} [DOTDICT] (3/2) > {common_sublevel_param} [STR] : 'common_sublevel_param value' +[DOTDICT] (9/2) > {values_AA} [DOTDICT] (3/3) > {AA_2} [INT] : 2 +[DOTDICT] (9/3) > {BB} [STR] : 'BB' +[DOTDICT] (9/4) > {values_BB} [DOTDICT] (3/1) > {BB_1} [INT] : 1 +[DOTDICT] (9/4) > {values_BB} [DOTDICT] (3/2) > {common_sublevel_param} [STR] : 'common_sublevel_param value' +[DOTDICT] (9/4) > {values_BB} [DOTDICT] (3/3) > {BB_2} [INT] : 2 +[DOTDICT] (9/5) > {CC} [STR] : 'CC' +[DOTDICT] (9/6) > {values_CC} [DOTDICT] (3/1) > {CC_1} [INT] : 1 +[DOTDICT] (9/6) > {values_CC} [DOTDICT] (3/2) > {common_sublevel_param} [STR] : 'common_sublevel_param value' +[DOTDICT] (9/6) > {values_CC} [DOTDICT] (3/3) > {CC_2} [INT] : 2 +[DOTDICT] (9/7) > {DD} [STR] : 'DD' +[DOTDICT] (9/8) > {root} [STR] : '../../../../' +[DOTDICT] (9/9) > {values_DD} [DOTDICT] (3/1) > {DD_1} [INT] : 1 +[DOTDICT] (9/9) > {values_DD} [DOTDICT] (3/2) > {common_sublevel_param} [STR] : 'common_sublevel_param value' +[DOTDICT] (9/9) > {values_DD} [DOTDICT] (3/3) > {DD_2} [INT] : 2 +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} dictUsecase['TESTID'] = "JPP_1150" @@ -3087,9 +3142,9 @@ dictUsecase['HINT'] = None dictUsecase['COMMENT'] = "Cyclic import" dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1152.jsonp" -dictUsecase['EXPECTEDEXCEPTION'] = "Cyclic imported json file" # maximum recursion depth exceeded while calling a Python object +dictUsecase['EXPECTEDEXCEPTION'] = "Cyclic imported json file" dictUsecase['EXPECTEDRETURN'] = None -# # # listofdictUsecases.append(dictUsecase) +listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} @@ -3101,9 +3156,9 @@ dictUsecase['HINT'] = None dictUsecase['COMMENT'] = "Cyclic import" dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1153.jsonp" -dictUsecase['EXPECTEDEXCEPTION'] = "Cyclic imported json file" # 'maximum recursion depth exceeded in __instancecheck__ +dictUsecase['EXPECTEDEXCEPTION'] = "Cyclic imported json file" dictUsecase['EXPECTEDRETURN'] = None -# # # listofdictUsecases.append(dictUsecase) +listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} @@ -3135,7 +3190,6 @@ del dictUsecase # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} -# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/377 dictUsecase['TESTID'] = "JPP_1156" dictUsecase['DESCRIPTION'] = "JSON file with syntax error in import path (1)" dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" @@ -3144,13 +3198,12 @@ dictUsecase['HINT'] = None dictUsecase['COMMENT'] = None dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1156.jsonp" -dictUsecase['EXPECTEDEXCEPTION'] = None # currently: Could not load the import file './dynamic_imports/${AA/imported.AA.jsonp'. The parameter '' is not available! +dictUsecase['EXPECTEDEXCEPTION'] = "Invalid expression found: './dynamic_imports/${AA/imported.AA.jsonp' - The brackets mismatch" dictUsecase['EXPECTEDRETURN'] = None -# # # listofdictUsecases.append(dictUsecase) +listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} -# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/381 dictUsecase['TESTID'] = "JPP_1157" dictUsecase['DESCRIPTION'] = "JSON file with syntax error in import path (2)" dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" @@ -3159,9 +3212,9 @@ dictUsecase['HINT'] = None dictUsecase['COMMENT'] = None dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1157.jsonp" -dictUsecase['EXPECTEDEXCEPTION'] = None # currently: FREEZE; expected: bracket mismatch +dictUsecase['EXPECTEDEXCEPTION'] = "Invalid expression found: './dynamic_imports/${${AA/imported.AA.jsonp' - The brackets mismatch" dictUsecase['EXPECTEDRETURN'] = None -# # # listofdictUsecases.append(dictUsecase) +listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} @@ -3217,9 +3270,9 @@ dictUsecase['HINT'] = "'int' instead of 'str'" dictUsecase['COMMENT'] = None dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1161.jsonp" -dictUsecase['EXPECTEDEXCEPTION'] = None # currently: argument of type 'int' is not iterable +dictUsecase['EXPECTEDEXCEPTION'] = "The [import] key requires a value of type 'str', but the type is 'int'" dictUsecase['EXPECTEDRETURN'] = None -# # # listofdictUsecases.append(dictUsecase) +listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} @@ -3232,9 +3285,9 @@ dictUsecase['HINT'] = "'list' instead of 'str'" dictUsecase['COMMENT'] = None dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1162.jsonp" -dictUsecase['EXPECTEDEXCEPTION'] = None # currently: 'list' object has no attribute 'strip' +dictUsecase['EXPECTEDEXCEPTION'] = "The [import] key requires a value of type 'str', but the type is 'list'" dictUsecase['EXPECTEDRETURN'] = None -# # # listofdictUsecases.append(dictUsecase) +listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} @@ -3247,9 +3300,9 @@ dictUsecase['HINT'] = "'dict' instead of 'str'" dictUsecase['COMMENT'] = None dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1163.jsonp" -dictUsecase['EXPECTEDEXCEPTION'] = None # currently: 'dict' object has no attribute 'strip' +dictUsecase['EXPECTEDEXCEPTION'] = "The [import] key requires a value of type 'str', but the type is 'dict'" dictUsecase['EXPECTEDRETURN'] = None -# # # listofdictUsecases.append(dictUsecase) +listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} @@ -3262,9 +3315,42 @@ dictUsecase['HINT'] = "'int' instead of 'str' (from 'dict')" dictUsecase['COMMENT'] = None dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1164.jsonp" -dictUsecase['EXPECTEDEXCEPTION'] = None # currently: File '%values%['A']' is not existing! +dictUsecase['EXPECTEDEXCEPTION'] = "The [import] key requires a value of type 'str', but the type is 'int'" dictUsecase['EXPECTEDRETURN'] = None -# # # listofdictUsecases.append(dictUsecase) +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Cyclic import is detected, but file list in exception should be checked. +# Similar to: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/389 +# Here: 'imported.ST03.1.jsonp' is not expected to be part of file list in exception. +dictUsecase['TESTID'] = "JPP_1165" +dictUsecase['DESCRIPTION'] = "JSON file with cyclic imports (sawtooth, stopped)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "FILE_IMPORTS" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = "Cyclic import" +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1165.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Cyclic imported json file" # file list to be fixed +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Cyclic import is detected, but file list in exception is not correct. +# Similar to: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/389 +dictUsecase['TESTID'] = "JPP_1166" +dictUsecase['DESCRIPTION'] = "JSON file with cyclic imports (sawtooth, endless)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "FILE_IMPORTS" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = "Cyclic import" +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1166.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Cyclic imported json file" # file list to be fixed +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------- diff --git a/test/testfiles/dynamic_imports/AA/BB/CC/DD/imported.DD.CSL.jsonp b/test/testfiles/dynamic_imports/AA/BB/CC/DD/imported.DD.CSL.jsonp new file mode 100644 index 00000000..10c333ed --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/BB/CC/DD/imported.DD.CSL.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "root" : "../../../../", + "values_DD" : {"DD_1" : 1, + "[import]" : "${root}global_defs/imported.common.sublevel.jsonp", + "DD_2" : 2 + } +} diff --git a/test/testfiles/dynamic_imports/AA/BB/CC/imported.CC.CSL.jsonp b/test/testfiles/dynamic_imports/AA/BB/CC/imported.CC.CSL.jsonp new file mode 100644 index 00000000..adb42549 --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/BB/CC/imported.CC.CSL.jsonp @@ -0,0 +1,23 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "root" : "../../../", + "values_CC" : {"CC_1" : 1, + "[import]" : "${root}global_defs/imported.common.sublevel.jsonp", + "CC_2" : 2 + }, + "DD" : "DD", + "[import]" : "./${DD}/imported.${DD}.CSL.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/BB/imported.BB.CSL.jsonp b/test/testfiles/dynamic_imports/AA/BB/imported.BB.CSL.jsonp new file mode 100644 index 00000000..42ed5c1d --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/BB/imported.BB.CSL.jsonp @@ -0,0 +1,23 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "root" : "../../", + "values_BB" : {"BB_1" : 1, + "[import]" : "${root}global_defs/imported.common.sublevel.jsonp", + "BB_2" : 2 + }, + "CC" : "CC", + "[import]" : "./${CC}/imported.${CC}.CSL.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/ST01/imported.ST01.1.jsonp b/test/testfiles/dynamic_imports/AA/ST01/imported.ST01.1.jsonp new file mode 100644 index 00000000..a356cd52 --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/ST01/imported.ST01.1.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "level" : "ST01", + "indicator" : "ST02", + "[import]" : "../imported.AA.ST.1.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/ST01/imported.ST01.2.jsonp b/test/testfiles/dynamic_imports/AA/ST01/imported.ST01.2.jsonp new file mode 100644 index 00000000..5d2dba48 --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/ST01/imported.ST01.2.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "level" : "ST01", + "indicator" : "ST02", + "[import]" : "../imported.AA.ST.2.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/ST02/imported.ST02.1.jsonp b/test/testfiles/dynamic_imports/AA/ST02/imported.ST02.1.jsonp new file mode 100644 index 00000000..2946af1c --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/ST02/imported.ST02.1.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "level" : "ST02", + "indicator" : "ST03", + "[import]" : "../imported.AA.ST.1.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/ST02/imported.ST02.2.jsonp b/test/testfiles/dynamic_imports/AA/ST02/imported.ST02.2.jsonp new file mode 100644 index 00000000..1e6bcd97 --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/ST02/imported.ST02.2.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "level" : "ST02", + "indicator" : "ST03", + "[import]" : "../imported.AA.ST.2.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/ST03/imported.ST03.1.jsonp b/test/testfiles/dynamic_imports/AA/ST03/imported.ST03.1.jsonp new file mode 100644 index 00000000..b5aa4efa --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/ST03/imported.ST03.1.jsonp @@ -0,0 +1,20 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "level" : "ST03" + // stopping here! + // handled in ST.2 (endless loop): // "indicator" : "ST01", + // handled in ST.2 (endless loop): // "[import]" : "../imported.AA.ST.1.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/ST03/imported.ST03.2.jsonp b/test/testfiles/dynamic_imports/AA/ST03/imported.ST03.2.jsonp new file mode 100644 index 00000000..b4d65f44 --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/ST03/imported.ST03.2.jsonp @@ -0,0 +1,20 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "level" : "ST03", + // would be an endless loop if 'cyclic import' detection would not stop the computation: + "indicator" : "ST01", + "[import]" : "../imported.AA.ST.2.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/imported.AA.CSL_1.jsonp b/test/testfiles/dynamic_imports/AA/imported.AA.CSL_1.jsonp new file mode 100644 index 00000000..6f2be80f --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/imported.AA.CSL_1.jsonp @@ -0,0 +1,25 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "root" : "../", + "values_AA_1" : {"AA_1_a" : 1, + "[import]" : "${root}global_defs/imported.common.sublevel.jsonp", + "AA_1_b" : 2 + }, + "values_AA_2" : {"AA_2_a" : 1, + "[import]" : "${root}global_defs/imported.common.sublevel.jsonp", + "AA_2_b" : 2 + } +} diff --git a/test/testfiles/dynamic_imports/AA/imported.AA.CSL_2.jsonp b/test/testfiles/dynamic_imports/AA/imported.AA.CSL_2.jsonp new file mode 100644 index 00000000..c7878115 --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/imported.AA.CSL_2.jsonp @@ -0,0 +1,23 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "root" : "../", + "values_AA" : {"AA_1" : 1, + "[import]" : "${root}global_defs/imported.common.sublevel.jsonp", + "AA_2" : 2 + }, + "BB" : "BB", + "[import]" : "./${BB}/imported.${BB}.CSL.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/imported.AA.ST.1.jsonp b/test/testfiles/dynamic_imports/AA/imported.AA.ST.1.jsonp new file mode 100644 index 00000000..5f3eb184 --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/imported.AA.ST.1.jsonp @@ -0,0 +1,17 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "[import]" : "./${indicator}/imported.${indicator}.1.jsonp" +} diff --git a/test/testfiles/dynamic_imports/AA/imported.AA.ST.2.jsonp b/test/testfiles/dynamic_imports/AA/imported.AA.ST.2.jsonp new file mode 100644 index 00000000..47c7d15f --- /dev/null +++ b/test/testfiles/dynamic_imports/AA/imported.AA.ST.2.jsonp @@ -0,0 +1,17 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "[import]" : "./${indicator}/imported.${indicator}.2.jsonp" +} diff --git a/test/testfiles/dynamic_imports/csl_import_1.jsonp b/test/testfiles/dynamic_imports/csl_import_1.jsonp new file mode 100644 index 00000000..3de909a2 --- /dev/null +++ b/test/testfiles/dynamic_imports/csl_import_1.jsonp @@ -0,0 +1,18 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "AA" : "AA", + "[import]" : "./${AA}/imported.${AA}.CSL_1.jsonp" +} diff --git a/test/testfiles/dynamic_imports/csl_import_2.jsonp b/test/testfiles/dynamic_imports/csl_import_2.jsonp new file mode 100644 index 00000000..556904f6 --- /dev/null +++ b/test/testfiles/dynamic_imports/csl_import_2.jsonp @@ -0,0 +1,18 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "AA" : "AA", + "[import]" : "./${AA}/imported.${AA}.CSL_2.jsonp" +} diff --git a/test/testfiles/dynamic_imports/global_defs/imported.common.sublevel.jsonp b/test/testfiles/dynamic_imports/global_defs/imported.common.sublevel.jsonp new file mode 100644 index 00000000..314ec7a1 --- /dev/null +++ b/test/testfiles/dynamic_imports/global_defs/imported.common.sublevel.jsonp @@ -0,0 +1,17 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "common_sublevel_param" : "common_sublevel_param value" +} diff --git a/test/testfiles/dynamic_imports/sawtooth_import.1.jsonp b/test/testfiles/dynamic_imports/sawtooth_import.1.jsonp new file mode 100644 index 00000000..c2c665e0 --- /dev/null +++ b/test/testfiles/dynamic_imports/sawtooth_import.1.jsonp @@ -0,0 +1,18 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "indicator" : "ST01", + "[import]" : "./AA/imported.AA.ST.1.jsonp" +} diff --git a/test/testfiles/dynamic_imports/sawtooth_import.2.jsonp b/test/testfiles/dynamic_imports/sawtooth_import.2.jsonp new file mode 100644 index 00000000..be4a156a --- /dev/null +++ b/test/testfiles/dynamic_imports/sawtooth_import.2.jsonp @@ -0,0 +1,18 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "indicator" : "ST01", + "[import]" : "./AA/imported.AA.ST.2.jsonp" +} diff --git a/test/testfiles/jpp-test_config_1112.jsonp b/test/testfiles/jpp-test_config_1112.jsonp new file mode 100644 index 00000000..2c7a013b --- /dev/null +++ b/test/testfiles/jpp-test_config_1112.jsonp @@ -0,0 +1,17 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "[import]" : "./dynamic_imports/csl_import_1.jsonp" +} \ No newline at end of file diff --git a/test/testfiles/jpp-test_config_1113.jsonp b/test/testfiles/jpp-test_config_1113.jsonp new file mode 100644 index 00000000..92938b4b --- /dev/null +++ b/test/testfiles/jpp-test_config_1113.jsonp @@ -0,0 +1,17 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "[import]" : "./dynamic_imports/csl_import_2.jsonp" +} \ No newline at end of file diff --git a/test/testfiles/jpp-test_config_1165.jsonp b/test/testfiles/jpp-test_config_1165.jsonp new file mode 100644 index 00000000..d94bebdc --- /dev/null +++ b/test/testfiles/jpp-test_config_1165.jsonp @@ -0,0 +1,18 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "imports_dir" : "dynamic_imports", + "[import]" : "./${imports_dir}/sawtooth_import.1.jsonp" +} \ No newline at end of file diff --git a/test/testfiles/jpp-test_config_1166.jsonp b/test/testfiles/jpp-test_config_1166.jsonp new file mode 100644 index 00000000..bad9500e --- /dev/null +++ b/test/testfiles/jpp-test_config_1166.jsonp @@ -0,0 +1,18 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + "imports_dir" : "dynamic_imports", + "[import]" : "./${imports_dir}/sawtooth_import.2.jsonp" +} \ No newline at end of file diff --git a/test/testtools/GenSnippetsJPP.py b/test/testtools/GenSnippetsJPP.py index 8d573576..b8469eb6 100644 --- a/test/testtools/GenSnippetsJPP.py +++ b/test/testtools/GenSnippetsJPP.py @@ -22,8 +22,8 @@ # # ************************************************************************************************************** # -VERSION = "0.32.0" -VERSION_DATE = "07.11.2024" +VERSION = "0.34.0" +VERSION_DATE = "18.11.2024" # # ************************************************************************************************************** @@ -3333,16 +3333,32 @@ def GetSeveralParticularSnippets(self): } """) + # cyclic import listCodeSnippets.append("""{ "imports_dir" : "dynamic_imports", "[import]" : "./${imports_dir}/cyclic_import_itself.jsonp" } """) + # cyclic import listCodeSnippets.append("""{ "imports_dir" : "dynamic_imports", "[import]" : "./${imports_dir}/cyclic_import.jsonp" } +""") + + # cyclic import (sawtooth, stopped) + listCodeSnippets.append("""{ + "imports_dir" : "dynamic_imports", + "[import]" : "./${imports_dir}/sawtooth_import.1.jsonp" +} +""") + + # cyclic import (sawtooth, endless) + listCodeSnippets.append("""{ + "imports_dir" : "dynamic_imports", + "[import]" : "./${imports_dir}/sawtooth_import.2.jsonp" +} """) listCodeSnippets.append("""{ @@ -3361,12 +3377,11 @@ def GetSeveralParticularSnippets(self): } """) -# !!! FREEZE !!! - # listCodeSnippets.append("""{ - # "AA" : "AA", - # "[import]" : "./dynamic_imports/${${AA/imported.AA.jsonp" -# } -# """) + listCodeSnippets.append("""{ + "AA" : "AA", + "[import]" : "./dynamic_imports/${${AA/imported.AA.jsonp" +} +""") listCodeSnippets.append("""{ "AA" : "AA", @@ -3411,6 +3426,20 @@ def GetSeveralParticularSnippets(self): "values" : ["A", "B"], "[import]" : ${values}[0] } +""") + + # -------------------------------------------------------------------------------------------------------------- + + # -- multiple imports + + listCodeSnippets.append("""{ + "[import]" : "./dynamic_imports/csl_import_1.jsonp" +} +""") + + listCodeSnippets.append("""{ + "[import]" : "./dynamic_imports/csl_import_2.jsonp" +} """) # listCodeSnippets.append("""{