89 BOOST_REQUIRE_MESSAGE( std::filesystem::exists( sourceBoard ),
"Missing test board " << sourceBoard );
94 const size_t originalCount = board->Footprints().size();
95 BOOST_REQUIRE_MESSAGE( originalCount > 1,
"Panel board needs multiple footprints to delete" );
99 const SCOPED_TEMP_DIR workDir( wxS(
"kicad_step_export_23704_" ) );
100 const std::filesystem::path onDisk = workDir.Path() /
"panel.kicad_pcb";
102 const wxString onDiskPath = wxString::FromUTF8( onDisk.string() );
106 std::filesystem::path projectFile = onDisk;
107 projectFile.replace_extension(
".kicad_pro" );
110 std::ofstream
project( projectFile );
112 project <<
"{ \"meta\": { \"version\": 1 } }\n";
116 while( board->Footprints().size() > 1 )
117 board->Remove( board->Footprints().back() );
119 const size_t remainingCount = board->Footprints().size();
120 BOOST_REQUIRE_EQUAL( remainingCount, 1u );
124 std::vector<wxString> tempFiles;
125 wxString errorDetail;
126 const wxString error =
129 BOOST_REQUIRE_MESSAGE( error.IsEmpty(),
"StageBoardForExport failed: " << error.ToStdString() );
131 BOOST_CHECK_MESSAGE( inputPath != onDiskPath,
"Modified board must stage a temporary copy, not the on-disk file" );
140 std::filesystem::path stagedProject = std::filesystem::path( std::string( inputPath.utf8_str() ) );
141 stagedProject.replace_extension(
".kicad_pro" );
142 BOOST_CHECK( std::filesystem::exists( stagedProject ) );
143 BOOST_CHECK_EQUAL( std::filesystem::file_size( stagedProject ), std::filesystem::file_size( projectFile ) );
150 for(
const wxString& f : tempFiles )
152 if( wxFileExists( f ) )
168 const wxString onDiskPath = wxString::FromUTF8( sourceBoard );
171 std::vector<wxString> tempFiles;
172 wxString errorDetail;
174 tempFiles, errorDetail );
176 BOOST_CHECK( error.IsEmpty() );
178 BOOST_CHECK( tempFiles.empty() );
193 std::vector<wxString> tempFiles;
194 wxString errorDetail;
196 tempFiles, errorDetail );
198 BOOST_CHECK( !error.IsEmpty() );
199 BOOST_CHECK( inputPath.IsEmpty() );
200 BOOST_CHECK( tempFiles.empty() );
static wxString StageBoardForExport(const wxString &aBoardPath, bool aContentModified, BOARD *aBoard, wxString &aInputPath, std::vector< wxString > &aTempFiles, wxString &aErrorDetail)
Resolve the board file to hand to the external 3D/STEP exporter.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
BOOST_CHECK_EQUAL(result, "25.4")