aboutsummaryrefslogtreecommitdiff
path: root/src/zencore
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-18 11:19:10 +0100
committerGitHub Enterprise <[email protected]>2026-03-18 11:19:10 +0100
commiteba410c4168e23d7908827eb34b7cf0c58a5dc48 (patch)
tree3cda8e8f3f81941d3bb5b84a8155350c5bb2068c /src/zencore
parentbugfix release - v5.7.23 (#851) (diff)
downloadzen-eba410c4168e23d7908827eb34b7cf0c58a5dc48.tar.xz
zen-eba410c4168e23d7908827eb34b7cf0c58a5dc48.zip
Compute batching (#849)
### Compute Batch Submission - Consolidate duplicated action submission logic in `httpcomputeservice` into a single `HandleSubmitAction` supporting both single-action and batch (actions array) payloads - Group actions by queue in `RemoteHttpRunner` and submit as batches with configurable chunk size, falling back to individual submission on failure - Extract shared helpers: `MakeErrorResult`, `ValidateQueueForEnqueue`, `ActivateActionInQueue`, `RemoveActionFromActiveMaps` ### Retracted Action State - Add `Retracted` state to `RunnerAction` for retry-free rescheduling — an explicit request to pull an action back and reschedule it on a different runner without incrementing `RetryCount` - Implement idempotent `RetractAction()` on `RunnerAction` and `ComputeServiceSession` - Add `POST jobs/{lsn}/retract` and `queues/{queueref}/jobs/{lsn}/retract` HTTP endpoints - Add state machine documentation and per-state comments to `RunnerAction` ### Compute Race Fixes - Fix race in `HandleActionUpdates` where actions enqueued between session abandon and scheduler tick were never abandoned, causing `GetActionResult` to return 202 indefinitely - Fix queue `ActiveCount` race where `NotifyQueueActionComplete` was called after releasing `m_ResultsLock`, allowing callers to observe stale counters immediately after `GetActionResult` returned OK ### Logging Optimization and ANSI improvements - Improve `AnsiColorStdoutSink` write efficiency — single write call, dirty-flag flush, `RwLock` instead of `std::mutex` - Move ANSI color emission from sink into formatters via `Formatter::SetColorEnabled()`; remove `ColorRangeStart`/`End` from `LogMessage` - Extract color helpers (`AnsiColorForLevel`, `StripAnsiSgrSequences`) into `helpers.h` - Strip upstream ANSI SGR escapes in non-color output mode. This enables colour in log messages without polluting log files with ANSI control sequences - Move `RotatingFileSink`, `JsonFormatter`, and `FullFormatter` from header-only to pimpl with `.cpp` files ### CLI / Exec Refactoring - Extract `ExecSessionRunner` class from ~920-line `ExecUsingSession` into focused methods and a `ExecSessionConfig` struct - Replace monolithic `ExecCommand` with subcommand-based architecture (`http`, `inproc`, `beacon`, `dump`, `buildlog`) - Allow parent options to appear after subcommand name by parsing subcommand args permissively and forwarding unmatched tokens to the parent parser ### Testing Improvements - Fix `--test-suite` filter being ignored due to accumulation with default wildcard filter - Add test suite banners to test listener output - Made `function.session.abandon_pending` test more robust ### Startup / Reliability Fixes - Fix silent exit when a second zenserver instance detects a port conflict — use `ZEN_CONSOLE_*` for log calls that precede `InitializeLogging()` - Fix two potential SIGSEGV paths during early startup: guard `sentry_options_new()` returning nullptr, and throw on `ZenServerState::Register()` returning nullptr instead of dereferencing - Fail on unrecognized zenserver `--mode` instead of silently defaulting to store ### Other - Show host details (hostname, platform, CPU count, memory) when discovering new compute workers - Move frontend `html.zip` from source tree into build directory - Add format specifications for Compact Binary and Compressed Buffer wire formats - Add `WriteCompactBinaryObject` to zencore - Extended `ConsoleTui` with additional functionality - Add `--vscode` option to `xmake sln` for clangd / `compile_commands.json` support - Disable compute/horde/nomad in release builds (not yet production-ready) - Disable unintended `ASIO_HAS_IO_URING` enablement - Fix crashpad patch missing leading whitespace - Clean up code triggering gcc false positives
Diffstat (limited to 'src/zencore')
-rw-r--r--src/zencore/compactbinaryfile.cpp11
-rw-r--r--src/zencore/include/zencore/compactbinaryfile.h1
-rw-r--r--src/zencore/include/zencore/logging/ansicolorsink.h3
-rw-r--r--src/zencore/include/zencore/logging/formatter.h6
-rw-r--r--src/zencore/include/zencore/logging/helpers.h77
-rw-r--r--src/zencore/include/zencore/logging/logmsg.h3
-rw-r--r--src/zencore/include/zencore/testing.h5
-rw-r--r--src/zencore/logging/ansicolorsink.cpp287
-rw-r--r--src/zencore/testing.cpp50
9 files changed, 300 insertions, 143 deletions
diff --git a/src/zencore/compactbinaryfile.cpp b/src/zencore/compactbinaryfile.cpp
index ec2fc3cd5..9ddafbe15 100644
--- a/src/zencore/compactbinaryfile.cpp
+++ b/src/zencore/compactbinaryfile.cpp
@@ -30,4 +30,15 @@ LoadCompactBinaryObject(const std::filesystem::path& FilePath)
return {.Hash = IoHash::Zero};
}
+void
+WriteCompactBinaryObject(const std::filesystem::path& Path, const CbObject& Object)
+{
+ // We cannot use CbObject::GetView() here because it may not return a complete
+ // view since the type byte can be omitted in arrays.
+ CbWriter Writer;
+ Writer.AddObject(Object);
+ CbFieldIterator Fields = Writer.Save();
+ zen::WriteFile(Path, IoBufferBuilder::MakeFromMemory(Fields.GetRangeView()));
+}
+
} // namespace zen
diff --git a/src/zencore/include/zencore/compactbinaryfile.h b/src/zencore/include/zencore/compactbinaryfile.h
index 33f3e7bea..a06524549 100644
--- a/src/zencore/include/zencore/compactbinaryfile.h
+++ b/src/zencore/include/zencore/compactbinaryfile.h
@@ -15,5 +15,6 @@ struct CbObjectFromFile
};
CbObjectFromFile LoadCompactBinaryObject(const std::filesystem::path& FilePath);
+void WriteCompactBinaryObject(const std::filesystem::path& Path, const CbObject& Object);
} // namespace zen
diff --git a/src/zencore/include/zencore/logging/ansicolorsink.h b/src/zencore/include/zencore/logging/ansicolorsink.h
index 5060a8393..939c70d12 100644
--- a/src/zencore/include/zencore/logging/ansicolorsink.h
+++ b/src/zencore/include/zencore/logging/ansicolorsink.h
@@ -15,6 +15,9 @@ enum class ColorMode
Auto
};
+bool IsColorTerminal();
+bool ResolveColorMode(ColorMode Mode);
+
class AnsiColorStdoutSink : public Sink
{
public:
diff --git a/src/zencore/include/zencore/logging/formatter.h b/src/zencore/include/zencore/logging/formatter.h
index 11904d71d..e605b22b8 100644
--- a/src/zencore/include/zencore/logging/formatter.h
+++ b/src/zencore/include/zencore/logging/formatter.h
@@ -15,6 +15,12 @@ public:
virtual ~Formatter() = default;
virtual void Format(const LogMessage& Msg, MemoryBuffer& Dest) = 0;
virtual std::unique_ptr<Formatter> Clone() const = 0;
+
+ void SetColorEnabled(bool Enabled) { m_UseColor = Enabled; }
+ bool IsColorEnabled() const { return m_UseColor; }
+
+private:
+ bool m_UseColor = false;
};
} // namespace zen::logging
diff --git a/src/zencore/include/zencore/logging/helpers.h b/src/zencore/include/zencore/logging/helpers.h
index ce021e1a5..765aa59e3 100644
--- a/src/zencore/include/zencore/logging/helpers.h
+++ b/src/zencore/include/zencore/logging/helpers.h
@@ -119,4 +119,81 @@ LevelToShortString(LogLevel Level)
return ToStringView(Level);
}
+inline std::string_view
+AnsiColorForLevel(LogLevel Level)
+{
+ using namespace std::string_view_literals;
+ switch (Level)
+ {
+ case Trace:
+ return "\033[37m"sv; // white
+ case Debug:
+ return "\033[36m"sv; // cyan
+ case Info:
+ return "\033[32m"sv; // green
+ case Warn:
+ return "\033[33m\033[1m"sv; // bold yellow
+ case Err:
+ return "\033[31m\033[1m"sv; // bold red
+ case Critical:
+ return "\033[1m\033[41m"sv; // bold on red background
+ default:
+ return "\033[m"sv;
+ }
+}
+
+inline constexpr std::string_view kAnsiReset = "\033[m";
+
+inline void
+AppendAnsiColor(LogLevel Level, MemoryBuffer& Dest)
+{
+ std::string_view Color = AnsiColorForLevel(Level);
+ Dest.append(Color.data(), Color.data() + Color.size());
+}
+
+inline void
+AppendAnsiReset(MemoryBuffer& Dest)
+{
+ Dest.append(kAnsiReset.data(), kAnsiReset.data() + kAnsiReset.size());
+}
+
+// Strip ANSI SGR escape sequences (\033[...m) from the buffer in-place.
+// Only sequences terminated by 'm' are removed (colors, bold, underline, etc.).
+// Other CSI sequences (cursor movement, erase, etc.) are left intact.
+inline void
+StripAnsiSgrSequences(MemoryBuffer& Buf)
+{
+ const char* Src = Buf.data();
+ const char* End = Src + Buf.size();
+ char* Dst = Buf.data();
+
+ while (Src < End)
+ {
+ if (Src[0] == '\033' && (Src + 1) < End && Src[1] == '[')
+ {
+ const char* Seq = Src + 2;
+ while (Seq < End && *Seq != 'm')
+ {
+ ++Seq;
+ }
+ if (Seq < End)
+ {
+ ++Seq; // skip 'm'
+ }
+ Src = Seq;
+ }
+ else
+ {
+ if (Dst != Src)
+ {
+ *Dst = *Src;
+ }
+ ++Dst;
+ ++Src;
+ }
+ }
+
+ Buf.resize(static_cast<size_t>(Dst - Buf.data()));
+}
+
} // namespace zen::logging::helpers
diff --git a/src/zencore/include/zencore/logging/logmsg.h b/src/zencore/include/zencore/logging/logmsg.h
index 1d8b6b1b7..a1acb503b 100644
--- a/src/zencore/include/zencore/logging/logmsg.h
+++ b/src/zencore/include/zencore/logging/logmsg.h
@@ -40,9 +40,6 @@ struct LogMessage
void SetTime(LogClock::time_point InTime) { m_Time = InTime; }
void SetSource(const SourceLocation& InSource) { m_Source = InSource; }
- mutable size_t ColorRangeStart = 0;
- mutable size_t ColorRangeEnd = 0;
-
private:
static constexpr LogPoint s_DefaultPoints[LogLevelCount] = {
{{}, Trace, {}},
diff --git a/src/zencore/include/zencore/testing.h b/src/zencore/include/zencore/testing.h
index 8410216c4..01356fa00 100644
--- a/src/zencore/include/zencore/testing.h
+++ b/src/zencore/include/zencore/testing.h
@@ -43,9 +43,8 @@ public:
TestRunner();
~TestRunner();
- void SetDefaultSuiteFilter(const char* Pattern);
- int ApplyCommandLine(int Argc, char const* const* Argv);
- int Run();
+ int ApplyCommandLine(int Argc, char const* const* Argv, const char* DefaultSuiteFilter = nullptr);
+ int Run();
private:
struct Impl;
diff --git a/src/zencore/logging/ansicolorsink.cpp b/src/zencore/logging/ansicolorsink.cpp
index 540d22359..03aae068a 100644
--- a/src/zencore/logging/ansicolorsink.cpp
+++ b/src/zencore/logging/ansicolorsink.cpp
@@ -4,12 +4,14 @@
#include <zencore/logging/helpers.h>
#include <zencore/logging/messageonlyformatter.h>
+#include <zencore/thread.h>
+
#include <cstdio>
#include <cstdlib>
-#include <mutex>
#if defined(_WIN32)
# include <io.h>
+# include <zencore/windows.h>
# define ZEN_ISATTY _isatty
# define ZEN_FILENO _fileno
#else
@@ -62,188 +64,225 @@ public:
Dest.push_back(' ');
}
- // level (colored range)
+ // level
Dest.push_back('[');
- Msg.ColorRangeStart = Dest.size();
+ if (IsColorEnabled())
+ {
+ helpers::AppendAnsiColor(Msg.GetLevel(), Dest);
+ }
helpers::AppendStringView(helpers::LevelToShortString(Msg.GetLevel()), Dest);
- Msg.ColorRangeEnd = Dest.size();
+ if (IsColorEnabled())
+ {
+ helpers::AppendAnsiReset(Dest);
+ }
Dest.push_back(']');
Dest.push_back(' ');
- // message
- helpers::AppendStringView(Msg.GetPayload(), Dest);
+ // message (align continuation lines with the first line)
+ size_t AnsiBytes = IsColorEnabled() ? (helpers::AnsiColorForLevel(Msg.GetLevel()).size() + helpers::kAnsiReset.size()) : 0;
+ size_t LinePrefixCount = Dest.size() - AnsiBytes;
+
+ auto MsgPayload = Msg.GetPayload();
+ auto ItLineBegin = MsgPayload.begin();
+ auto ItMessageEnd = MsgPayload.end();
+ bool IsFirstLine = true;
+
+ auto ItLineEnd = ItLineBegin;
+
+ auto EmitLine = [&] {
+ if (IsFirstLine)
+ {
+ IsFirstLine = false;
+ }
+ else
+ {
+ for (size_t i = 0; i < LinePrefixCount; ++i)
+ {
+ Dest.push_back(' ');
+ }
+ }
+ helpers::AppendStringView(std::string_view(&*ItLineBegin, ItLineEnd - ItLineBegin), Dest);
+ };
+
+ while (ItLineEnd != ItMessageEnd)
+ {
+ if (*ItLineEnd++ == '\n')
+ {
+ EmitLine();
+ ItLineBegin = ItLineEnd;
+ }
+ }
+
+ if (ItLineBegin != ItMessageEnd)
+ {
+ EmitLine();
+ }
Dest.push_back('\n');
}
- std::unique_ptr<Formatter> Clone() const override { return std::make_unique<DefaultConsoleFormatter>(); }
+ std::unique_ptr<Formatter> Clone() const override
+ {
+ auto Copy = std::make_unique<DefaultConsoleFormatter>();
+ Copy->SetColorEnabled(IsColorEnabled());
+ return Copy;
+ }
private:
std::chrono::seconds m_LastLogSecs{0};
std::tm m_CachedLocalTm{};
};
-static constexpr std::string_view s_Reset = "\033[m";
-
-static std::string_view
-GetColorForLevel(LogLevel InLevel)
+bool
+IsColorTerminal()
{
- using namespace std::string_view_literals;
- switch (InLevel)
+ // If stdout is not a TTY, no color
+ if (ZEN_ISATTY(ZEN_FILENO(stdout)) == 0)
{
- case Trace:
- return "\033[37m"sv; // white
- case Debug:
- return "\033[36m"sv; // cyan
- case Info:
- return "\033[32m"sv; // green
- case Warn:
- return "\033[33m\033[1m"sv; // bold yellow
- case Err:
- return "\033[31m\033[1m"sv; // bold red
- case Critical:
- return "\033[1m\033[41m"sv; // bold on red background
- default:
- return s_Reset;
+ return false;
}
-}
-struct AnsiColorStdoutSink::Impl
-{
- explicit Impl(ColorMode Mode) : m_Formatter(std::make_unique<DefaultConsoleFormatter>()), m_UseColor(ResolveColorMode(Mode)) {}
+ // NO_COLOR convention (https://no-color.org/)
+ if (std::getenv("NO_COLOR") != nullptr)
+ {
+ return false;
+ }
- static bool IsColorTerminal()
+ // COLORTERM is set by terminals that support color (e.g. "truecolor", "24bit")
+ if (std::getenv("COLORTERM") != nullptr)
{
- // If stdout is not a TTY, no color
- if (ZEN_ISATTY(ZEN_FILENO(stdout)) == 0)
- {
- return false;
- }
+ return true;
+ }
- // NO_COLOR convention (https://no-color.org/)
- if (std::getenv("NO_COLOR") != nullptr)
+ // Check TERM for known color-capable values
+ const char* Term = std::getenv("TERM");
+ if (Term != nullptr)
+ {
+ std::string_view TermView(Term);
+ // "dumb" terminals do not support color
+ if (TermView == "dumb")
{
return false;
}
-
- // COLORTERM is set by terminals that support color (e.g. "truecolor", "24bit")
- if (std::getenv("COLORTERM") != nullptr)
+ // Match against known color-capable terminal types.
+ // TERM often includes suffixes like "-256color", so we use substring matching.
+ constexpr std::string_view ColorTerms[] = {
+ "alacritty",
+ "ansi",
+ "color",
+ "console",
+ "cygwin",
+ "gnome",
+ "konsole",
+ "kterm",
+ "linux",
+ "msys",
+ "putty",
+ "rxvt",
+ "screen",
+ "tmux",
+ "vt100",
+ "vt102",
+ "xterm",
+ };
+ for (std::string_view Candidate : ColorTerms)
{
- return true;
- }
-
- // Check TERM for known color-capable values
- const char* Term = std::getenv("TERM");
- if (Term != nullptr)
- {
- std::string_view TermView(Term);
- // "dumb" terminals do not support color
- if (TermView == "dumb")
+ if (TermView.find(Candidate) != std::string_view::npos)
{
- return false;
- }
- // Match against known color-capable terminal types.
- // TERM often includes suffixes like "-256color", so we use substring matching.
- constexpr std::string_view ColorTerms[] = {
- "alacritty",
- "ansi",
- "color",
- "console",
- "cygwin",
- "gnome",
- "konsole",
- "kterm",
- "linux",
- "msys",
- "putty",
- "rxvt",
- "screen",
- "tmux",
- "vt100",
- "vt102",
- "xterm",
- };
- for (std::string_view Candidate : ColorTerms)
- {
- if (TermView.find(Candidate) != std::string_view::npos)
- {
- return true;
- }
+ return true;
}
}
+ }
#if defined(_WIN32)
- // Windows console supports ANSI color by default in modern versions
- return true;
+ // Windows console supports ANSI color by default in modern versions
+ return true;
#else
- // Unknown terminal — be conservative
- return false;
+ // Unknown terminal — be conservative
+ return false;
#endif
- }
+}
- static bool ResolveColorMode(ColorMode Mode)
+bool
+ResolveColorMode(ColorMode Mode)
+{
+ switch (Mode)
{
- switch (Mode)
- {
- case ColorMode::On:
- return true;
- case ColorMode::Off:
- return false;
- case ColorMode::Auto:
- default:
- return IsColorTerminal();
- }
+ case ColorMode::On:
+ return true;
+ case ColorMode::Off:
+ return false;
+ case ColorMode::Auto:
+ default:
+ return IsColorTerminal();
}
+}
- void Log(const LogMessage& Msg)
+struct AnsiColorStdoutSink::Impl
+{
+ explicit Impl(ColorMode Mode) : m_Formatter(std::make_unique<DefaultConsoleFormatter>()), m_UseColor(ResolveColorMode(Mode))
{
- std::lock_guard<std::mutex> Lock(m_Mutex);
-
- MemoryBuffer Formatted;
- m_Formatter->Format(Msg, Formatted);
+ m_Formatter->SetColorEnabled(m_UseColor);
+ }
- if (m_UseColor && Msg.ColorRangeEnd > Msg.ColorRangeStart)
- {
- // Print pre-color range
- fwrite(Formatted.data(), 1, Msg.ColorRangeStart, m_File);
+ void WriteOutput(const MemoryBuffer& Buf)
+ {
+ RwLock::ExclusiveLockScope Lock(m_Lock);
- // Print color
- std::string_view Color = GetColorForLevel(Msg.GetLevel());
- fwrite(Color.data(), 1, Color.size(), m_File);
+#if defined(_WIN32)
+ DWORD Written;
+ WriteFile(m_Handle, Buf.data(), static_cast<DWORD>(Buf.size()), &Written, nullptr);
+#else
+ fwrite(Buf.data(), 1, Buf.size(), m_File);
+#endif
- // Print colored range
- fwrite(Formatted.data() + Msg.ColorRangeStart, 1, Msg.ColorRangeEnd - Msg.ColorRangeStart, m_File);
+ m_Dirty.store(false, std::memory_order_relaxed);
+ }
- // Reset color
- fwrite(s_Reset.data(), 1, s_Reset.size(), m_File);
+ void Log(const LogMessage& Msg)
+ {
+ MemoryBuffer Formatted;
+ m_Formatter->Format(Msg, Formatted);
- // Print remainder
- fwrite(Formatted.data() + Msg.ColorRangeEnd, 1, Formatted.size() - Msg.ColorRangeEnd, m_File);
- }
- else
+ if (!m_UseColor)
{
- fwrite(Formatted.data(), 1, Formatted.size(), m_File);
+ helpers::StripAnsiSgrSequences(Formatted);
}
- fflush(m_File);
+ WriteOutput(Formatted);
}
void Flush()
{
- std::lock_guard<std::mutex> Lock(m_Mutex);
+ if (!m_Dirty.load(std::memory_order_relaxed))
+ {
+ return;
+ }
+ RwLock::ExclusiveLockScope Lock(m_Lock);
+ m_Dirty.store(false, std::memory_order_relaxed);
+#if defined(_WIN32)
+ FlushFileBuffers(m_Handle);
+#else
fflush(m_File);
+#endif
}
void SetFormatter(std::unique_ptr<Formatter> InFormatter)
{
- std::lock_guard<std::mutex> Lock(m_Mutex);
+ RwLock::ExclusiveLockScope Lock(m_Lock);
+ InFormatter->SetColorEnabled(m_UseColor);
m_Formatter = std::move(InFormatter);
}
private:
- std::mutex m_Mutex;
+ RwLock m_Lock;
std::unique_ptr<Formatter> m_Formatter;
- FILE* m_File = stdout;
- bool m_UseColor = true;
+#if defined(_WIN32)
+ HANDLE m_Handle = GetStdHandle(STD_OUTPUT_HANDLE);
+#else
+ FILE* m_File = stdout;
+#endif
+ bool m_UseColor = true;
+ std::atomic<bool> m_Dirty = false;
};
AnsiColorStdoutSink::AnsiColorStdoutSink(ColorMode Mode) : m_Impl(std::make_unique<Impl>(Mode))
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 = &in;
+
+ 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();
}