20#include <boost/test/unit_test.hpp>
39 std::unique_ptr<SCH_NETCHAIN> aChain );
44static void swallowWxAssert(
const wxString&,
int,
const wxString&,
const wxString&,
107 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
120 const bool expectedBuiltAfterRollback =
false;
126 bool hookFired =
false;
132 auto stray = std::make_unique<SCH_NETCHAIN>();
133 stray->SetName( wxT(
"ROLLBACK_PARTIAL" ) );
134 stray->AddNet( wxT(
"/STRAY_NET" ) );
137 BOOST_REQUIRE_GT( aGraph.GetCommittedNetChains().size(), 0u );
139 throw std::runtime_error(
"rollback test injected throw" );
150 "Rollback hook never fired; snapshot/restore code path was not exercised" );
153 "Catch block did not resize m_committedNetChains back to the snapshot; "
154 "partial chain leaked into the committed list" );
157 "Catch block did not restore m_netChainsBuilt; readiness flag is stale" );
162 "Partially-built chain 'ROLLBACK_PARTIAL' survived the rollback" );
180 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
188 bool hookFired =
false;
193 throw std::runtime_error(
"no-growth rollback test throw" );
203 BOOST_CHECK( hookFired );
208 "Rollback left m_netChainsBuilt = true; the success-flag write "
209 "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)
static void swallowWxAssert(const wxString &, int, const wxString &, const wxString &, const wxString &)
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_CHECK_EQUAL(result, "25.4")