38#include <wx/filename.h>
39#include <wx/stdpaths.h>
50wxString writeSiblingRules(
BOARD& aBoard,
const wxString& aContent )
59 return fn.GetFullPath();
108 m_ancestor->SetFileName(
m_ancDir.PathStr() + wxFILE_SEP_PATH + wxS(
"board.kicad_pcb" ) );
109 m_ours->SetFileName(
m_oursDir.PathStr() + wxFILE_SEP_PATH + wxS(
"board.kicad_pcb" ) );
110 m_theirs->SetFileName(
m_theirsDir.PathStr() + wxFILE_SEP_PATH + wxS(
"board.kicad_pcb" ) );
117 if( wxFileExists(
path ) )
118 wxRemoveFile(
path );
148 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
162 recordCreatedFile( writeSiblingRules( *m_ours,
163 wxS(
"(version 1)\n(rule \"R\" (constraint clearance "
164 "(min 0.3mm)) (condition \"true\"))\n" ) ) );
166 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
176 BOOST_CHECK(
delta->after.ToDisplayString() !=
"(no custom rules)" );
184 recordCreatedFile( writeSiblingRules( *m_ancestor,
185 wxS(
"(version 1)\n(rule \"A\" (constraint clearance "
186 "(min 0.1mm)) (condition \"true\"))\n" ) ) );
187 recordCreatedFile( writeSiblingRules( *m_ours,
188 wxS(
"(version 1)\n(rule \"B\" (constraint clearance "
189 "(min 0.3mm)) (condition \"true\"))\n" ) ) );
191 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
200 BOOST_CHECK(
delta->before.ToDisplayString() !=
delta->after.ToDisplayString() );
207 const wxString sameContent =
208 wxS(
"(version 1)\n(rule \"R\" (constraint clearance (min 0.2mm)) "
209 "(condition \"true\"))\n" );
211 recordCreatedFile( writeSiblingRules( *m_ancestor, sameContent ) );
216 recordCreatedFile( writeSiblingRules( *m_ours, sameContent ) );
218 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
233 const wxString oursRules =
234 wxS(
"(version 1)\n(rule \"FromOurs\" (constraint clearance (min 0.5mm)) "
235 "(condition \"true\"))\n" );
236 recordCreatedFile( writeSiblingRules( *m_ours, oursRules ) );
238 PCB_DIFFER diffAO( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
239 PCB_DIFFER diffAT( m_ancestor.get(), m_theirs.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
248 std::unique_ptr<BOARD> merged = applier.
Apply();
Information pertinent to a Pcbnew printed circuit board.
const wxString & GetFileName() const
Three-way merge plan generator.
MERGE_PLAN Plan(const DOCUMENT_DIFF &aAncestorOurs, const DOCUMENT_DIFF &aAncestorTheirs) const
Plan the merge given the canonical pair of diffs.
Diff two already-parsed BOARDs and produce a DOCUMENT_DIFF.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
Materialize a MERGE_PLAN into a real merged BOARD.
std::unique_ptr< BOARD > Apply()
Produce the merged board.
const REPORT & GetReport() const
static const std::string DesignRulesFileExtension
static std::vector< PENDING_PROPERTY > plan(const EDA_ITEM &aSource, const EDA_ITEM &aTarget, const std::set< wxString > &aEnabledKeys)
Target properties to write, paired with values read off the source.
const wxString DOC_PROP_CUSTOM_RULES
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
~CUSTOM_DRC_DIFF_MERGE_FIXTURE()
SETTINGS_MANAGER m_settingsAnc
KI_TEST::SCOPED_TEMP_DIR m_ancDir
SETTINGS_MANAGER m_settingsTheirs
KI_TEST::SCOPED_TEMP_DIR m_theirsDir
void recordCreatedFile(const wxString &aPath)
CUSTOM_DRC_DIFF_MERGE_FIXTURE()
std::unique_ptr< BOARD > m_ours
SETTINGS_MANAGER m_settingsOurs
std::unique_ptr< BOARD > m_theirs
std::vector< wxString > m_createdFiles
std::unique_ptr< BOARD > m_ancestor
KI_TEST::SCOPED_TEMP_DIR m_oursDir
The full set of changes between two parsed documents of one type.
std::vector< ITEM_CHANGE > changes
One change record on a single item.
std::vector< PROPERTY_DELTA > properties
Result of planning a 3-way merge.
bool projectFileTouched
True iff the applier resolved state that lives in the .kicad_pro or a project sibling file.
wxString customDrcRules
Custom DRC rules (.kicad_dru) content the applier resolved.
Single (name, before, after) triple for one mutated property on an item.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(NoSiblingFileEmitsNoDelta)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
static const ITEM_CHANGE * findDocLevelChange(const DOCUMENT_DIFF &aDiff)
Find the synthetic doc-level ITEM_CHANGE (empty KIID_PATH) in a diff result, returning nullptr if non...
static const PROPERTY_DELTA * findProperty(const ITEM_CHANGE &aChange, const wxString &aName)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
Definition of file extensions used in Kicad.