testing: use std.Build.TranslateC instead of @cImport

This commit is contained in:
Jeffrey C. Ollie
2026-02-27 10:13:03 -06:00
parent ea5b07d20f
commit cdf0dd15e9
8 changed files with 35 additions and 57 deletions

View File

@@ -93,18 +93,18 @@ 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.
/// `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 {
const info = @typeInfo(T);
try std.testing.expect(info == .@"enum");
try std.testing.expect(info.@"enum".tag_type == c_int);
try std.testing.expect(info.@"enum".is_exhaustive == true);
@setEvalBranchQuota(1000000);
const c = @cImport({
@cInclude("ghostty.h");
});
const c = @import("ghostty.h");
var set: std.EnumSet(T) = .initFull();
@@ -137,8 +137,8 @@ pub fn checkGhosttyHEnum(comptime T: type, comptime prefix: []const u8) !void {
var it = set.iterator();
while (it.next()) |v| {
var buf: [128]u8 = undefined;
const n = std.ascii.upperString(&buf, @tagName(v));
std.log.err("ghostty.h is missing value for {s}{s}, {t}", .{ prefix, n, v });
const upper_string = std.ascii.upperString(&buf, @tagName(v));
std.log.err("ghostty.h is missing value for {s}{s}", .{ prefix, upper_string });
}
return e;
};