Function close

Synopsis

#include <include/internal/catch_run_context.cpp>

void close() override

Description

No description yet.

Source

Lines 65-92 in include/internal/catch_run_context.cpp.

void close() override {
    TrackerBase::close();
    // If a generator has a child (it is followed by a section)
    // and none of its children have started, then we must wait
    // until later to start consuming its values.
    // This catches cases where `GENERATE` is placed between two
    // `SECTION`s.
    // **The check for m_children.empty cannot be removed**.
    // doing so would break `GENERATE` _not_ followed by `SECTION`s.
    const bool should_wait_for_child =
        !m_children.empty() &&
        std::find_if( m_children.begin(),
                      m_children.end(),
                      []( TestCaseTracking::ITrackerPtr tracker ) {
                          return tracker->hasStarted();
                      } ) == m_children.end();
    // This check is a bit tricky, because m_generator->next()
    // has a side-effect, where it consumes generator's current
    // value, but we do not want to invoke the side-effect if
    // this generator is still waiting for any child to start.
    if ( should_wait_for_child ||
         ( m_runState == CompletedSuccessfully &&
           m_generator->next() ) ) {
        m_children.clear();
        m_runState = Executing;
    }
}





Add Discussion as Guest

Log in