mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-21 14:55:20 +00:00
testing: use std.Build.TranslateC instead of @cImport
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user