EgtGeneral 1.5g1 :

- In CmdParser comando ContinueOnError sostituito da Assert.
This commit is contained in:
Dario Sassi
2014-08-02 21:15:40 +00:00
parent e73051bc0b
commit ae10451cea
3 changed files with 39 additions and 29 deletions
+36 -26
View File
@@ -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 ;