37#include <wx/filename.h>
38#include <wx/stdpaths.h>
47wxString uniqueSuffix()
49 static int counter = 0;
50 return wxString::Format( wxS(
"%d_%d" ),
51 static_cast<int>( wxGetUTCTimeMillis().GetValue() & 0xffffff ),
56wxString writeProjectFile(
BOARD& aBoard,
const std::string& aFileName,
57 const wxString& aContent )
60 fn.SetFullName( wxString::FromUTF8( aFileName ) );
66 return fn.GetFullPath();
108 wxString tmp = wxStandardPaths::Get().GetTempDir();
109 m_ancDir = tmp + wxFILE_SEP_PATH + wxS(
"kicad_libtbl_anc_" ) + uniqueSuffix();
110 m_oursDir = tmp + wxFILE_SEP_PATH + wxS(
"kicad_libtbl_ours_" ) + uniqueSuffix();
111 m_theirsDir = tmp + wxFILE_SEP_PATH + wxS(
"kicad_libtbl_theirs_" ) + uniqueSuffix();
114 BOOST_REQUIRE( wxFileName::Mkdir( d, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
117 m_ours ->SetFileName(
m_oursDir + wxFILE_SEP_PATH + wxS(
"board.kicad_pcb" ) );
125 if( !d.IsEmpty() && wxFileName::DirExists( d ) )
126 wxFileName::Rmdir( d, wxPATH_RMDIR_RECURSIVE );
147 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
161 wxS(
"(fp_lib_table\n(version 7)\n)\n" ) );
163 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
172 BOOST_CHECK(
delta->after.ToDisplayString() !=
"(no fp-lib-table)" );
179 wxS(
"(sym_lib_table\n(version 7)\n)\n" ) );
181 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
190 BOOST_CHECK(
delta->after.ToDisplayString() !=
"(no sym-lib-table)" );
197 wxS(
"(fp_lib_table\n(version 7)\n(lib (name old))\n)\n" ) );
199 wxS(
"(fp_lib_table\n(version 7)\n(lib (name new))\n)\n" ) );
201 PCB_DIFFER differ( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
209 BOOST_CHECK(
delta->before.ToDisplayString() !=
delta->after.ToDisplayString() );
215 const wxString oursFp =
216 wxS(
"(fp_lib_table\n(version 7)\n(lib (name FromOurs))\n)\n" );
219 PCB_DIFFER diffAO( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
220 PCB_DIFFER diffAT( m_ancestor.get(), m_theirs.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
229 std::unique_ptr<BOARD> merged = applier.
Apply();
240 const wxString oursSym =
241 wxS(
"(sym_lib_table\n(version 7)\n(lib (name FromOurs))\n)\n" );
244 PCB_DIFFER diffAO( m_ancestor.get(), m_ours.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
245 PCB_DIFFER diffAT( m_ancestor.get(), m_theirs.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
254 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 SymbolLibraryTableFileName
static const std::string FootprintLibraryTableFileName
const wxString DOC_PROP_SYM_LIB_TABLE
const wxString DOC_PROP_FP_LIB_TABLE
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
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.
wxString fpLibTable
fp-lib-table content the applier resolved.
bool projectFileTouched
True iff the applier resolved state that lives in the .kicad_pro or a project sibling file.
wxString symLibTable
sym-lib-table content the applier resolved.
Single (name, before, after) triple for one mutated property on an item.
LIB_TABLE_DIFF_MERGE_FIXTURE()
std::unique_ptr< BOARD > m_ours
~LIB_TABLE_DIFF_MERGE_FIXTURE()
SETTINGS_MANAGER m_settingsOurs
SETTINGS_MANAGER m_settingsAnc
SETTINGS_MANAGER m_settingsTheirs
std::unique_ptr< BOARD > m_theirs
std::unique_ptr< BOARD > m_ancestor
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(NoSiblingFilesEmitsNoDelta)
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.