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

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-04-19 10:32:13 +0200
committerMartin Hořeňovský2022-04-19 10:32:13 +0200
commit17a04f88d90d3687bd561e89dab40e4ba6a55b83 (patch)
tree76ccd8e074c7ed3e63cc7fa34be219cdb8a86627 /src
parent90e69050505ff210ca29e1c9e8feaf598de4fc74 (diff)
downloadcatch3-17a04f88d90d3687bd561e89dab40e4ba6a55b83.tar.gz
Always report rng seed from builtin reporters
Not all reporters use a format that supports this, so TeamCity and Automake reporters still do not report it. The console reporter now reports it even on successful runs, where before it only reported the rng seed in the header, which was showed either for failed run, or for run with `-s`. CLoses #2065
Diffstat (limited to 'src')
-rw-r--r--src/catch2/reporters/catch_reporter_compact.cpp11
-rw-r--r--src/catch2/reporters/catch_reporter_compact.hpp2
-rw-r--r--src/catch2/reporters/catch_reporter_console.cpp16
-rw-r--r--src/catch2/reporters/catch_reporter_console.hpp1
-rw-r--r--src/catch2/reporters/catch_reporter_sonarqube.cpp12
-rw-r--r--src/catch2/reporters/catch_reporter_tap.cpp5
-rw-r--r--src/catch2/reporters/catch_reporter_tap.hpp2
7 files changed, 38 insertions, 11 deletions
diff --git a/src/catch2/reporters/catch_reporter_compact.cpp b/src/catch2/reporters/catch_reporter_compact.cpp
index 1d3d0329..3f036ec5 100644
--- a/src/catch2/reporters/catch_reporter_compact.cpp
+++ b/src/catch2/reporters/catch_reporter_compact.cpp
@@ -7,6 +7,7 @@
// SPDX-License-Identifier: BSL-1.0
#include <catch2/reporters/catch_reporter_compact.hpp>
+#include <catch2/catch_test_spec.hpp>
#include <catch2/reporters/catch_reporter_helpers.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/internal/catch_platform.hpp>
@@ -253,6 +254,16 @@ private:
m_stream << "No test cases matched '" << unmatchedSpec << "'\n";
}
+ void CompactReporter::testRunStarting( TestRunInfo const& ) {
+ if ( m_config->testSpec().hasFilters() ) {
+ m_stream << m_colour->guardColour( Colour::BrightYellow )
+ << "Filters: "
+ << serializeFilters( m_config->getTestsOrTags() )
+ << '\n';
+ }
+ m_stream << "RNG seed: " << m_config->rngSeed() << '\n';
+ }
+
void CompactReporter::assertionEnded( AssertionStats const& _assertionStats ) {
AssertionResult const& result = _assertionStats.assertionResult;
diff --git a/src/catch2/reporters/catch_reporter_compact.hpp b/src/catch2/reporters/catch_reporter_compact.hpp
index 4232138c..6362fc29 100644
--- a/src/catch2/reporters/catch_reporter_compact.hpp
+++ b/src/catch2/reporters/catch_reporter_compact.hpp
@@ -24,6 +24,8 @@ namespace Catch {
void noMatchingTestCases( StringRef unmatchedSpec ) override;
+ void testRunStarting( TestRunInfo const& _testInfo ) override;
+
void assertionEnded(AssertionStats const& _assertionStats) override;
void sectionEnded(SectionStats const& _sectionStats) override;
diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp
index 6b564b15..bb755ed7 100644
--- a/src/catch2/reporters/catch_reporter_console.cpp
+++ b/src/catch2/reporters/catch_reporter_console.cpp
@@ -496,7 +496,11 @@ void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) {
}
void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) {
StreamingReporterBase::testRunStarting(_testInfo);
- printTestFilters();
+ if ( m_config->testSpec().hasFilters() ) {
+ m_stream << m_colour->guardColour( Colour::BrightYellow ) << "Filters: "
+ << serializeFilters( m_config->getTestsOrTags() ) << '\n';
+ }
+ m_stream << "Randomness seeded to: " << m_config->rngSeed() << '\n';
}
void ConsoleReporter::lazyPrint() {
@@ -521,8 +525,7 @@ void ConsoleReporter::lazyPrintRunInfo() {
<< m_colour->guardColour( Colour::SecondaryText )
<< currentTestRunInfo.name << " is a Catch2 v" << libraryVersion()
<< " host application.\n"
- << "Run with -? for options\n\n"
- << "Randomness seeded to: " << m_config->rngSeed() << "\n\n";
+ << "Run with -? for options\n\n";
m_testRunInfoPrinted = true;
}
@@ -701,13 +704,6 @@ void ConsoleReporter::printSummaryDivider() {
m_stream << lineOfChars('-') << '\n';
}
-void ConsoleReporter::printTestFilters() {
- if (m_config->testSpec().hasFilters()) {
- m_stream << m_colour->guardColour( Colour::BrightYellow ) << "Filters: "
- << serializeFilters( m_config->getTestsOrTags() ) << '\n';
- }
-}
-
} // end namespace Catch
#if defined(_MSC_VER)
diff --git a/src/catch2/reporters/catch_reporter_console.hpp b/src/catch2/reporters/catch_reporter_console.hpp
index 12bfc0e2..719dcc44 100644
--- a/src/catch2/reporters/catch_reporter_console.hpp
+++ b/src/catch2/reporters/catch_reporter_console.hpp
@@ -63,7 +63,6 @@ namespace Catch {
void printTotalsDivider(Totals const& totals);
void printSummaryDivider();
- void printTestFilters();
bool m_headerPrinted = false;
bool m_testRunInfoPrinted = false;
diff --git a/src/catch2/reporters/catch_reporter_sonarqube.cpp b/src/catch2/reporters/catch_reporter_sonarqube.cpp
index d45bbfe1..8119c3b8 100644
--- a/src/catch2/reporters/catch_reporter_sonarqube.cpp
+++ b/src/catch2/reporters/catch_reporter_sonarqube.cpp
@@ -9,13 +9,25 @@
#include <catch2/internal/catch_string_manip.hpp>
#include <catch2/catch_test_case_info.hpp>
+#include <catch2/internal/catch_reusable_string_stream.hpp>
+#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <map>
namespace Catch {
+ namespace {
+ std::string createRngSeedString(uint32_t seed) {
+ ReusableStringStream sstr;
+ sstr << "rng-seed=" << seed;
+ return sstr.str();
+ }
+ }
+
void SonarQubeReporter::testRunStarting(TestRunInfo const& testRunInfo) {
CumulativeReporterBase::testRunStarting(testRunInfo);
+
+ xml.writeComment( createRngSeedString( m_config->rngSeed() ) );
xml.startElement("testExecutions");
xml.writeAttribute("version"_sr, '1');
}
diff --git a/src/catch2/reporters/catch_reporter_tap.cpp b/src/catch2/reporters/catch_reporter_tap.cpp
index 71249f87..8ecf3928 100644
--- a/src/catch2/reporters/catch_reporter_tap.cpp
+++ b/src/catch2/reporters/catch_reporter_tap.cpp
@@ -9,6 +9,7 @@
#include <catch2/internal/catch_console_colour.hpp>
#include <catch2/internal/catch_string_manip.hpp>
#include <catch2/catch_test_case_info.hpp>
+#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <algorithm>
#include <iterator>
@@ -189,6 +190,10 @@ namespace Catch {
} // End anonymous namespace
+ void TAPReporter::testRunStarting( TestRunInfo const& ) {
+ m_stream << "# rng-seed: " << m_config->rngSeed() << '\n';
+ }
+
void TAPReporter::noMatchingTestCases( StringRef unmatchedSpec ) {
m_stream << "# No test cases matched '" << unmatchedSpec << "'\n";
}
diff --git a/src/catch2/reporters/catch_reporter_tap.hpp b/src/catch2/reporters/catch_reporter_tap.hpp
index b8c3208f..0c4b14b4 100644
--- a/src/catch2/reporters/catch_reporter_tap.hpp
+++ b/src/catch2/reporters/catch_reporter_tap.hpp
@@ -26,6 +26,8 @@ namespace Catch {
return "Reports test results in TAP format, suitable for test harnesses"s;
}
+ void testRunStarting( TestRunInfo const& testInfo ) override;
+
void noMatchingTestCases( StringRef unmatchedSpec ) override;
void assertionEnded(AssertionStats const& _assertionStats) override;