CLI: make ERC report include violations with the expected severities
the ERC report creates its own SHEETLIST_ERC_ITEMS_PROVIDER and
hard-codes warnings and errors as wanted severities, regardless
of the --severity-* options given through the CLI.
we keep the marker provider optional and create a fallback instance for
tests code that expects reports with warnings and errors.
(cherry picked from commit 24dec03ba5)
This commit is contained in:
committed by
Wayne Stambaugh
parent
f4b3366b30
commit
662b7daf00
@@ -1197,7 +1197,7 @@ int EESCHEMA_JOBS_HANDLER::JobSchErc( JOB* aJob )
|
||||
markersProvider->GetCount() ),
|
||||
RPT_SEVERITY_INFO );
|
||||
|
||||
ERC_REPORT reportWriter( sch, units );
|
||||
ERC_REPORT reportWriter( sch, units, markersProvider );
|
||||
|
||||
bool wroteReport = false;
|
||||
|
||||
|
||||
+15
-12
@@ -34,10 +34,19 @@
|
||||
#include <rc_json_schema.h>
|
||||
|
||||
|
||||
ERC_REPORT::ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits ) :
|
||||
ERC_REPORT::ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits,
|
||||
std::shared_ptr<RC_ITEMS_PROVIDER> aMarkersProvider ) :
|
||||
m_sch( aSchematic ),
|
||||
m_reportUnits( aReportUnits )
|
||||
m_reportUnits( aReportUnits ),
|
||||
m_markersProvider( std::move( aMarkersProvider ) )
|
||||
{
|
||||
if( !m_markersProvider )
|
||||
{
|
||||
// When no provider is supplied, fall back to creating one with default severities.
|
||||
// This allows test code to get a basic report without needing to set up a provider.
|
||||
m_markersProvider = std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( m_sch );
|
||||
m_markersProvider->SetSeverities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,14 +68,11 @@ wxString ERC_REPORT::GetTextReport()
|
||||
|
||||
ERC_SETTINGS& settings = m_sch->ErcSettings();
|
||||
|
||||
SHEETLIST_ERC_ITEMS_PROVIDER errors( m_sch );
|
||||
errors.SetSeverities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING );
|
||||
|
||||
std::map<SCH_SHEET_PATH, std::vector<ERC_ITEM*>> orderedItems;
|
||||
|
||||
for( int i = 0; i < errors.GetCount(); ++i )
|
||||
for( int i = 0; i < m_markersProvider->GetCount(); ++i )
|
||||
{
|
||||
if( auto item = dynamic_cast<ERC_ITEM*>( errors.GetItem( i ).get() ) )
|
||||
if( auto item = dynamic_cast<ERC_ITEM*>( m_markersProvider->GetItem( i ).get() ) )
|
||||
{
|
||||
if( item->MainItemHasSheetPath() )
|
||||
orderedItems[item->GetMainItemSheetPath()].emplace_back( item );
|
||||
@@ -137,14 +143,11 @@ bool ERC_REPORT::WriteJsonReport( const wxString& aFullFileName )
|
||||
|
||||
ERC_SETTINGS& settings = m_sch->ErcSettings();
|
||||
|
||||
SHEETLIST_ERC_ITEMS_PROVIDER errors( m_sch );
|
||||
errors.SetSeverities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING );
|
||||
|
||||
std::map<SCH_SHEET_PATH, std::vector<ERC_ITEM*>> orderedItems;
|
||||
|
||||
for( int i = 0; i < errors.GetCount(); ++i )
|
||||
for( int i = 0; i < m_markersProvider->GetCount(); ++i )
|
||||
{
|
||||
if( auto item = dynamic_cast<ERC_ITEM*>( errors.GetItem( i ).get() ) )
|
||||
if( auto item = dynamic_cast<ERC_ITEM*>( m_markersProvider->GetItem( i ).get() ) )
|
||||
{
|
||||
if( item->MainItemHasSheetPath() )
|
||||
orderedItems[item->GetMainItemSheetPath()].emplace_back( item );
|
||||
|
||||
@@ -30,7 +30,8 @@ class RC_ITEMS_PROVIDER;
|
||||
class ERC_REPORT
|
||||
{
|
||||
public:
|
||||
ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits );
|
||||
ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits,
|
||||
std::shared_ptr<RC_ITEMS_PROVIDER> aMarkersProvider = nullptr );
|
||||
|
||||
/**
|
||||
* Returns the ERC report in "text" (human readable) format
|
||||
@@ -56,6 +57,7 @@ public:
|
||||
private:
|
||||
SCHEMATIC* m_sch;
|
||||
EDA_UNITS m_reportUnits;
|
||||
std::shared_ptr<RC_ITEMS_PROVIDER> m_markersProvider;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user