Run GTK unit tests in CI, fix broken tests (#7878)

This commit is contained in:
Mitchell Hashimoto
2025-07-09 11:03:40 -07:00
committed by GitHub
4 changed files with 40 additions and 5 deletions

View File

@ -561,7 +561,16 @@ jobs:
name: ghostty
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Test GTK Build
- name: Test
run: |
nix develop -c \
zig build \
-Dapp-runtime=gtk \
-Dgtk-x11=${{ matrix.x11 }} \
-Dgtk-wayland=${{ matrix.wayland }} \
test
- name: Build
run: |
nix develop -c \
zig build \

View File

@ -103,7 +103,7 @@ pub inline fn runtimeUntil(
test "atLeast" {
const testing = std.testing;
const funs = &.{ atLeast, runtimeAtLeast, runtimeUntil };
const funs = &.{ atLeast, runtimeAtLeast };
inline for (funs) |fun| {
try testing.expect(fun(c.GTK_MAJOR_VERSION, c.GTK_MINOR_VERSION, c.GTK_MICRO_VERSION));
@ -118,3 +118,23 @@ test "atLeast" {
try testing.expect(fun(c.GTK_MAJOR_VERSION, c.GTK_MINOR_VERSION - 1, c.GTK_MICRO_VERSION + 1));
}
}
test "runtimeUntil" {
const testing = std.testing;
// This is an array in case we add a comptime variant.
const funs = &.{runtimeUntil};
inline for (funs) |fun| {
try testing.expect(!fun(c.GTK_MAJOR_VERSION, c.GTK_MINOR_VERSION, c.GTK_MICRO_VERSION));
try testing.expect(fun(c.GTK_MAJOR_VERSION, c.GTK_MINOR_VERSION, c.GTK_MICRO_VERSION + 1));
try testing.expect(fun(c.GTK_MAJOR_VERSION, c.GTK_MINOR_VERSION + 1, c.GTK_MICRO_VERSION));
try testing.expect(fun(c.GTK_MAJOR_VERSION + 1, c.GTK_MINOR_VERSION, c.GTK_MICRO_VERSION));
try testing.expect(!fun(c.GTK_MAJOR_VERSION - 1, c.GTK_MINOR_VERSION, c.GTK_MICRO_VERSION));
try testing.expect(!fun(c.GTK_MAJOR_VERSION - 1, c.GTK_MINOR_VERSION + 1, c.GTK_MICRO_VERSION));
try testing.expect(!fun(c.GTK_MAJOR_VERSION - 1, c.GTK_MINOR_VERSION, c.GTK_MICRO_VERSION + 1));
try testing.expect(!fun(c.GTK_MAJOR_VERSION, c.GTK_MINOR_VERSION - 1, c.GTK_MICRO_VERSION + 1));
}
}

View File

@ -17,7 +17,7 @@ test "read /proc/sys/kernel/osrelease" {
if (comptime builtin.os.tag != .linux) return null;
const allocator = std.testing.allocator;
const kernel_info = try getKernelInfo(allocator);
const kernel_info = getKernelInfo(allocator).?;
defer allocator.free(kernel_info);
// Since we can't hardcode the info in tests, just check

View File

@ -2,6 +2,8 @@
//! system. These aren't restricted to syscalls or low-level operations, but
//! also OS-specific features and conventions.
const builtin = @import("builtin");
const dbus = @import("dbus.zig");
const desktop = @import("desktop.zig");
const env = @import("env.zig");
@ -14,7 +16,7 @@ const openpkg = @import("open.zig");
const pipepkg = @import("pipe.zig");
const resourcesdir = @import("resourcesdir.zig");
const systemd = @import("systemd.zig");
const kernelInfo = @import("kernel_info.zig");
const kernel_info = @import("kernel_info.zig");
// Namespaces
pub const args = @import("args.zig");
@ -59,8 +61,12 @@ pub const pipe = pipepkg.pipe;
pub const resourcesDir = resourcesdir.resourcesDir;
pub const ResourcesDir = resourcesdir.ResourcesDir;
pub const ShellEscapeWriter = shell.ShellEscapeWriter;
pub const getKernelInfo = kernelInfo.getKernelInfo;
pub const getKernelInfo = kernel_info.getKernelInfo;
test {
_ = i18n;
if (comptime builtin.os.tag == .linux) {
_ = kernel_info;
}
}