21#include <boost/test/unit_test.hpp>
40 std::unique_ptr<SCH_NETCHAIN> aChain );
54 wxSetDefaultAssertHandler();
95 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
108 const bool expectedBuiltAfterRollback =
false;
114 bool hookFired =
false;
120 auto stray = std::make_unique<SCH_NETCHAIN>();
121 stray->SetName( wxT(
"ROLLBACK_PARTIAL" ) );
122 stray->AddNet( wxT(
"/STRAY_NET" ) );
125 BOOST_REQUIRE_GT( aGraph.GetCommittedNetChains().size(), 0u );
127 throw std::runtime_error(
"rollback test injected throw" );
138 "Rollback hook never fired; snapshot/restore code path was not exercised" );
141 "Catch block did not resize m_committedNetChains back to the snapshot; "
142 "partial chain leaked into the committed list" );
145 "Catch block did not restore m_netChainsBuilt; readiness flag is stale" );
150 "Partially-built chain 'ROLLBACK_PARTIAL' survived the rollback" );
168 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
176 bool hookFired =
false;
181 throw std::runtime_error(
"no-growth rollback test throw" );
191 BOOST_CHECK( hookFired );
196 "Rollback left m_netChainsBuilt = true; the success-flag write "
197 "escaped the catch handler's snapshot restore" );
Calculate the connectivity of a schematic and generates netlists.
SCH_NETCHAIN * GetNetChainByName(const wxString &aName)
static std::function< void(CONNECTION_GRAPH &)> & RebuildNetChainsTestHook()
Test-only hook fired inside RebuildNetChains() after the restore passes have finished but before the ...
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Update the connection graph for the given list of sheets.
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & GetPotentialNetChains() const
Potential net chains are inferred groupings produced by RebuildNetChains() but not yet user-committed...
bool NetChainsBuilt() const
Returns true once RebuildNetChains() has completed at least once on this graph.
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & GetCommittedNetChains() const
Return user-created (committed) net chains (legacy accessor retained under net-chain API).
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
void wxAssertThrower(const wxString &aFile, int aLine, const wxString &aFunc, const wxString &aCond, const wxString &aMsg)
std::vector< FAB_LAYER_COLOR > dummy
NETCHAIN_ROLLBACK_FIXTURE()
std::unique_ptr< SCHEMATIC > m_schematic
~NETCHAIN_ROLLBACK_FIXTURE()
SETTINGS_MANAGER m_settingsManager
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
void boost_test_inject_committed_net_chain(CONNECTION_GRAPH &aGraph, std::unique_ptr< SCH_NETCHAIN > aChain)
BOOST_FIXTURE_TEST_CASE(NetChain_RebuildRollback_TruncatesAndRestoresOnThrow, NETCHAIN_ROLLBACK_FIXTURE)
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_CHECK_EQUAL(result, "25.4")