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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-10-26 00:05:00 +0200
committerMartin Hořeňovský2022-10-26 00:05:00 +0200
commitffa152095ce075499b299e4872ecb1c1ea1a4dbf (patch)
tree42397a9eb0d3058ebab89bf50a7402a392e1751d
parent0ce8c25566176acbce2e887445d8c33306c184bc (diff)
downloadcatch3-ffa152095ce075499b299e4872ecb1c1ea1a4dbf.tar.gz
Report used filters in the SonarQube reporter
-rw-r--r--src/catch2/reporters/catch_reporter_sonarqube.cpp13
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt2
3 files changed, 12 insertions, 5 deletions
diff --git a/src/catch2/reporters/catch_reporter_sonarqube.cpp b/src/catch2/reporters/catch_reporter_sonarqube.cpp
index 8119c3b8..15b55ae0 100644
--- a/src/catch2/reporters/catch_reporter_sonarqube.cpp
+++ b/src/catch2/reporters/catch_reporter_sonarqube.cpp
@@ -11,15 +11,22 @@
#include <catch2/catch_test_case_info.hpp>
#include <catch2/internal/catch_reusable_string_stream.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
+#include <catch2/catch_test_spec.hpp>
+#include <catch2/reporters/catch_reporter_helpers.hpp>
#include <map>
namespace Catch {
namespace {
- std::string createRngSeedString(uint32_t seed) {
+ std::string createMetadataString(IConfig const& config) {
ReusableStringStream sstr;
- sstr << "rng-seed=" << seed;
+ if ( config.testSpec().hasFilters() ) {
+ sstr << "filters='"
+ << serializeFilters( config.getTestsOrTags() )
+ << "' ";
+ }
+ sstr << "rng-seed=" << config.rngSeed();
return sstr.str();
}
}
@@ -27,7 +34,7 @@ namespace Catch {
void SonarQubeReporter::testRunStarting(TestRunInfo const& testRunInfo) {
CumulativeReporterBase::testRunStarting(testRunInfo);
- xml.writeComment( createRngSeedString( m_config->rngSeed() ) );
+ xml.writeComment( createMetadataString( *m_config ) );
xml.startElement("testExecutions");
xml.writeAttribute("version"_sr, '1');
}
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index be43f8d8..a21c6a51 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- rng-seed=1 -->
+<!-- filters='~[!nonportable]~[!benchmark]~[approvals] *' rng-seed=1 -->
<testExecutions version="1"loose text artifact
>
<file path="tests/<exe-name>/IntrospectiveTests/Clara.tests.cpp">
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
index 75157eca..cf90c1f7 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- rng-seed=1 -->
+<!-- filters='~[!nonportable]~[!benchmark]~[approvals] *' rng-seed=1 -->
<testExecutions version="1">
<file path="tests/<exe-name>/IntrospectiveTests/Clara.tests.cpp">
<testCase name="Clara::Arg supports single-arg parse the way Opt does" duration="{duration}"/>