37#include <wx/filename.h>
38#include <wx/stdpaths.h>
49wxString writeSiblingRules(
BOARD& aBoard,
const wxString& aContent )
58 return fn.GetFullPath();
104 wxString tmp = wxStandardPaths::Get().GetTempDir();
105 m_ancDir = ( wxFileName( tmp, wxEmptyString ).GetPath() + wxFILE_SEP_PATH
107 m_oursDir = ( wxFileName( tmp, wxEmptyString ).GetPath() + wxFILE_SEP_PATH
109 m_theirsDir = ( wxFileName( tmp, wxEmptyString ).GetPath() + wxFILE_SEP_PATH
113 BOOST_REQUIRE( wxFileName::Mkdir( d, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
116 m_ours ->SetFileName(
m_oursDir + wxFILE_SEP_PATH + wxS(
"board.kicad_pcb" ) );
124 if( wxFileExists(
path ) )
125 wxRemoveFile(
path );
130 if( !d.IsEmpty() && wxFileName::DirExists( d ) )
131 wxFileName::Rmdir( d, wxPATH_RMDIR_RECURSIVE );
142 static int counter = 0;
143 return wxString::Format( wxS(
"%d_%d" ),
144 static_cast<int>( wxGetUTCTimeMillis().GetValue() & 0xffffff ),
168 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
182 recordCreatedFile( writeSiblingRules( *m_ours,
183 wxS(
"(version 1)\n(rule \"R\" (constraint clearance "
184 "(min 0.3mm)) (condition \"true\"))\n" ) ) );
186 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
196 BOOST_CHECK(
delta->after.ToDisplayString() !=
"(no custom rules)" );
204 recordCreatedFile( writeSiblingRules( *m_ancestor,
205 wxS(
"(version 1)\n(rule \"A\" (constraint clearance "
206 "(min 0.1mm)) (condition \"true\"))\n" ) ) );
207 recordCreatedFile( writeSiblingRules( *m_ours,
208 wxS(
"(version 1)\n(rule \"B\" (constraint clearance "
209 "(min 0.3mm)) (condition \"true\"))\n" ) ) );
211 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
220 BOOST_CHECK(
delta->before.ToDisplayString() !=
delta->after.ToDisplayString() );
227 const wxString sameContent =
228 wxS(
"(version 1)\n(rule \"R\" (constraint clearance (min 0.2mm)) "
229 "(condition \"true\"))\n" );
231 recordCreatedFile( writeSiblingRules( *m_ancestor, sameContent ) );
236 recordCreatedFile( writeSiblingRules( *m_ours, sameContent ) );
238 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
253 const wxString oursRules =
254 wxS(
"(version 1)\n(rule \"FromOurs\" (constraint clearance (min 0.5mm)) "
255 "(condition \"true\"))\n" );
256 recordCreatedFile( writeSiblingRules( *m_ours, oursRules ) );
258 PCB_DIFFER diffAO( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
259 PCB_DIFFER diffAT( m_ancestor.get(), m_theirs.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
268 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
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
SETTINGS_MANAGER m_settingsTheirs
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
static wxString uniqueSuffix()
std::vector< wxString > m_createdFiles
std::unique_ptr< BOARD > m_ancestor
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.