| 12635 | return !!m_generator; |
| 12636 | } |
| 12637 | void close() override { |
| 12638 | TrackerBase::close(); |
| 12639 | // If a generator has a child (it is followed by a section) |
| 12640 | // and none of its children have started, then we must wait |
| 12641 | // until later to start consuming its values. |
| 12642 | // This catches cases where `GENERATE` is placed between two |
| 12643 | // `SECTION`s. |
| 12644 | // **The check for m_children.empty cannot be removed**. |
| 12645 | // doing so would break `GENERATE` _not_ followed by `SECTION`s. |
| 12646 | const bool should_wait_for_child = [&]() { |
| 12647 | // No children -> nobody to wait for |
| 12648 | if ( m_children.empty() ) { |
| 12649 | return false; |
| 12650 | } |
| 12651 | // If at least one child started executing, don't wait |
| 12652 | if ( std::find_if( |
| 12653 | m_children.begin(), |
| 12654 | m_children.end(), |
| 12655 | []( TestCaseTracking::ITrackerPtr tracker ) { |
| 12656 | return tracker->hasStarted(); |
| 12657 | } ) != m_children.end() ) { |
| 12658 | return false; |
| 12659 | } |
| 12660 | |
| 12661 | // No children have started. We need to check if they _can_ |
| 12662 | // start, and thus we should wait for them, or they cannot |
| 12663 | // start (due to filters), and we shouldn't wait for them |
| 12664 | auto* parent = m_parent; |
| 12665 | // This is safe: there is always at least one section |
| 12666 | // tracker in a test case tracking tree |
| 12667 | while ( !parent->isSectionTracker() ) { |
| 12668 | parent = &( parent->parent() ); |
| 12669 | } |
| 12670 | assert( parent && |
| 12671 | "Missing root (test case) level section" ); |
| 12672 | |
| 12673 | auto const& parentSection = |
| 12674 | static_cast<SectionTracker&>( *parent ); |
| 12675 | auto const& filters = parentSection.getFilters(); |
| 12676 | // No filters -> no restrictions on running sections |
| 12677 | if ( filters.empty() ) { |
| 12678 | return true; |
| 12679 | } |
| 12680 | |
| 12681 | for ( auto const& child : m_children ) { |
| 12682 | if ( child->isSectionTracker() && |
| 12683 | std::find( filters.begin(), |
| 12684 | filters.end(), |
| 12685 | static_cast<SectionTracker&>( *child ) |
| 12686 | .trimmedName() ) != |
| 12687 | filters.end() ) { |
| 12688 | return true; |
| 12689 | } |
| 12690 | } |
| 12691 | return false; |
| 12692 | }(); |
| 12693 | |
| 12694 | // This check is a bit tricky, because m_generator->next() |
nothing calls this directly
no test coverage detected