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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-09-07 21:17:24 +0200
committerMartin Hořeňovský2021-09-07 21:18:48 +0200
commit290c1b60e6c6d9fd4dde1b28959a6d673caad937 (patch)
tree3142f8391fead977a0ad37a24b4127a624d5cf4b /src/catch2
parente5938007f7dab5c9886ca561d09106ee4d7f2301 (diff)
downloadcatch3-290c1b60e6c6d9fd4dde1b28959a6d673caad937.tar.gz
Store singular TestRunNode in CumulativeReporterBase
There can never be more than one, so there is no reason to provide genericity over multiple nodes.
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/reporters/catch_reporter_cumulative_base.cpp5
-rw-r--r--src/catch2/reporters/catch_reporter_cumulative_base.hpp7
-rw-r--r--src/catch2/reporters/catch_reporter_junit.cpp5
-rw-r--r--src/catch2/reporters/catch_reporter_sonarqube.hpp5
4 files changed, 9 insertions, 13 deletions
diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.cpp b/src/catch2/reporters/catch_reporter_cumulative_base.cpp
index e0007030..dd76d1eb 100644
--- a/src/catch2/reporters/catch_reporter_cumulative_base.cpp
+++ b/src/catch2/reporters/catch_reporter_cumulative_base.cpp
@@ -100,8 +100,9 @@ namespace Catch {
void CumulativeReporterBase::testRunEnded( TestRunStats const& testRunStats ) {
- m_testRuns.emplace_back( testRunStats );
- m_testRuns.back().children.swap( m_testCases );
+ assert(!m_testRun && "CumulativeReporterBase assumes there can only be one test run");
+ m_testRun = Detail::make_unique<TestRunNode>( testRunStats );
+ m_testRun->children.swap( m_testCases );
testRunEndedCumulative();
}
diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/src/catch2/reporters/catch_reporter_cumulative_base.hpp
index 34e5e794..7c2ad9ac 100644
--- a/src/catch2/reporters/catch_reporter_cumulative_base.hpp
+++ b/src/catch2/reporters/catch_reporter_cumulative_base.hpp
@@ -73,10 +73,11 @@ namespace Catch {
std::ostream& stream;
// Note: We rely on pointer identity being stable, which is why
- // which is why we store around pointers rather than values.
+ // we store pointers to the nodes rather than the values.
std::vector<Detail::unique_ptr<TestCaseNode>> m_testCases;
-
- std::vector<TestRunNode> m_testRuns;
+ // We need lazy construction here. We should probably refactor it
+ // later, after the events are redone.
+ Detail::unique_ptr<TestRunNode> m_testRun;
Detail::unique_ptr<SectionNode> m_rootSection;
SectionNode* m_deepestSection = nullptr;
diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp
index ba11c55a..e13d374d 100644
--- a/src/catch2/reporters/catch_reporter_junit.cpp
+++ b/src/catch2/reporters/catch_reporter_junit.cpp
@@ -99,10 +99,7 @@ namespace Catch {
void JunitReporter::testRunEndedCumulative() {
const auto suiteTime = suiteTimer.getElapsedSeconds();
- // HACK: There can only be one testRunNode? This needs to be
- // refactored after the group nodes are excised.
- assert(m_testRuns.size() == 1);
- writeRun( m_testRuns.back(), suiteTime );
+ writeRun( *m_testRun, suiteTime );
xml.endElement();
}
diff --git a/src/catch2/reporters/catch_reporter_sonarqube.hpp b/src/catch2/reporters/catch_reporter_sonarqube.hpp
index f48d6406..81544388 100644
--- a/src/catch2/reporters/catch_reporter_sonarqube.hpp
+++ b/src/catch2/reporters/catch_reporter_sonarqube.hpp
@@ -35,10 +35,7 @@ namespace Catch {
void testRunStarting( TestRunInfo const& testRunInfo ) override;
void testRunEndedCumulative() override {
- // HACK: There can only be one testRunNode? This needs to be
- // refactored after the group nodes are excised.
- assert( m_testRuns.size() == 1 );
- writeRun( m_testRuns.back() );
+ writeRun( *m_testRun );
xml.endElement();
}