Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_session.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-11-04 21:35:57 +0100
committerMartin Hořeňovský2019-11-14 10:52:34 +0100
commit302e2c0b06f131199b97ad33bdebacc359782ff0 (patch)
tree26e80b38b48739573de4225e789096ec83c79357 /include/internal/catch_session.cpp
parent019b0a0fe0398a5b73937b9a1901b3dfaecac386 (diff)
downloadcatch3-302e2c0b06f131199b97ad33bdebacc359782ff0.tar.gz
Do not copy around TestCaseInfo
Now a `TEST_CASE` macro should create a single TestCaseInfo and then it should never be copied around. This, together with latter changes, should significantly decrease the number of allocations made before `main` is even entered.
Diffstat (limited to 'include/internal/catch_session.cpp')
-rw-r--r--include/internal/catch_session.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/include/internal/catch_session.cpp b/include/internal/catch_session.cpp
index dd3dc241..87b52d44 100644
--- a/include/internal/catch_session.cpp
+++ b/include/internal/catch_session.cpp
@@ -72,7 +72,7 @@ namespace Catch {
if (m_matches.empty() && invalidArgs.empty()) {
for (auto const& test : allTestCases)
- if (!test.isHidden())
+ if (!test.getTestCaseInfo().isHidden())
m_tests.emplace(&test);
} else {
for (auto const& match : m_matches)
@@ -88,7 +88,7 @@ namespace Catch {
if (!m_context.aborting())
totals += m_context.runTest(*testCase);
else
- m_context.reporter().skipTest(*testCase);
+ m_context.reporter().skipTest(testCase->getTestCaseInfo());
}
for (auto const& match : m_matches) {
@@ -108,7 +108,7 @@ namespace Catch {
}
private:
- using Tests = std::set<TestCase const*>;
+ using Tests = std::set<TestCaseHandle const*>;
std::shared_ptr<Config> m_config;
RunContext m_context;
@@ -117,11 +117,11 @@ namespace Catch {
};
void applyFilenamesAsTags(Catch::IConfig const& config) {
- auto& tests = const_cast<std::vector<TestCase>&>(getAllTestCasesSorted(config));
- for (auto& testCase : tests) {
- auto tags = testCase.tags;
+ for (auto const& testCase : getAllTestCasesSorted(config)) {
+ // Yeah, sue me. This will be removed soon.
+ auto& testInfo = const_cast<TestCaseInfo&>(testCase.getTestCaseInfo());
- std::string filename = testCase.lineInfo.file;
+ std::string filename = testInfo.lineInfo.file;
auto lastSlash = filename.find_last_of("\\/");
if (lastSlash != std::string::npos) {
filename.erase(0, lastSlash);
@@ -133,8 +133,9 @@ namespace Catch {
filename.erase(lastDot);
}
+ auto tags = testInfo.tags;
tags.push_back(std::move(filename));
- setTags(testCase, tags);
+ setTags(testInfo, tags);
}
}