Report used filters in the SonarQube reporter

This commit is contained in:
Martin Hořeňovský 2022-10-26 00:05:00 +02:00
parent 0ce8c25566
commit ffa152095c
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
3 changed files with 12 additions and 5 deletions

View File

@ -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');
}

View File

@ -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">

View File

@ -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}"/>