mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Turn RunTests into TestRunOrder enum class
This commit is contained in:
parent
60cc4c293d
commit
b0531404e4
@ -72,7 +72,7 @@ namespace Catch {
|
||||
bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); }
|
||||
ShowDurations Config::showDurations() const { return m_data.showDurations; }
|
||||
double Config::minDuration() const { return m_data.minDuration; }
|
||||
RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; }
|
||||
TestRunOrder Config::runOrder() const { return m_data.runOrder; }
|
||||
unsigned int Config::rngSeed() const { return m_data.rngSeed; }
|
||||
UseColour::YesOrNo Config::useColour() const { return m_data.useColour; }
|
||||
bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; }
|
||||
|
@ -45,7 +45,7 @@ namespace Catch {
|
||||
WarnAbout::What warnings = WarnAbout::Nothing;
|
||||
ShowDurations showDurations = ShowDurations::DefaultForReporter;
|
||||
double minDuration = -1;
|
||||
RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
|
||||
TestRunOrder runOrder = TestRunOrder::Declared;
|
||||
UseColour::YesOrNo useColour = UseColour::Auto;
|
||||
WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
|
||||
|
||||
@ -96,7 +96,7 @@ namespace Catch {
|
||||
bool warnAboutNoTests() const override;
|
||||
ShowDurations showDurations() const override;
|
||||
double minDuration() const override;
|
||||
RunTests::InWhatOrder runOrder() const override;
|
||||
TestRunOrder runOrder() const override;
|
||||
unsigned int rngSeed() const override;
|
||||
UseColour::YesOrNo useColour() const override;
|
||||
bool shouldDebugBreak() const override;
|
||||
|
@ -34,11 +34,11 @@ namespace Catch {
|
||||
Always,
|
||||
Never
|
||||
};
|
||||
struct RunTests { enum InWhatOrder {
|
||||
InDeclarationOrder,
|
||||
InLexicographicalOrder,
|
||||
InRandomOrder
|
||||
}; };
|
||||
enum class TestRunOrder {
|
||||
Declared,
|
||||
LexicographicallySorted,
|
||||
Randomized
|
||||
};
|
||||
struct UseColour { enum YesOrNo {
|
||||
Auto,
|
||||
Yes,
|
||||
@ -71,7 +71,7 @@ namespace Catch {
|
||||
virtual TestSpec const& testSpec() const = 0;
|
||||
virtual bool hasTestFilters() const = 0;
|
||||
virtual std::vector<std::string> const& getTestsOrTags() const = 0;
|
||||
virtual RunTests::InWhatOrder runOrder() const = 0;
|
||||
virtual TestRunOrder runOrder() const = 0;
|
||||
virtual unsigned int rngSeed() const = 0;
|
||||
virtual UseColour::YesOrNo useColour() const = 0;
|
||||
virtual std::vector<std::string> const& getSectionsToRun() const = 0;
|
||||
|
@ -62,11 +62,11 @@ namespace Catch {
|
||||
};
|
||||
auto const setTestOrder = [&]( std::string const& order ) {
|
||||
if( startsWith( "declared", order ) )
|
||||
config.runOrder = RunTests::InDeclarationOrder;
|
||||
config.runOrder = TestRunOrder::Declared;
|
||||
else if( startsWith( "lexical", order ) )
|
||||
config.runOrder = RunTests::InLexicographicalOrder;
|
||||
config.runOrder = TestRunOrder::LexicographicallySorted;
|
||||
else if( startsWith( "random", order ) )
|
||||
config.runOrder = RunTests::InRandomOrder;
|
||||
config.runOrder = TestRunOrder::Randomized;
|
||||
else
|
||||
return ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" );
|
||||
return ParserResult::ok( ParseResultType::Matched );
|
||||
|
@ -46,15 +46,15 @@ namespace {
|
||||
|
||||
std::vector<TestCaseHandle> sortTests( IConfig const& config, std::vector<TestCaseHandle> const& unsortedTestCases ) {
|
||||
switch (config.runOrder()) {
|
||||
case RunTests::InDeclarationOrder:
|
||||
case TestRunOrder::Declared:
|
||||
return unsortedTestCases;
|
||||
|
||||
case RunTests::InLexicographicalOrder: {
|
||||
case TestRunOrder::LexicographicallySorted: {
|
||||
std::vector<TestCaseHandle> sorted = unsortedTestCases;
|
||||
std::sort(sorted.begin(), sorted.end());
|
||||
return sorted;
|
||||
}
|
||||
case RunTests::InRandomOrder: {
|
||||
case TestRunOrder::Randomized: {
|
||||
seedRng(config);
|
||||
HashTest h(rng());
|
||||
std::vector<std::pair<uint64_t, TestCaseHandle>> indexed_tests;
|
||||
|
@ -47,7 +47,7 @@ namespace Catch {
|
||||
|
||||
std::vector<Detail::unique_ptr<ITestInvoker>> m_invokers;
|
||||
std::vector<TestCaseHandle> m_handles;
|
||||
mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder;
|
||||
mutable TestRunOrder m_currentSortOrder = TestRunOrder::Declared;
|
||||
mutable std::vector<TestCaseHandle> m_sortedFunctions;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user