mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 22:10:29 +00:00
shell-integration: add failure regression test
Add a unit test to prevent regressions in our failure state. For example, we always want to set GHOSTTY_SHELL_FEATURES, even if automatic shell integration fails, because it's also used for manual shell integration (e.g. #5048).
This commit is contained in:
@@ -70,7 +70,6 @@ pub fn setup(
|
||||
exe,
|
||||
);
|
||||
|
||||
// Setup our feature env vars
|
||||
try setupFeatures(env, features);
|
||||
|
||||
return result;
|
||||
@@ -168,6 +167,29 @@ test "force shell" {
|
||||
}
|
||||
}
|
||||
|
||||
test "shell integration failure" {
|
||||
const testing = std.testing;
|
||||
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
|
||||
var env = EnvMap.init(alloc);
|
||||
defer env.deinit();
|
||||
|
||||
const result = try setup(
|
||||
alloc,
|
||||
"/nonexistent",
|
||||
.{ .shell = "sh" },
|
||||
&env,
|
||||
null,
|
||||
.{ .cursor = true, .title = false, .path = false },
|
||||
);
|
||||
|
||||
try testing.expect(result == null);
|
||||
try testing.expectEqualStrings("cursor", env.get("GHOSTTY_SHELL_FEATURES").?);
|
||||
}
|
||||
|
||||
/// Set up the shell integration features environment variable.
|
||||
pub fn setupFeatures(
|
||||
env: *EnvMap,
|
||||
@@ -234,7 +256,7 @@ test "setup features" {
|
||||
var env = EnvMap.init(alloc);
|
||||
defer env.deinit();
|
||||
|
||||
try setupFeatures(&env, .{ .cursor = false, .sudo = false, .title = false, .@"ssh-env" = false, .@"ssh-terminfo" = false, .path = false });
|
||||
try setupFeatures(&env, std.mem.zeroes(config.ShellIntegrationFeatures));
|
||||
try testing.expect(env.get("GHOSTTY_SHELL_FEATURES") == null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user