pns_debug_tool: Fix "save as" to save log file with new router state
This commit is contained in:
parent
11f5908761
commit
ca148fb4d1
|
@ -58,6 +58,13 @@ public:
|
||||||
EVENT_TYPE type;
|
EVENT_TYPE type;
|
||||||
KIID uuid;
|
KIID uuid;
|
||||||
SIZES_SETTINGS sizes;
|
SIZES_SETTINGS sizes;
|
||||||
|
|
||||||
|
EVENT_ENTRY() {}
|
||||||
|
|
||||||
|
EVENT_ENTRY( const EVENT_ENTRY& aE ) :
|
||||||
|
p( aE.p ), type( aE.type ), uuid( aE.uuid ), sizes( aE.sizes )
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LOGGER();
|
LOGGER();
|
||||||
|
|
|
@ -299,11 +299,10 @@ bool PNS_LOG_FILE::COMMIT_STATE::Compare( const PNS_LOG_FILE::COMMIT_STATE& aOth
|
||||||
|
|
||||||
bool PNS_LOG_FILE::SaveLog( const wxFileName& logFileName, REPORTER* aRpt )
|
bool PNS_LOG_FILE::SaveLog( const wxFileName& logFileName, REPORTER* aRpt )
|
||||||
{
|
{
|
||||||
std::vector<PNS::ITEM*> dummyHeads; // todo - save heads when we support it in QA
|
|
||||||
|
|
||||||
FILE* log_f = wxFopen( logFileName.GetFullPath(), "wb" );
|
FILE* log_f = wxFopen( logFileName.GetFullPath(), "wb" );
|
||||||
wxString logString = PNS::LOGGER::FormatLogFileAsString( m_mode, m_commitState.m_addedItems,
|
wxString logString = PNS::LOGGER::FormatLogFileAsString( m_mode, m_commitState.m_addedItems,
|
||||||
m_commitState.m_removedIds, dummyHeads,
|
m_commitState.m_removedIds,
|
||||||
|
m_commitState.m_heads,
|
||||||
m_events );
|
m_events );
|
||||||
fprintf( log_f, "%s\n", logString.c_str().AsChar() );
|
fprintf( log_f, "%s\n", logString.c_str().AsChar() );
|
||||||
fclose( log_f );
|
fclose( log_f );
|
||||||
|
|
|
@ -57,12 +57,14 @@ public:
|
||||||
{
|
{
|
||||||
COMMIT_STATE(){};
|
COMMIT_STATE(){};
|
||||||
COMMIT_STATE( const COMMIT_STATE& aOther ) :
|
COMMIT_STATE( const COMMIT_STATE& aOther ) :
|
||||||
m_removedIds( aOther.m_removedIds ), m_addedItems( aOther.m_addedItems )
|
m_removedIds( aOther.m_removedIds ), m_addedItems( aOther.m_addedItems ),
|
||||||
|
m_heads( aOther.m_heads )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<KIID> m_removedIds;
|
std::set<KIID> m_removedIds;
|
||||||
std::vector<PNS::ITEM*> m_addedItems;
|
std::vector<PNS::ITEM*> m_addedItems;
|
||||||
|
std::vector<PNS::ITEM*> m_heads;
|
||||||
|
|
||||||
bool Compare( const COMMIT_STATE& aOther );
|
bool Compare( const COMMIT_STATE& aOther );
|
||||||
};
|
};
|
||||||
|
@ -84,8 +86,17 @@ public:
|
||||||
|
|
||||||
const COMMIT_STATE& GetExpectedResult() const { return m_commitState; }
|
const COMMIT_STATE& GetExpectedResult() const { return m_commitState; }
|
||||||
|
|
||||||
|
void SetExpectedResult( const COMMIT_STATE& aCommitState,
|
||||||
|
std::vector<std::unique_ptr<PNS::ITEM>> aParsedItems )
|
||||||
|
{
|
||||||
|
m_commitState = aCommitState;
|
||||||
|
m_parsed_items = std::move( aParsedItems );
|
||||||
|
}
|
||||||
|
|
||||||
PNS::ROUTER_MODE GetMode() const { return m_mode; }
|
PNS::ROUTER_MODE GetMode() const { return m_mode; }
|
||||||
|
|
||||||
|
void SetMode( PNS::ROUTER_MODE aMode ) { m_mode = aMode; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd, wxStringTokenizer& aTokens );
|
bool parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd, wxStringTokenizer& aTokens );
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,8 @@ const PNS_LOG_FILE::COMMIT_STATE PNS_LOG_PLAYER::GetRouterUpdatedItems()
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PNS_LOG_PLAYER::ReplayLog( PNS_LOG_FILE* aLog, int aStartEventIndex, int aFrom, int aTo )
|
void PNS_LOG_PLAYER::ReplayLog( PNS_LOG_FILE* aLog, int aStartEventIndex, int aFrom, int aTo,
|
||||||
|
bool aUpdateExpectedResult )
|
||||||
{
|
{
|
||||||
m_board = aLog->GetBoard();
|
m_board = aLog->GetBoard();
|
||||||
|
|
||||||
|
@ -250,7 +251,36 @@ void PNS_LOG_PLAYER::ReplayLog( PNS_LOG_FILE* aLog, int aStartEventIndex, int aF
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxASSERT_MSG( m_router->Mode() == aLog->GetMode(), "didn't set the router mode correctly?" );
|
||||||
|
|
||||||
|
if( aUpdateExpectedResult )
|
||||||
|
{
|
||||||
|
std::vector<PNS::ITEM*> added, removed, heads;
|
||||||
|
m_router->GetUpdatedItems( removed, added, heads );
|
||||||
|
|
||||||
|
std::set<KIID> removedKIIDs;
|
||||||
|
|
||||||
|
for( auto item : removed )
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( item->Parent() != nullptr, "removed an item with no parent uuid?" );
|
||||||
|
|
||||||
|
if( item->Parent() )
|
||||||
|
removedKIIDs.insert( item->Parent()->m_Uuid );
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::unique_ptr<PNS::ITEM>> myOwnedItems;
|
||||||
|
PNS_LOG_FILE::COMMIT_STATE routerCommitState;
|
||||||
|
routerCommitState.m_addedItems = added;
|
||||||
|
routerCommitState.m_removedIds = removedKIIDs;
|
||||||
|
routerCommitState.m_heads = heads;
|
||||||
|
|
||||||
|
for( PNS::ITEM* head : heads )
|
||||||
|
myOwnedItems.emplace_back( head );
|
||||||
|
|
||||||
|
aLog->SetExpectedResult( routerCommitState, std::move( myOwnedItems ) );
|
||||||
|
|
||||||
|
int test = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,8 @@ public:
|
||||||
PNS_LOG_PLAYER();
|
PNS_LOG_PLAYER();
|
||||||
~PNS_LOG_PLAYER();
|
~PNS_LOG_PLAYER();
|
||||||
|
|
||||||
void ReplayLog( PNS_LOG_FILE* aLog, int aStartEventIndex = 0, int aFrom = 0, int aTo = -1 );
|
void ReplayLog( PNS_LOG_FILE* aLog, int aStartEventIndex = 0, int aFrom = 0, int aTo = -1,
|
||||||
|
bool aUpdateExpectedResult = false );
|
||||||
|
|
||||||
void SetReporter( REPORTER* aReporter ) { m_reporter = aReporter; }
|
void SetReporter( REPORTER* aReporter ) { m_reporter = aReporter; }
|
||||||
|
|
||||||
|
|
|
@ -342,7 +342,7 @@ void PNS_LOG_VIEWER_FRAME::SetLogFile( PNS_LOG_FILE* aLog )
|
||||||
|
|
||||||
SetBoard( m_logFile->GetBoard() );
|
SetBoard( m_logFile->GetBoard() );
|
||||||
|
|
||||||
m_logPlayer->ReplayLog( m_logFile.get(), 0, 0, -1);
|
m_logPlayer->ReplayLog( m_logFile.get(), 0, 0, -1, true );
|
||||||
|
|
||||||
auto dbgd = m_logPlayer->GetDebugDecorator();
|
auto dbgd = m_logPlayer->GetDebugDecorator();
|
||||||
int n_stages = dbgd->GetStageCount();
|
int n_stages = dbgd->GetStageCount();
|
||||||
|
|
Loading…
Reference in New Issue