@@ -196,6 +196,8 @@ namespace Catch {
196196 auto getGenerator () const -> GeneratorBasePtr const & override {
197197 return m_generator;
198198 }
199+
200+ bool isFilteredImpl () const override { return m_isFiltered; }
199201 };
200202 } // namespace
201203 }
@@ -540,17 +542,6 @@ namespace Catch {
540542 SourceLineInfo lineInfo,
541543 Generators::GeneratorBasePtr&& generator ) {
542544
543- // TBD: Do we want to avoid the warning if the generator is filtered?
544- if ( m_config->warnAboutInfiniteGenerators () &&
545- !generator->isFinite () ) {
546- // We want the semantics of `FAIL()`, but we inline it
547- // to avoid issues with conditionally prefixed macros
548- INTERNAL_CATCH_MSG ( " FAIL" ,
549- Catch::ResultWas::ExplicitFailure,
550- Catch::ResultDisposition::Normal,
551- " GENERATE() would run infinitely" );
552- }
553-
554545 auto nameAndLoc = TestCaseTracking::NameAndLocation ( static_cast <std::string>( generatorName ), lineInfo );
555546 auto & currentTracker = m_trackerContext.currentTracker ();
556547 assert (
@@ -563,11 +554,24 @@ namespace Catch {
563554 m_trackerContext,
564555 ¤tTracker,
565556 CATCH_MOVE ( generator ) );
566- auto ret = newTracker.get ();
557+
558+ // The warning shouldn't fire if the generator is infinite, **but** filtered down.
559+ if ( m_config->warnAboutInfiniteGenerators () &&
560+ !newTracker->m_generator ->isFinite () &&
561+ !newTracker->isFiltered () ) {
562+ // We want the semantics of `FAIL()`, but we inline it
563+ // to avoid issues with conditionally prefixed macros
564+ INTERNAL_CATCH_MSG ( " FAIL" ,
565+ Catch::ResultWas::ExplicitFailure,
566+ Catch::ResultDisposition::Normal,
567+ " GENERATE() would run infinitely" );
568+ }
569+
570+ auto returnPtr = newTracker.get ();
567571 currentTracker.addChild ( CATCH_MOVE ( newTracker ) );
568572
569- ret ->open ();
570- return ret ;
573+ returnPtr ->open ();
574+ return returnPtr ;
571575 }
572576
573577 bool RunContext::testForMissingAssertions (Counts& assertions) {
0 commit comments