terminal: guard ghostty.h checks on building the app

This commit is contained in:
Mitchell Hashimoto
2026-03-23 08:58:56 -07:00
parent 374ed27214
commit 04b5dc7332
4 changed files with 11 additions and 6 deletions

View File

@@ -95,7 +95,10 @@ test "abi by removing a key" {
/// Verify that for every key in enum T, there is a matching declaration in
/// `ghostty.h` with the correct value. This should only ever be called inside a `test`
/// because the `ghostty.h` module is only available then.
pub fn checkGhosttyHEnum(comptime T: type, comptime prefix: []const u8) !void {
pub fn checkGhosttyHEnum(
comptime T: type,
comptime prefix: []const u8,
) !void {
const info = @typeInfo(T);
try std.testing.expect(info == .@"enum");

View File

@@ -260,9 +260,9 @@ pub const std_options: std.Options = options: {
test {
_ = terminal;
_ = @import("lib/main.zig");
@import("std").testing.refAllDecls(input);
if (comptime terminal.options.c_abi) {
_ = terminal.c_api;
}
// _ = @import("lib/main.zig");
// @import("std").testing.refAllDecls(input);
// if (comptime terminal.options.c_abi) {
// _ = terminal.c_api;
// }
}

View File

@@ -92,6 +92,7 @@ pub const Shape = enum(c_int) {
};
test "ghostty.h MouseShape" {
if (comptime build_options.artifact == .lib) return error.SkipZigTest;
try lib.checkGhosttyHEnum(Shape, "GHOSTTY_MOUSE_SHAPE_");
}
};

View File

@@ -205,6 +205,7 @@ pub const Command = union(Key) {
pause,
test "ghostty.h Command.ProgressReport.State" {
if (comptime build_options.artifact == .lib) return error.SkipZigTest;
try lib.checkGhosttyHEnum(State, "GHOSTTY_PROGRESS_STATE_");
}
};