From f7f51cb86051393f890e0743c6cb76d8a3dd9b12 Mon Sep 17 00:00:00 2001 From: mas2hc Date: Mon, 13 May 2024 15:58:04 +0700 Subject: [PATCH] Updated based on review comments. --- .../Config/CConfig.py | 13 ++++++++----- .../Keywords/CSetup.py | 16 ++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/RobotFramework_TestsuitesManagement/Config/CConfig.py b/RobotFramework_TestsuitesManagement/Config/CConfig.py index df451068..77a790c5 100644 --- a/RobotFramework_TestsuitesManagement/Config/CConfig.py +++ b/RobotFramework_TestsuitesManagement/Config/CConfig.py @@ -515,12 +515,15 @@ def __updateGlobalVariable(self): lReservedKeyword = ['Settings', 'Variables', 'Keywords', 'Comments', 'Documentation', 'Metadata'] if 'params' in self.oConfigParams and 'global' in self.oConfigParams['params']: for k,v in self.oConfigParams['params']['global'].items(): - if not re.match(varNamePattern, k) or k in lReservedKeyword: + if not re.match(varNamePattern, k): self.bLoadedCfg = False - self.sLoadedCfgLog['error'].append(f"Parameter '{k}' is invalid variable name or conflicts with Robot reserved keywords.") - self.sLoadedCfgLog['error'].append("Variable names in Robot Framework must start with a letter or underscore, \ -followed by letters, digits, or underscores.") - BuiltIn().unknown() + self.sLoadedCfgLog['error'].append(f"Found invalid parameter name '{k}'.") + self.sLoadedCfgLog['unknown'] = "Violation of naming conventions detected. The test execution will be aborted!" + raise Exception + if k in lReservedKeyword: + self.sLoadedCfgLog['error'].append(f"'{k}' is a reserved keyword in Robot Framework and cannot be used as parameter name.") + self.sLoadedCfgLog['unknown'] = "Violation of naming conventions detected. The test execution will be aborted!" + raise Exception if k in self.lBuitInVariables: continue try: diff --git a/RobotFramework_TestsuitesManagement/Keywords/CSetup.py b/RobotFramework_TestsuitesManagement/Keywords/CSetup.py index 0f85871f..b5d23e7f 100644 --- a/RobotFramework_TestsuitesManagement/Keywords/CSetup.py +++ b/RobotFramework_TestsuitesManagement/Keywords/CSetup.py @@ -64,10 +64,12 @@ def testsuite_setup(self, sTestsuiteCfgFile=''): if not TM.CTestsuitesCfg.oConfig.bLoadedCfg: if len(TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['error']) > 0: for errorMsg in TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['error']: - logger.error(errorMsg) + if errorMsg.strip() != '': + logger.error(errorMsg) if len(TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['info']) > 0: - for errorMsg in TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['info']: - logger.error(errorMsg) + for infoMsg in TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['info']: + if infoMsg.strip() != '': + logger.error(infoMsg) BuiltIn().unknown(TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['unknown']) return if not TM.CTestsuitesCfg.oConfig.rConfigFiles.bLevel1: @@ -83,10 +85,12 @@ def testsuite_setup(self, sTestsuiteCfgFile=''): except: if len(TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['error']) > 0: for errorMsg in TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['error']: - logger.error(errorMsg) + if errorMsg.strip() != '': + logger.error(errorMsg) if len(TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['info']) > 0: - for errorMsg in TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['info']: - logger.error(errorMsg) + for infoMsg in TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['info']: + if infoMsg.strip() != '': + logger.error(infoMsg) BuiltIn().unknown(TM.CTestsuitesCfg.oConfig.sLoadedCfgLog['unknown']) if TM.CTestsuitesCfg.oConfig.rConfigFiles.bLevel1: