diff options
| author | Lukasz Okraszewski | 2022-04-08 17:01:59 +0100 |
|---|---|---|
| committer | GitHub | 2022-04-08 18:01:59 +0200 |
| commit | cb551b4f6d338020322eb39a2f3747c81896a1ba (patch) | |
| tree | c44d70ec3a0f007fe2cada04b72100b73d67a368 /src/catch2/catch_config.cpp | |
| parent | 4b7815798107b4226b5e00b6f49e4be5848328e6 (diff) | |
| download | catch3-cb551b4f6d338020322eb39a2f3747c81896a1ba.tar.gz | |
Add default reporter for Bazel integration (#2399)
When the added Bazel configuration flag is enabled,
a default JUnit reporter will be added if the XML
envrioment variable is defined.
Fix include paths for generated config header.
Enable Bazel config by default when building with
Bazel.
Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
Diffstat (limited to 'src/catch2/catch_config.cpp')
| -rw-r--r-- | src/catch2/catch_config.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index ff6198d9..913dbb4c 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -69,6 +69,28 @@ namespace Catch { } ); } +#if defined( CATCH_CONFIG_BAZEL_SUPPORT ) + // Register a JUnit reporter for Bazel. Bazel sets an environment + // variable with the path to XML output. If this file is written to + // during test, Bazel will not generate a default XML output. + // This allows the XML output file to contain higher level of detail + // than what is possible otherwise. +# if defined( _MSC_VER ) + // On Windows getenv throws a warning as there is no input validation, + // since the key is hardcoded, this should not be an issue. +# pragma warning( push ) +# pragma warning( disable : 4996 ) +# endif + const auto bazelOutputFilePtr = std::getenv( "XML_OUTPUT_FILE" ); +# if defined( _MSC_VER ) +# pragma warning( pop ) +# endif + if ( bazelOutputFilePtr != nullptr ) { + m_data.reporterSpecifications.push_back( + { "junit", std::string( bazelOutputFilePtr ), {}, {} } ); + } +#endif + bool defaultOutputUsed = false; m_reporterStreams.reserve( m_data.reporterSpecifications.size() ); for ( auto const& reporterSpec : m_data.reporterSpecifications ) { |