28#include <wx/filename.h>
29#include <wx/stdpaths.h>
54wxString stageProject(
const wxString& aStem )
56 wxString sep = wxFileName::GetPathSeparator();
57 wxString dir = wxStandardPaths::Get().GetTempDir() + sep + aStem + wxT(
"-fpreconcile-qa" );
59 if( wxDirExists( dir ) )
60 wxFileName::Rmdir( dir, wxPATH_RMDIR_RECURSIVE );
62 wxFileName::Mkdir( dir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
64 wxString projectPath = dir + sep + aStem + wxT(
".kicad_pro" );
68 Pgm().GetSettingsManager().
Prj().GetProjectDirectory() );
82 wxString projectPath = stageProject( wxS(
"eagle_fpreconcile" ) );
86 brdFn.AppendDir( wxS(
"io" ) );
87 brdFn.AppendDir( wxS(
"eagle" ) );
88 brdFn.SetFullName( wxS(
"eagle-import-testfile.brd" ) );
89 BOOST_REQUIRE_MESSAGE( brdFn.FileExists(),
"Missing Eagle board fixture" );
92 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
96 BOOST_REQUIRE_GT( board->Footprints().size(), 0 );
99 std::vector<std::unique_ptr<FOOTPRINT>> defs;
102 defs.emplace_back( fp );
107 const wxString cacheNick = wxS(
"eagle_test-import-fps" );
111 reconciler.
Reconcile( board.get(), std::move( defs ), cacheNick, {} );
115 BOOST_CHECK_GT(
result.m_savedToCache, 0 );
117 wxFileName prettyDir(
project.GetProjectPath(), cacheNick,
120 "Generated .pretty was not published" );
125 BOOST_CHECK( projectTable->
HasRow( cacheNick ) );
130 for(
FOOTPRINT* fp : board->Footprints() )
132 wxString
name = fp->GetFPID().GetUniStringLibItemName();
137 wxString nick = fp->GetFPID().GetUniStringLibNickname();
140 wxString::Format(
"Board footprint '%s' left with empty nickname",
143 wxString::Format(
"FPID '%s:%s' does not resolve after reconciliation",
148 BOOST_CHECK_GT( resolved, 0 );
157 stageProject( wxS(
"altium_fpreconcile" ) );
160 std::string dataPath =
164 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
168 BOOST_REQUIRE_GT( board->Footprints().size(), 0 );
171 std::vector<std::unique_ptr<FOOTPRINT>> defs;
174 defs.emplace_back( fp );
179 const wxString cacheNick = wxS(
"hifive-import-fps" );
183 reconciler.
Reconcile( board.get(), std::move( defs ), cacheNick, {} );
190 for(
FOOTPRINT* fp : board->Footprints() )
192 wxString
name = fp->GetFPID().GetUniStringLibItemName();
197 wxString nick = fp->GetFPID().GetUniStringLibNickname();
200 wxString::Format(
"FPID '%s:%s' does not resolve after reconciliation",
205 BOOST_CHECK_GT( resolved, 0 );
213 stageProject( wxS(
"eagle_netlist_roundtrip" ) );
217 brdFn.AppendDir( wxS(
"io" ) );
218 brdFn.AppendDir( wxS(
"eagle" ) );
219 brdFn.SetFullName( wxS(
"eagle-import-testfile.brd" ) );
223 std::unique_ptr<BOARD> imported = std::make_unique<BOARD>();
224 imported->SetProject( &
project );
228 std::vector<std::unique_ptr<FOOTPRINT>> defs;
231 defs.emplace_back( fp );
236 const wxString cacheNick = wxS(
"eagle_test-import-fps" );
238 reconciler.
Reconcile( imported.get(), std::move( defs ), cacheNick, {} );
242 std::set<wxString> seen;
243 int expectedComponents = 0;
245 for(
FOOTPRINT* fp : imported->Footprints() )
247 LIB_ID fpid = fp->GetFPID();
252 wxString ref = wxString::Format( wxS(
"U%d" ), ++expectedComponents );
257 BOOST_REQUIRE_GT( expectedComponents, 0 );
260 std::unique_ptr<BOARD> target = std::make_unique<BOARD>();
261 target->SetProject( &
project );
264 toolMgr.
SetEnvironment( target.get(),
nullptr,
nullptr,
nullptr,
nullptr );
277 "Netlist updater reported a footprint not found after reconciliation" );
278 BOOST_CHECK_EQUAL(
static_cast<int>( target->Footprints().size() ), expectedComponents );
Update the BOARD with a new netlist.
void SetReporter(REPORTER *aReporter)
Enable dry run mode (just report, no changes to PCB).
bool UpdateNetlist(NETLIST &aNetlist)
Update the board's components according to the new netlist.
void SetDeleteUnusedFootprints(bool aEnabled)
int GetErrorCount() const
void SetReplaceFootprints(bool aEnabled)
std::optional< LIBRARY_TABLE * > ProjectTable() const
Retrieves the project library table for this adapter type, or nullopt if one doesn't exist.
void LoadProjectTables(std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={})
(Re)loads the project library tables in the given list, or all tables if no list is given
bool HasRow(const wxString &aNickname) const
A logical library item identifier and consists of various portions much like a URI.
wxString GetUniStringLibId() const
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
Works with Eagle 6.x XML board files and footprints to implement the Pcbnew #PLUGIN API or a portion ...
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
virtual SETTINGS_MANAGER & GetSettingsManager() const
virtual LIBRARY_MANAGER & GetLibraryManager() const
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
Container for project specific data.
virtual const wxString GetProjectPath() const
Return the full path of the project.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
A wrapper for reporting to a wxString object.
static const std::string KiCadFootprintLibPathExtension
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
PGM_BASE & Pgm()
The global program "get" accessor.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
IbisParser parser & reporter
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")