diff options
| author | Martin Hořeňovský | 2026-08-22 23:28:11 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2026-08-22 23:28:11 +0200 |
| commit | ef3a728265292e6a1dbec727b0099d3d8b3f6420 (patch) | |
| tree | 7c2ddb997a6a1fdbd1ad25edc18966ee63ebd4dd /src/catch2/interfaces | |
| parent | 69da66ee7370d7c249ba6f2a322a78dcdd623761 (diff) | |
| download | catch3-ef3a728265292e6a1dbec727b0099d3d8b3f6420.tar.gz | |
Don't store extra copy of all `TestCaseInfo*` in `TestRegistry`
We used to store a full vector of "views" of the registered test infos,
so that it can be retrieved externally. However, the only user of that
interface left was `Session`, specifically `Session::applyFilenameAsTags`.
By moving the adding of the filename tags into the `ITestCaseRegistry`
interface, we avoid storing the vector and make the initial test registration
faster.
The new code is ugly and shows a design/layering issue, but no worse than
the previous approach did.
Diffstat (limited to 'src/catch2/interfaces')
| -rw-r--r-- | src/catch2/interfaces/catch_interfaces_registry_hub.hpp | 2 | ||||
| -rw-r--r-- | src/catch2/interfaces/catch_interfaces_testcase.hpp | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp index 3695a192..072b48bf 100644 --- a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp +++ b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp @@ -53,6 +53,8 @@ namespace Catch { virtual void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) = 0; virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; virtual void registerStartupException() noexcept = 0; + + virtual ITestCaseRegistry& getMutableTestCaseRegistry() = 0; }; IRegistryHub const& getRegistryHub(); diff --git a/src/catch2/interfaces/catch_interfaces_testcase.hpp b/src/catch2/interfaces/catch_interfaces_testcase.hpp index daee8482..67c4371a 100644 --- a/src/catch2/interfaces/catch_interfaces_testcase.hpp +++ b/src/catch2/interfaces/catch_interfaces_testcase.hpp @@ -19,8 +19,7 @@ namespace Catch { class ITestCaseRegistry { public: virtual ~ITestCaseRegistry(); // = default - // TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later - virtual std::vector<TestCaseInfo* > const& getAllInfos() const = 0; + virtual void enableFilenameTags() = 0; virtual std::vector<TestCaseHandle> const& getAllTests() const = 0; virtual std::vector<TestCaseHandle> const& getAllTestsSorted( IConfig const& config ) const = 0; }; |