mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-26 20:53:31 +01:00
Merge branch 'develop' of git://github.com/peterhuene/Catch into peterhuene-develop
This commit is contained in:
commit
6d1da8e8d7
@ -170,6 +170,10 @@ namespace Catch {
|
||||
.describe( "set a specific seed for random numbers" )
|
||||
.bind( &setRngSeed, "'time'|number" );
|
||||
|
||||
cli["--force-colour"]
|
||||
.describe( "force colourised output" )
|
||||
.bind( &ConfigData::forceColour );
|
||||
|
||||
return cli;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ namespace Catch {
|
||||
noThrow( false ),
|
||||
showHelp( false ),
|
||||
showInvisibles( false ),
|
||||
forceColour( false ),
|
||||
abortAfter( -1 ),
|
||||
rngSeed( 0 ),
|
||||
verbosity( Verbosity::Normal ),
|
||||
@ -55,6 +56,7 @@ namespace Catch {
|
||||
bool noThrow;
|
||||
bool showHelp;
|
||||
bool showInvisibles;
|
||||
bool forceColour;
|
||||
|
||||
int abortAfter;
|
||||
unsigned int rngSeed;
|
||||
@ -131,7 +133,6 @@ namespace Catch {
|
||||
|
||||
std::string getReporterName() const { return m_data.reporterName; }
|
||||
|
||||
|
||||
int abortAfter() const { return m_data.abortAfter; }
|
||||
|
||||
TestSpec const& testSpec() const { return m_testSpec; }
|
||||
@ -148,6 +149,7 @@ namespace Catch {
|
||||
virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; }
|
||||
virtual RunTests::InWhatOrder runOrder() const { return m_data.runOrder; }
|
||||
virtual unsigned int rngSeed() const { return m_data.rngSeed; }
|
||||
virtual bool forceColour() const { return m_data.forceColour; }
|
||||
|
||||
private:
|
||||
ConfigData m_data;
|
||||
|
@ -143,7 +143,8 @@ namespace {
|
||||
};
|
||||
|
||||
IColourImpl* platformColourInstance() {
|
||||
return isatty(STDOUT_FILENO)
|
||||
Ptr<IConfig const> config = getCurrentContext().getConfig();
|
||||
return (config && config->forceColour()) || isatty(STDOUT_FILENO)
|
||||
? PosixColourImpl::instance()
|
||||
: NoColourImpl::instance();
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ namespace Catch {
|
||||
virtual TestSpec const& testSpec() const = 0;
|
||||
virtual RunTests::InWhatOrder runOrder() const = 0;
|
||||
virtual unsigned int rngSeed() const = 0;
|
||||
virtual bool forceColour() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,23 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
||||
CHECK( config.shouldDebugBreak );
|
||||
CHECK( config.noThrow == true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION( "force-colour", "") {
|
||||
SECTION( "--force-colour", "" ) {
|
||||
const char* argv[] = { "test", "--force-colour" };
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||
|
||||
REQUIRE( config.forceColour );
|
||||
}
|
||||
|
||||
SECTION( "without --force-colour", "" ) {
|
||||
const char* argv[] = { "test" };
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||
|
||||
REQUIRE( !config.forceColour );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user