25#include <boost/test/unit_test.hpp>
36namespace fs = std::filesystem;
47 std::ifstream stream( aFeaturesFile );
50 while( std::getline( stream, line ) )
52 if( line.rfind(
"S ", 0 ) == 0 )
77 for(
const fs::directory_entry& entry : fs::recursive_directory_iterator( aRoot ) )
79 if( !entry.is_regular_file() || entry.path().filename() !=
"features" )
82 const std::string layerDir = entry.path().parent_path().filename().string();
84 if( layerDir.find(
"mask" ) == std::string::npos )
105 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
122 addEdge( { 0, 0 }, { side, 0 } );
123 addEdge( { side, 0 }, { side, side } );
124 addEdge( { side, side }, { 0, side } );
125 addEdge( { 0, side }, { 0, 0 } );
131 fp->SetReference( wxT(
"U1" ) );
144 "Test shape is not reported on F_Mask; SetHasSolderMask had no effect" );
149 const fs::path outDir =
150 fs::temp_directory_path() / (
"kicad_qa_odb_soldermask_24690_" +
KIID().
AsString().ToStdString() );
155 std::map<std::string, UTF8> props;
156 props[
"units"] =
"mm";
157 props[
"sigfig"] =
"6";
159 BOOST_REQUIRE_NO_THROW( odbExporter.
SaveBoard( outDir.string(), board.get(), &props ) );
161 BOOST_REQUIRE_MESSAGE( fs::exists( outDir ),
"ODB++ export produced no output tree" );
163 bool foundMask =
false;
166 BOOST_REQUIRE_MESSAGE( foundMask,
"ODB++ export produced no solder-mask features file" );
168 BOOST_CHECK_MESSAGE( surfaceCount > 0,
"Mask-flagged shape was dropped from the ODB++ export "
169 "(no surface features on the solder-mask layer)" );
171 fs::remove_all( outDir );
constexpr EDA_IU_SCALE pcbIUScale
virtual void SetFilled(bool aFlag)
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
wxString AsString() const
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
void SetWidth(int aWidth) override
void SetHasSolderMask(bool aVal)
void SetEnd(const VECTOR2I &aEnd) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetStart(const VECTOR2I &aStart) override
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_CASE(OdbSolderMaskShapeExport)
Regression guard for GitLab #24690: a footprint polygon on a copper layer with the "Solder mask" flag...
static int countOdbSurfaceRecords(const fs::path &aFeaturesFile)
Count surface ("S ") feature records in a single ODB++ "features" file.
static int countMaskSurfaceRecords(const fs::path &aRoot, bool &aFoundFile)
Sum surface ("S ") feature records across every solder-mask "features" file in an ODB++ tree.
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
VECTOR2< int32_t > VECTOR2I