mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-04 09:01:50 +01:00 
			
		
		
		
	Refactored stream related stuff
- simpler, polymorphic hierarchy-based, approach - less bitty conditionals spread across the code - all resolved up-front so now config class is immutable (it had evolved the way it was and in need of a clean-up sweep for a long time)
This commit is contained in:
		@@ -52,25 +52,11 @@ namespace Catch {
 | 
			
		||||
        return reporters;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    void openStreamInto( Ptr<Config> const& config, std::ofstream& ofs ) {
 | 
			
		||||
        // Open output file, if specified
 | 
			
		||||
        if( !config->getFilename().empty() ) {
 | 
			
		||||
            ofs.open( config->getFilename().c_str() );
 | 
			
		||||
            if( ofs.fail() ) {
 | 
			
		||||
                std::ostringstream oss;
 | 
			
		||||
                oss << "Unable to open file: '" << config->getFilename() << "'";
 | 
			
		||||
                throw std::domain_error( oss.str() );
 | 
			
		||||
            }
 | 
			
		||||
            config->setStreamBuf( ofs.rdbuf() );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    Totals runTests( Ptr<Config> const& config ) {
 | 
			
		||||
 | 
			
		||||
        Ptr<IConfig const> iconfig = config.get();
 | 
			
		||||
        
 | 
			
		||||
        std::ofstream ofs;
 | 
			
		||||
        openStreamInto( config, ofs );
 | 
			
		||||
        Ptr<IStreamingReporter> reporter = makeReporter( config );
 | 
			
		||||
        reporter = addListeners( iconfig, reporter );
 | 
			
		||||
        
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user