catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Faster selection of tests to run
- Commit
ab13a28d125b50a458667e972ed56400af7ad931- Author
- Martin Hořeňovský ·
- Parents
ed393f09c729
Changes
src/catch2/catch_session.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp index 503da14f..78cb5a06 100644 --- a/src/catch2/catch_session.cpp +++ b/src/catch2/catch_session.cpp @@ -31,7 +31,6 @@ #include <cstdlib> #include <exception> #include <iomanip> -#include <set> namespace Catch { @@ -86,21 +85,29 @@ namespace Catch { assert( m_config->testSpec().getInvalidSpecs().empty() && "Invalid test specs should be handled before running tests" ); + // Note that we are working with pointers into this vector + // of sorted test cases, so sorting/unique-ing the pointers + // keeps the user-specified order. auto const& allTestCases = getAllTestCasesSorted(*m_config); auto const& testSpec = m_config->testSpec(); + m_tests.reserve( allTestCases.size() ); if ( !testSpec.hasFilters() ) { for ( auto const& test : allTestCases ) { if ( !test.getTestCaseInfo().isHidden() ) { - m_tests.emplace( &test ); + m_tests.push_back( &test ); } } } else { - m_matches = - testSpec.matchesByFilter( allTestCases, *m_config ); + m_matches = testSpec.matchesByFilter( allTestCases, *m_config ); for ( auto const& match : m_matches ) { - m_tests.insert( match.tests.begin(), + m_tests.insert( m_tests.end(), + match.tests.begin(), match.tests.end() ); } + std::sort( m_tests.begin(), m_tests.end() ); + m_tests.erase( + std::unique( m_tests.begin(), m_tests.end() ), + m_tests.end() ); } m_tests = createShard(CATCH_MOVE(m_tests), m_config->shardCount(), m_config->shardIndex()); @@ -134,7 +141,7 @@ namespace Catch { IEventListener* m_reporter; Config const* m_config; RunContext m_context; - std::set<TestCaseHandle const*> m_tests; + std::vector<TestCaseHandle const*> m_tests; TestSpec::Matches m_matches; bool m_unmatchedTestSpecs = false; };