aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/testing.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/testing.cpp')
-rw-r--r--src/zencore/testing.cpp50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/zencore/testing.cpp b/src/zencore/testing.cpp
index f5bc723b1..c6ee5ee6b 100644
--- a/src/zencore/testing.cpp
+++ b/src/zencore/testing.cpp
@@ -181,6 +181,15 @@ struct TestListener : public doctest::IReporter
void test_case_start(const doctest::TestCaseData& in) override
{
Current = ∈
+
+ if (in.m_test_suite && in.m_test_suite != CurrentSuite)
+ {
+ CurrentSuite = in.m_test_suite;
+ ZEN_CONSOLE("{}==============================================================================={}", ColorYellow, ColorNone);
+ ZEN_CONSOLE("{} TEST_SUITE: {}{}", ColorYellow, CurrentSuite, ColorNone);
+ ZEN_CONSOLE("{}==============================================================================={}", ColorYellow, ColorNone);
+ }
+
ZEN_CONSOLE("{}======== TEST_CASE: {:<50} ========{}", ColorYellow, Current->m_name, ColorNone);
}
@@ -217,8 +226,9 @@ struct TestListener : public doctest::IReporter
void test_case_skipped(const doctest::TestCaseData& /*in*/) override {}
- const doctest::TestCaseData* Current = nullptr;
- std::chrono::steady_clock::time_point RunStart = {};
+ const doctest::TestCaseData* Current = nullptr;
+ std::string_view CurrentSuite = {};
+ std::chrono::steady_clock::time_point RunStart = {};
struct FailedTestInfo
{
@@ -244,15 +254,29 @@ TestRunner::~TestRunner()
{
}
-void
-TestRunner::SetDefaultSuiteFilter(const char* Pattern)
-{
- m_Impl->Session.setOption("test-suite", Pattern);
-}
-
int
-TestRunner::ApplyCommandLine(int Argc, char const* const* Argv)
+TestRunner::ApplyCommandLine(int Argc, char const* const* Argv, const char* DefaultSuiteFilter)
{
+ // Apply the default suite filter only when the command line doesn't provide
+ // an explicit --test-suite / --ts override.
+ if (DefaultSuiteFilter)
+ {
+ bool HasExplicitSuiteFilter = false;
+ for (int i = 1; i < Argc; ++i)
+ {
+ std::string_view Arg = Argv[i];
+ if (Arg.starts_with("--test-suite=") || Arg.starts_with("--ts=") || Arg.starts_with("-test-suite=") || Arg.starts_with("-ts="))
+ {
+ HasExplicitSuiteFilter = true;
+ break;
+ }
+ }
+ if (!HasExplicitSuiteFilter)
+ {
+ m_Impl->Session.setOption("test-suite", DefaultSuiteFilter);
+ }
+ }
+
m_Impl->Session.applyCommandLine(Argc, Argv);
for (int i = 1; i < Argc; ++i)
@@ -316,6 +340,7 @@ RunTestMain(int Argc, char* Argv[], const char* ExecutableName, void (*ForceLink
TestRunner Runner;
// Derive default suite filter from ExecutableName: "zencore-test" -> "core.*"
+ std::string DefaultSuiteFilter;
if (ExecutableName)
{
std::string_view Name = ExecutableName;
@@ -329,13 +354,12 @@ RunTestMain(int Argc, char* Argv[], const char* ExecutableName, void (*ForceLink
}
if (!Name.empty())
{
- std::string Filter(Name);
- Filter += ".*";
- Runner.SetDefaultSuiteFilter(Filter.c_str());
+ DefaultSuiteFilter = Name;
+ DefaultSuiteFilter += ".*";
}
}
- Runner.ApplyCommandLine(Argc, Argv);
+ Runner.ApplyCommandLine(Argc, Argv, DefaultSuiteFilter.empty() ? nullptr : DefaultSuiteFilter.c_str());
return Runner.Run();
}