diff --git a/CmdParser.cpp b/CmdParser.cpp index ce0ae20..27212e6 100644 --- a/CmdParser.cpp +++ b/CmdParser.cpp @@ -37,7 +37,7 @@ CmdParser::CmdParser( void) m_nLev = 0 ; // assegno chiavi a funzioni di esecuzione m_ExecMgr.Init( 16) ; - m_ExecMgr.Insert( "CONTINUEONERROR", &CmdParser::ExecuteContinueOnError) ; + m_ExecMgr.Insert( "ASSERT", &CmdParser::ExecuteAssert) ; m_ExecMgr.Insert( "COUNTER", &CmdParser::ExecuteCounter) ; m_ExecMgr.Insert( "DIR", &CmdParser::ExecuteDir) ; m_ExecMgr.Insert( "DIRREPLACE", &CmdParser::ExecuteDirReplace) ; @@ -135,8 +135,8 @@ CmdParser::Run( const string& sCmdFile, bool bIsolated) // interpretazione dei comandi del file m_nCurrLine = 0 ; m_nExec = DO ; - m_bContinueOnError = false ; - while ( ( bOk || m_bContinueOnError) && m_nExec != STOP && TheScanner.GetLine( sLine)) { + m_nAssertNextError = 0 ; + while ( bOk && m_nExec != STOP && TheScanner.GetLine( sLine)) { // assegno numero linea corrente m_nCurrLine = TheScanner.GetCurrLineNbr() ; // elimino gli spazi all'inizio e alla fine @@ -150,11 +150,22 @@ CmdParser::Run( const string& sCmdFile, bool bIsolated) if ( m_nExec == SKIP && sCmd != "EXEC.DO") continue ; // deve esserci un comando e deve essere eseguito correttamente - if ( sCmd.empty() || ! ExecCommand( sCmd, sParams)) { - bOk = false ; + if ( ! sCmd.empty() && ExecCommand( sCmd, sParams)) { + if ( m_nAssertNextError == 1) { + bOk = false ; + sOut = GetInitSpaces() + "Expected error not found on line (" + ToString( m_nCurrLine) + ") : " + sLine ; + LOG_ERROR( GetEGnLogger(), sOut.c_str()) + } + } + else { + if ( m_nAssertNextError != 1) + bOk = false ; sOut = GetInitSpaces() + "Error on line (" + ToString( m_nCurrLine) + ") : " + sLine ; LOG_ERROR( GetEGnLogger(), sOut.c_str()) } + // reset flag atteso errore su prossima istruzione + if ( m_nAssertNextError > 0) + -- m_nAssertNextError ; } // log di fine file @@ -162,10 +173,6 @@ CmdParser::Run( const string& sCmdFile, bool bIsolated) sOut = GetInitSpaces() + "--- End ---" ; LOG_INFO( GetEGnLogger(), sOut.c_str()) } - else if ( m_bContinueOnError) { - sOut = GetInitSpaces() + "--- End : some errors ---" ; - LOG_ERROR( GetEGnLogger(), sOut.c_str()) - } else { sOut = GetInitSpaces() + "--- Stop : error ---" ; LOG_ERROR( GetEGnLogger(), sOut.c_str()) @@ -344,15 +351,15 @@ CmdParser::GetIdParam( const string& sParam, bool bNewAllowed) //---------------------------------------------------------------------------- bool -CmdParser::GetTextParam( const string& sParam, string& sText) +CmdParser::GetStringParam( const string& sParam, string& sString) { if ( sParam.empty()) return false ; - sText = sParam ; - if ( sText[0] == '(') - sText.erase( 0, 1) ; - if ( ! sText.empty() && sText.back() == ')') - sText.pop_back() ; + sString = sParam ; + if ( sString[0] == '(') + sString.erase( 0, 1) ; + if ( ! sString.empty() && sString.back() == ')') + sString.pop_back() ; return true ; } @@ -415,17 +422,20 @@ CmdParser::ExecCommand( const string& sCmd, const string& sParams) //---------------------------------------------------------------------------- bool -CmdParser::ExecuteContinueOnError( const string& sCmd2, const STRVECTOR& vsParams) +CmdParser::ExecuteAssert( const string& sCmd2, const STRVECTOR& vsParams) { - // nessun parametro - if ( vsParams.size() != 0) - return false ; - // imposto il flag di continuazione su errore - m_bContinueOnError = true ; - // emetto log - string sOut = GetInitSpaces() + "Continue on error (" + ToString( m_nCurrLine) + ")" ; - LOG_INFO( GetEGnLogger(), sOut.c_str()) - return true ; + if ( sCmd2 == "NEXTERROR") { + // nessun parametro + if ( vsParams.size() != 0) + return false ; + // imposto il flag di assert errore in prossima istruzione + m_nAssertNextError = 2 ; + // emetto log + string sOut = GetInitSpaces() + "Assert error on next line (" + ToString( m_nCurrLine) + ")" ; + LOG_INFO( GetEGnLogger(), sOut.c_str()) + return true ; + } + return false ; } //---------------------------------------------------------------------------- @@ -596,7 +606,7 @@ CmdParser::ExecuteOutLog( const string& sCmd2, const STRVECTOR& vsParams) // recupero messaggio string sMsg ; - if ( ! GetTextParam( vsParams[0], sMsg)) + if ( ! GetStringParam( vsParams[0], sMsg)) return false ; string sOut = GetInitSpaces() + sMsg ; diff --git a/CmdParser.h b/CmdParser.h index 20d163a..7cb8b59 100644 --- a/CmdParser.h +++ b/CmdParser.h @@ -36,7 +36,7 @@ class CmdParser : public ICmdParser virtual int DirReplace( std::string& sPath) ; virtual int DirInvReplace( std::string& sPath) ; virtual int GetIdParam( const std::string& sParam, bool bNewAllowed = false) ; - virtual bool GetTextParam( const std::string& sParam, std::string& sText) ; + virtual bool GetStringParam( const std::string& sParam, std::string& sString) ; virtual bool Run( const std::string& sCmdFile, bool bIsolated = true) ; virtual bool ExecLine( const std::string& sCmdLine, bool bIsolated = false) ; @@ -47,7 +47,7 @@ class CmdParser : public ICmdParser bool ResetAllVariables( void) ; std::string GetInitSpaces( void) ; bool ExecCommand( const std::string& sCmd, const std::string& sParams) ; - bool ExecuteContinueOnError( const std::string& sCmd2, const STRVECTOR& vsParams) ; + bool ExecuteAssert( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteCounter( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteDir( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteDirReplace( const std::string& sCmd2, const STRVECTOR& vsParams) ; @@ -74,7 +74,7 @@ class CmdParser : public ICmdParser ExecManager m_ExecMgr ; int m_nLev ; Exec m_nExec ; - bool m_bContinueOnError ; + int m_nAssertNextError ; int m_nCurrLine ; PerformanceCounter m_Counter ; StrStrVector m_DirReplace ; diff --git a/EgtGeneral.rc b/EgtGeneral.rc index d000c73..c88e925 100644 Binary files a/EgtGeneral.rc and b/EgtGeneral.rc differ