test(util): cover command stream line delivery and EOF flushing

Add focused coverage for the new GLib command stream helper.

These tests verify that complete lines are emitted as they arrive and that EOF flushes a final unterminated line without duplicating a newline-terminated one.

That behavior is the contract the custom module will rely on when its continuous command handling moves onto this helper.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman
2026-07-04 08:40:31 -05:00
committed by Austin Horstman
parent 2355486cb3
commit 560f02509b
3 changed files with 80 additions and 2 deletions
+9 -2
View File
@@ -6,10 +6,16 @@
class GlibTestsFixture : public sigc::trackable {
public:
GlibTestsFixture() : main_loop_{Glib::MainLoop::create()} {}
~GlibTestsFixture() { timeout_.disconnect(); }
void setTimeout(int timeout) {
Glib::signal_timeout().connect_once([]() { throw std::runtime_error("Test timed out"); },
timeout);
timeout_.disconnect();
timeout_ = Glib::signal_timeout().connect(
[]() {
throw std::runtime_error("Test timed out");
return false;
},
timeout);
}
void run(std::function<void()> fn) {
@@ -21,4 +27,5 @@ class GlibTestsFixture : public sigc::trackable {
protected:
Glib::RefPtr<Glib::MainLoop> main_loop_;
sigc::connection timeout_;
};