21#include <boost/test/unit_test.hpp>
40 std::unique_ptr<SCH_NETCHAIN> aChain );
45static void swallowWxAssert(
const wxString&,
int,
const wxString&,
const wxString&,
108 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
121 const bool expectedBuiltAfterRollback =
false;
127 bool hookFired =
false;
133 auto stray = std::make_unique<SCH_NETCHAIN>();
134 stray->SetName( wxT(
"ROLLBACK_PARTIAL" ) );
135 stray->AddNet( wxT(
"/STRAY_NET" ) );
138 BOOST_REQUIRE_GT( aGraph.GetCommittedNetChains().size(), 0u );
140 throw std::runtime_error(
"rollback test injected throw" );
151 "Rollback hook never fired; snapshot/restore code path was not exercised" );
154 "Catch block did not resize m_committedNetChains back to the snapshot; "
155 "partial chain leaked into the committed list" );
158 "Catch block did not restore m_netChainsBuilt; readiness flag is stale" );
163 "Partially-built chain 'ROLLBACK_PARTIAL' survived the rollback" );
181 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
189 bool hookFired =
false;
194 throw std::runtime_error(
"no-growth rollback test throw" );
204 BOOST_CHECK( hookFired );
209 "Rollback left m_netChainsBuilt = true; the success-flag write "
210 "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")