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