From 458241cc90b71de453fb40bfeed9ccce20d45ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 19 May 2020 17:29:24 +0200 Subject: [PATCH] Do not use shared_ptr when listing things --- src/catch2/catch_session.cpp | 5 ++++- src/catch2/internal/catch_list.cpp | 15 +++++++-------- src/catch2/internal/catch_list.hpp | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp index 66dd7186..c3bf898b 100644 --- a/src/catch2/catch_session.cpp +++ b/src/catch2/catch_session.cpp @@ -273,11 +273,14 @@ namespace Catch { applyFilenamesAsTags(); } + // Set up global config instance before we start calling into other functions + getCurrentMutableContext().setConfig(m_config); + // Create reporter(s) so we can route listings through them auto reporter = makeReporter(m_config.get()); // Handle list request - if (list(*reporter, m_config)) { + if (list(*reporter, *m_config)) { return 0; } diff --git a/src/catch2/internal/catch_list.cpp b/src/catch2/internal/catch_list.cpp index 11fb8150..b654c4c1 100644 --- a/src/catch2/internal/catch_list.cpp +++ b/src/catch2/internal/catch_list.cpp @@ -90,20 +90,19 @@ namespace Catch { return out; } - bool list( IStreamingReporter& reporter, std::shared_ptr const& config ) { + bool list( IStreamingReporter& reporter, Config const& config ) { bool listed = false; - getCurrentMutableContext().setConfig( config ); - if (config->listTests()) { + if (config.listTests()) { listed = true; - listTests(reporter, *config); + listTests(reporter, config); } - if (config->listTags()) { + if (config.listTags()) { listed = true; - listTags(reporter, *config); + listTags(reporter, config); } - if (config->listReporters()) { + if (config.listReporters()) { listed = true; - listReporters(reporter, *config); + listReporters(reporter, config); } return listed; } diff --git a/src/catch2/internal/catch_list.hpp b/src/catch2/internal/catch_list.hpp index 88e4c2c8..638f05b0 100644 --- a/src/catch2/internal/catch_list.hpp +++ b/src/catch2/internal/catch_list.hpp @@ -31,7 +31,7 @@ namespace Catch { std::size_t count = 0; }; - bool list( IStreamingReporter& reporter, std::shared_ptr const& config ); + bool list( IStreamingReporter& reporter, Config const& config ); } // end namespace Catch