Repository: catchorg/Catch2
File: src/catch2/catch_config.cpp (C++)

Code before:
            for (auto const& testOrTags : m_data.testsOrTags) {
                parser.parse(testOrTags);
            }
        }
        m_testSpec = parser.testSpec();


        // Insert the default reporter if user hasn't asked for a specfic one
        if ( m_data.reporterSpecifications.empty() ) {
            m_data.reporterSpecifications.push_back( {
#if defined( CATCH_CONFIG_DEFAULT_REPORTER )
                CATCH_CONFIG_DEFAULT_REPORTER,
#else
                "console",
#endif
                {}
            } );
        }

#if defined( CATCH_CONFIG_BAZEL_SUPPORT )
        // Register a JUnit reporter for Bazel. Bazel sets an enviorment
        // 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( CATCH_PLATFORM_WINDOWS )
        // 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(suppress: 4996)
        auto const bazelOutputFile = std::getenv( "XML_OUTPUT_FILE" );
#else
        auto const bazelOutputFile = std::getenv( "XML_OUTPUT_FILE" );
#endif
        if ( bazelOutputFile != nullptr ) {
            m_data.reporterSpecifications.push_back(
                { "junit", { bazelOutputFile } } );
        }
#endif

        bool defaultOutputUsed = false;
        m_reporterStreams.reserve( m_data.reporterSpecifications.size() );
        for ( auto const& reporterAndFile : m_data.reporterSpecifications ) {
            if ( reporterAndFile.outputFileName.none() ) {
                CATCH_ENFORCE( !defaultOutputUsed,
                               "Internal error: cannot use default output for "
                               "multiple reporters" );
                defaultOutputUsed = true;

                m_reporterStreams.push_back(
                    openStream( data.defaultOutputFilename ) );
            } else {

Review comment (suggestion):
This should check for `_MSC_VER` instead, because `CATCH_PLATFORM_WINDOWS` is also defined for MinGW, which uses different syntax for warning suppression pragmas (and also doesn't complain about plain `getenv`)

Code after:
#else
                "console",
#endif
                {}, {}, {}
            } );
        }

#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 ) {
            if ( reporterSpec.outputFile().none() ) {
                CATCH_ENFORCE( !defaultOutputUsed,
                               "Internal error: cannot use default output for "
                               "multiple reporters" );
                defaultOutputUsed = true;

                m_reporterStreams.push_back(
                    makeStream( data.defaultOutputFilename ) );
            } else {
                m_reporterStreams.push_back(
                    makeStream( *reporterSpec.outputFile() ) );
            }
        }
    }

    Config::~Config() = default;


    bool Config::listTests() const          { return m_data.listTests; }