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

Code before:
                               "Internal error: cannot use default output for "
                               "multiple reporters" );
                defaultOutputUsed = true;
            }

            m_processedReporterSpecs.push_back( ProcessedReporterSpec{
                reporterSpec.name(),
                reporterSpec.outputFile() ? *reporterSpec.outputFile()
                                          : data.defaultOutputFilename,
                reporterSpec.colourMode().valueOr( data.defaultColourMode ),
                reporterSpec.customOptions() } );
        }
    }

    Config::~Config() = default;


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

    bool Config::hasBazel() const {
#ifdef CATCH_CONFIG_BAZEL_SUPPORT
        return true;
#endif
	
#    if defined( _MSC_VER )
        // On Windows getenv throws a warning as there is no input validation,
        // since the switch is hardcoded, this should not be an issue.
#        pragma warning( push )
#        pragma warning( disable : 4996 )
#    endif

	return std::getenv("BAZEL_TEST") != nullptr;

#    if defined( _MSC_VER )
#        pragma warning( pop )
#    endif
    }

    std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; }
    std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; }

    std::vector<ReporterSpec> const& Config::getReporterSpecs() const {
        return m_data.reporterSpecifications;
    }

    std::vector<ProcessedReporterSpec> const&
    Config::getProcessedReporterSpecs() const {
        return m_processedReporterSpecs;

Review comment (suggestion):
This will cause annoying warning issues about unreachable code. The simplest solution, albeit a bit annoying, is to turn this into an `#else` and then have the code below also be conditionally compiled.

Code after:
            // and avoid superfluous copies.
            if ( reporterSpec.outputFile().none() ) {
                CATCH_ENFORCE( !defaultOutputUsed,
                               "Internal error: cannot use default output for "
                               "multiple reporters" );
                defaultOutputUsed = true;
            }

            m_processedReporterSpecs.push_back( ProcessedReporterSpec{
                reporterSpec.name(),
                reporterSpec.outputFile() ? *reporterSpec.outputFile()
                                          : data.defaultOutputFilename,
                reporterSpec.colourMode().valueOr( data.defaultColourMode ),
                reporterSpec.customOptions() } );
        }
    }

    Config::~Config() = default;


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

    bool provideBazelReporterOutput() {
#ifdef CATCH_CONFIG_BAZEL_SUPPORT
        return true;
#else

#    if defined( _MSC_VER )
        // On Windows getenv throws a warning as there is no input validation,
        // since the switch is hardcoded, this should not be an issue.
#        pragma warning( push )
#       pragma warning( disable : 4996 )
#    endif

    return std::getenv("BAZEL_TEST") != nullptr;

#    if defined( _MSC_VER )
#        pragma warning( pop )
#    endif
#endif
    }

    std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; }
    std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; }

    std::vector<ReporterSpec> const& Config::getReporterSpecs() const {
        return m_data.reporterSpecifications;
    }