From 1137da9238bb203840ca1f2469d0082036073f8a Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 19 Dec 2023 08:41:29 -0600 Subject: [PATCH] cli: add xdg-terminal-exec parsing tests Add two tests for parsing of xdg-terminal-exec. --- src/config/Config.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/config/Config.zig b/src/config/Config.zig index 28acfaade..c1984b7c8 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -1847,6 +1847,28 @@ test "parse e: command and args" { try testing.expectEqualStrings("echo foo bar baz", cfg.command.?); } +test "parse xdg-terminal-exec: command and args" { + const testing = std.testing; + var cfg = try Config.default(testing.allocator); + defer cfg.deinit(); + const alloc = cfg._arena.?.allocator(); + + var it: TestIterator = .{ .data = &.{ "echo", "foo", "bar baz" } }; + try testing.expect(!try cfg.parseManuallyHook(alloc, "xdg-terminal-exec", &it)); + try testing.expectEqualStrings("echo foo bar baz", cfg.command.?); +} + +test "parse xdg-terminal-exec: command and args with abs path" { + const testing = std.testing; + var cfg = try Config.default(testing.allocator); + defer cfg.deinit(); + const alloc = cfg._arena.?.allocator(); + + var it: TestIterator = .{ .data = &.{ "echo", "foo", "bar baz" } }; + try testing.expect(!try cfg.parseManuallyHook(alloc, "/home/ghostty/.local/bin/xdg-terminal-exec", &it)); + try testing.expectEqualStrings("echo foo bar baz", cfg.command.?); +} + test "clone default" { const testing = std.testing; const alloc = testing.allocator;