72 for(
bool useEngine : {
false,
true } )
80 RefreshTextChecks(
true );
99 int genericErrors = 0;
100 int genericWarnings = 0;
101 int unresolvedVars = 0;
102 std::vector<wxString> errorMessages;
103 std::vector<wxString> warningMessages;
105 for(
int ii = 0; ii < errors.
GetCount(); ++ii )
107 std::shared_ptr<RC_ITEM> rc = errors.
GetItem( ii );
112 errorMessages.push_back( rc->GetErrorMessage(
false ) );
117 warningMessages.push_back( rc->GetErrorMessage(
false ) );
137 [](
const std::vector<wxString>& aList,
const wxString& aNeedle )
139 for(
const wxString& msg : aList )
141 if( msg.Contains( aNeedle ) )
148 BOOST_CHECK( containsMsg( errorMessages,
"start_of_text" ) );
149 BOOST_CHECK( containsMsg( errorMessages,
"placeholder_text" ) );
150 BOOST_CHECK( containsMsg( warningMessages,
"this_is_warning" ) );
151 BOOST_CHECK( containsMsg( warningMessages,
"embedded_warning" ) );
152 BOOST_CHECK( !containsMsg( errorMessages,
"not_a_real_error" ) );
164 std::vector<SCH_SHEET_PATH> paths;
168 if(
path.LastScreen()->GetFileName().EndsWith(
"ampli_ht.kicad_sch" ) )
169 paths.push_back(
path );
172 BOOST_REQUIRE_EQUAL( paths.size(), 2u );
184 const wxString
name(
"Capture assertion" );
193 std::map<KIID_PATH, std::tuple<KIID, int, wxString, VECTOR2I>> found;
194 std::vector<SCH_MARKER*> markers;
198 auto* marker =
static_cast<SCH_MARKER*
>( item );
199 const auto error = std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() );
201 if( error->GetMainItemID() == field->
m_Uuid || error->GetMainItemID() == symbol->
m_Uuid )
204 BOOST_CHECK( error->MainItemHasSheetPath() );
206 if( error->MainItemHasSheetPath() )
207 BOOST_CHECK( error->GetMainItemSheetPath().PathRef() == error->GetSpecificSheetPath().PathRef() );
209 BOOST_CHECK( found.emplace( error->GetSpecificSheetPath().PathRef(),
210 std::make_tuple( error->GetMainItemID(), error->GetErrorCode(),
211 error->GetErrorMessage(
false ), marker->GetPosition() ) ).second );
214 markers.push_back( marker );
223 for(
int change = 0; change < 2; ++change )
227 field->
SetText(
"${ERC_WARNING Captured}" );
229 RefreshTextChecks(
true );
230 const auto before = collect();
231 BOOST_REQUIRE_EQUAL( before.size(), 2u );
236 BOOST_CHECK( std::get<0>( before.at(
path.PathRef() ) ) == field->
m_Uuid );
238 m_schematic->SetCurrentSheet(
path );
239 BOOST_CHECK( collect() == before );
243 field->
SetText(
"${ConnectivityCaptureMissingVariable}" );
248 RefreshTextChecks(
false );
249 const auto after = collect();
250 BOOST_REQUIRE_EQUAL( after.size(), 2u );
255 const auto& error = after.at(
path.PathRef() );
256 BOOST_CHECK( std::get<0>( error ) == ( change == 0 ? symbol->
m_Uuid : field->
m_Uuid ) );
259 BOOST_CHECK( std::get<3>( error ) == field->
GetPosition() );
262 BOOST_CHECK( after != before );
263 RefreshTextChecks(
true );
264 BOOST_CHECK( collect() == after );
266 RefreshTextChecks(
true );
267 BOOST_CHECK( collect() == after );
272 auto targetMarkers = [&]()
274 std::vector<SCH_MARKER*>
result;
278 auto* marker =
static_cast<SCH_MARKER*
>( item );
279 const KIID& owner = marker->GetRCItem()->GetMainItemID();
282 result.push_back( marker );
287 auto& exclusions = m_schematic->ErcSettings().m_ErcExclusions;
289 for(
const wxString& raw : { wxString(
"${ERC_WARNING Captured}" ), wxString(
"${ERC_ERROR Captured}" ),
290 wxString(
"${ConnectivityCaptureMissingVariable}" ) } )
294 for(
int format : { 0, 1, 2 } )
298 const bool legacyString = format == 2;
299 auto& legacyExclusions = m_schematic->ErcSettings().m_ErcExclusionsLegacy;
301 legacyExclusions.clear();
303 RefreshTextChecks(
true );
306 BOOST_REQUIRE_EQUAL( targetMarkers().size(), 2u );
310 const auto error = std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() );
313 if( error->GetSpecificSheetPath().PathRef() != paths[0].PathRef() )
316 error->SetItemsSheetPaths( paths[0] );
320 proto.mutable_marker()->clear_main_item_sheet_path();
323 exclusion.SetComment(
"Retained text exclusion" );
327 BOOST_REQUIRE_GT( proto.marker().items_size(), 0 );
328 const wxString data = wxString::Format( wxS(
"%s|%d|%d|%s|%s|%s|%s|" ),
329 error->GetSettingsKey(), marker->GetPosition().x, marker->GetPosition().y,
330 wxString::FromUTF8( proto.marker().items( 0 ).value() ),
331 proto.marker().has_child()
332 ? wxString::FromUTF8( proto.marker().child().text_value() )
334 error->GetSpecificSheetPath().PathRef().AsString(),
335 error->GetMainItemSheetPath().PathRef().AsString() );
336 legacyExclusions.emplace( data, exclusion.GetComment() );
340 const nlohmann::json saved = exclusion;
345 BOOST_REQUIRE_EQUAL( exclusions.size(), legacyString ? 0u : 1u );
346 BOOST_REQUIRE_EQUAL( legacyExclusions.size(), legacyString ? 1u : 0u );
347 const auto savedExclusions = exclusions;
348 const auto savedLegacyExclusions = legacyExclusions;
353 for(
bool backend : {
true,
false } )
358 exclusions = savedExclusions;
359 legacyExclusions = savedLegacyExclusions;
360 RefreshTextChecks(
true );
363 m_schematic->ResolveERCExclusionsPostUpdate();
364 BOOST_CHECK( legacyExclusions.empty() );
366 BOOST_REQUIRE_EQUAL( targetMarkers().size(), 2u );
371 const auto error = std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() );
372 const bool expected = error->GetSpecificSheetPath().PathRef() == paths[0].PathRef();
375 if( marker->IsExcluded() )
378 BOOST_CHECK_EQUAL( marker->GetComment(), wxString(
"Retained text exclusion" ) );
391 for(
bool backend : {
true,
false } )
396 field->
SetText(
"${ERC_WARNING Retained shared field}" );
397 m_schematic->SetCurrentSheet( m_schematic->Hierarchy().front() );
398 RefreshTextChecks(
true );
399 const auto before = collect();
400 BOOST_REQUIRE_EQUAL( before.size(), 2u );
406 std::unique_ptr<SCH_SHEET> undoOwnedSheet( removed );
407 m_schematic->RefreshHierarchy();
409 expected.erase( paths[0].PathRef() );
410 BOOST_REQUIRE_EQUAL(
expected.size(), 1u );
411 BOOST_CHECK( collect() ==
expected );
414 RefreshTextChecks(
false );
416 RefreshTextChecks(
true );
418 BOOST_CHECK( collect() ==
expected );
419 RefreshTextChecks(
true );
420 BOOST_CHECK( collect() ==
expected );
422 m_schematic->RefreshHierarchy();
425 RefreshTextChecks(
false );
427 RefreshTextChecks(
true );
429 BOOST_CHECK( collect() == before );
430 RefreshTextChecks(
true );
431 BOOST_CHECK( collect() == before );
BOOST_CHECK_EQUAL(result, "25.4")