KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_erc_footprint_filters.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one at
18 * http://www.gnu.org/licenses/
19 */
20
23
24#include <schematic.h>
25#include <sch_marker.h>
26#include <sch_screen.h>
27#include <sch_sheet_path.h>
28#include <erc/erc.h>
29#include <erc/erc_settings.h>
31#include <locale_io.h>
32
33
42
43
44// Regression test for https://gitlab.com/kicad/code/kicad/-/issues/24037
45//
46// TestFootprintFilters() previously created markers with the
47// ERCE_FOOTPRINT_LINK_ISSUES error code instead of ERCE_FOOTPRINT_FILTERS.
48// As a consequence, ignoring the "Assigned footprint doesn't match footprint
49// filters" violation in the ERC settings had no effect: the filter check
50// kept producing markers tagged as link issues, leaving a red error marker
51// on the canvas even though the violations counter showed zero.
52BOOST_FIXTURE_TEST_CASE( ERCFootprintFiltersUsesCorrectErrorCode,
54{
56
57 KI_TEST::LoadSchematic( m_settingsManager, "issue24037/issue24037", m_schematic );
58
59 ERC_SETTINGS& settings = m_schematic->ErcSettings();
62
63 ERC_TESTER tester( m_schematic.get() );
64 tester.TestFootprintFilters();
65
66 SHEETLIST_ERC_ITEMS_PROVIDER provider( m_schematic.get() );
68
69 BOOST_REQUIRE_EQUAL( provider.GetCount(), 1 );
70
71 std::shared_ptr<ERC_ITEM> item = provider.GetERCItem( 0 );
72 BOOST_CHECK_EQUAL( item->GetErrorCode(), ERCE_FOOTPRINT_FILTERS );
73
74 // With ERCE_FOOTPRINT_FILTERS set to IGNORE, the marker raised by
75 // TestFootprintFilters() must be filtered out of the visible-error set
76 // (and counted under the IGNORE bucket instead). The bug was that the
77 // marker was tagged ERCE_FOOTPRINT_LINK_ISSUES, so changing the
78 // ERCE_FOOTPRINT_FILTERS severity had no effect on it.
79 SCH_SCREENS screens( m_schematic->Root() );
81
83
84 tester.TestFootprintFilters();
85
86 SHEETLIST_ERC_ITEMS_PROVIDER visible( m_schematic.get() );
88 BOOST_CHECK_EQUAL( visible.GetCount(), 0 );
89
90 SHEETLIST_ERC_ITEMS_PROVIDER ignored( m_schematic.get() );
92 BOOST_CHECK_EQUAL( ignored.GetCount(), 1 );
93
94 // The marker for an IGNORE-severity violation must not request any render
95 // layers, otherwise it repaints as a red error even though it is ignored.
96 for( const SCH_SHEET_PATH& path : m_schematic->Hierarchy() )
97 {
98 for( SCH_ITEM* item : path.LastScreen()->Items().OfType( SCH_MARKER_T ) )
99 BOOST_CHECK( static_cast<SCH_MARKER*>( item )->ViewGetLayers().empty() );
100 }
101}
Container for ERC settings.
std::map< int, SEVERITY > m_ERCSeverities
int TestFootprintFilters()
Test symbols to ensure that assigned footprint passes any given footprint filters.
Definition erc.cpp:2274
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:746
void DeleteAllMarkers(enum MARKER_BASE::MARKER_T aMarkerType, bool aIncludeExclusions)
Delete all electronic rules check markers of aMarkerType from all the screens in the list.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contra...
int GetCount(int aSeverity=-1) const override
void SetSeverities(int aSeverities) override
std::shared_ptr< ERC_ITEM > GetERCItem(int aIndex) const
static bool empty(const wxTextEntryBase *aCtrl)
@ ERCE_FOOTPRINT_LINK_ISSUES
The footprint link is invalid, or points to a missing (or inactive) footprint or library.
@ ERCE_FOOTPRINT_FILTERS
The assigned footprint doesn't match the footprint filters.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_IGNORE
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< FAB_LAYER_COLOR > dummy
std::unique_ptr< SCHEMATIC > m_schematic
BOOST_FIXTURE_TEST_CASE(ERCFootprintFiltersUsesCorrectErrorCode, ERC_FOOTPRINT_FILTERS_FIXTURE)
std::string path
BOOST_CHECK_EQUAL(result, "25.4")
@ SCH_MARKER_T
Definition typeinfo.h:155