mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 13:55:39 +02:00
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>
This commit is contained in:

committed by
GitHub

parent
4b78157981
commit
cb551b4f6d
@@ -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 ) {
|
||||
|
@@ -165,6 +165,7 @@
|
||||
// ------
|
||||
|
||||
|
||||
#cmakedefine CATCH_CONFIG_BAZEL_SUPPORT
|
||||
#cmakedefine CATCH_CONFIG_DISABLE_EXCEPTIONS
|
||||
#cmakedefine CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER
|
||||
#cmakedefine CATCH_CONFIG_DISABLE
|
||||
|
Reference in New Issue
Block a user