summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 00:52:52 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit5157579ff7f9ae0cfc3c7629e953da05bce340fc (patch)
tree02147789efdcea998981efcfe05d4bcb3e9bb7b0 /src/main.zig
parent4c4b9bf54d77dbc0f9f4e2619746908e501c6001 (diff)
downloadpardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.tar.gz
pardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.zip
tests: at the end of their files: every top-level test block of the 46 files that had one mid-file (the locality analysis's 45 and test/hxdiff.zig; gui.zig, macos.zig, look, host_io, 9p_io, terminal, tui, mouse, fs, replica, layout among them, 11,429 test lines), with the functions only tests call, moved after the file's code in their order, a mechanical move (.scratch/suites/tests_to_end.py), zig fmt'd; the unit suites pass as before (tui 1486/1487, gui 1536/1537, core 956/956 on both), macos.zig only parse-checked here
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/main.zig b/src/main.zig
index c36c4eb7..c7f1f960 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -286,15 +286,6 @@ fn hasPane(index: []const u8, serial: u32) bool {
return false;
}
-test "--wait finds the pane /index names a file by, spaces and all, and sees it gone" {
- const index = "1 term 0 /home/u 1\n4 text 1 /tmp/a b.txt 2\n";
- try std.testing.expectEqual(@as(?u32, 4), paneShowing(index, "/tmp/a b.txt"));
- try std.testing.expectEqual(@as(?u32, null), paneShowing(index, "/tmp/a"));
- try std.testing.expect(hasPane(index, 4) and !hasPane(index, 2));
- try std.testing.expect(isDel("new 5 /x\ndel 4 /tmp/a b.txt\n", 4));
- try std.testing.expect(!isDel("del 41 /x\n", 4) and !isDel("undel 4\n", 4));
-}
-
fn badArgs(io: std.Io, comptime fmt: []const u8, args: anytype) noreturn {
die(io, fmt ++ "\nTry 'pardes --help'.", args);
}
@@ -349,18 +340,6 @@ fn libcResult(rc: usize) c_int {
return -1;
}
-test "tcgetattr writes nothing past a Zig termios" {
- if (comptime !(builtin.os.tag == .linux and builtin.abi.isGnu())) return error.SkipZigTest;
- const master = std.c.open("/dev/ptmx", .{ .ACCMODE = .RDWR, .NOCTTY = true, .CLOEXEC = true }, @as(std.c.mode_t, 0));
- if (master < 0) return error.SkipZigTest;
- defer _ = std.c.close(master);
- var s: extern struct { t: std.c.termios, canary: [32]u8 } = .{ .t = undefined, .canary = @splat(0xAA) };
- try std.testing.expectEqual(0, std.c.tcgetattr(master, &s.t));
- try std.testing.expectEqualSlices(u8, &@as([32]u8, @splat(0xAA)), &s.canary);
- try std.testing.expectEqual(0, std.c.tcsetattr(master, .NOW, &s.t));
- try std.testing.expectEqual(-1, std.c.tcgetattr(-1, &s.t));
-}
-
// init.gpa, what the tui, gui and detached shells allocate from, is their
// own fixed arena (memory.host) in a release build, spilling to libc's
// malloc, and std.start's DebugAllocator in Debug. Zig 0.17's std.start
@@ -1072,6 +1051,38 @@ fn parseCtrlKey(raw: []const u8) ?u21 {
return c;
}
+/// Where Recent's file (0.24) and the store before it were kept:
+/// $XDG_STATE_HOME/pardes, else ~/.local/state/pardes. A state file that
+/// holds no Recent yet reads them once (Db.zig).
+fn oldRecentDir(arena: std.mem.Allocator, env: *const std.process.Environ.Map) ?[]const u8 {
+ if (env.get("XDG_STATE_HOME")) |base| if (base.len != 0 and std.Io.Dir.path.isAbsolute(base))
+ return std.Io.Dir.path.join(arena, &.{ base, "pardes" }) catch null;
+ const home = env.get("HOME") orelse return null;
+ if (home.len == 0) return null;
+ return std.Io.Dir.path.join(arena, &.{ home, ".local", "state", "pardes" }) catch null;
+}
+
+test "--wait finds the pane /index names a file by, spaces and all, and sees it gone" {
+ const index = "1 term 0 /home/u 1\n4 text 1 /tmp/a b.txt 2\n";
+ try std.testing.expectEqual(@as(?u32, 4), paneShowing(index, "/tmp/a b.txt"));
+ try std.testing.expectEqual(@as(?u32, null), paneShowing(index, "/tmp/a"));
+ try std.testing.expect(hasPane(index, 4) and !hasPane(index, 2));
+ try std.testing.expect(isDel("new 5 /x\ndel 4 /tmp/a b.txt\n", 4));
+ try std.testing.expect(!isDel("del 41 /x\n", 4) and !isDel("undel 4\n", 4));
+}
+
+test "tcgetattr writes nothing past a Zig termios" {
+ if (comptime !(builtin.os.tag == .linux and builtin.abi.isGnu())) return error.SkipZigTest;
+ const master = std.c.open("/dev/ptmx", .{ .ACCMODE = .RDWR, .NOCTTY = true, .CLOEXEC = true }, @as(std.c.mode_t, 0));
+ if (master < 0) return error.SkipZigTest;
+ defer _ = std.c.close(master);
+ var s: extern struct { t: std.c.termios, canary: [32]u8 } = .{ .t = undefined, .canary = @splat(0xAA) };
+ try std.testing.expectEqual(0, std.c.tcgetattr(master, &s.t));
+ try std.testing.expectEqualSlices(u8, &@as([32]u8, @splat(0xAA)), &s.canary);
+ try std.testing.expectEqual(0, std.c.tcsetattr(master, .NOW, &s.t));
+ try std.testing.expectEqual(-1, std.c.tcgetattr(-1, &s.t));
+}
+
test {
_ = pardes.config.User;
_ = @import("crash.zig");
@@ -1096,14 +1107,3 @@ test {
if (comptime pardes.platform == .gui) _ = @import("gui/gui.zig");
if (comptime pardes.font_picker) _ = @import("fonts.zig");
}
-
-/// Where Recent's file (0.24) and the store before it were kept:
-/// $XDG_STATE_HOME/pardes, else ~/.local/state/pardes. A state file that
-/// holds no Recent yet reads them once (Db.zig).
-fn oldRecentDir(arena: std.mem.Allocator, env: *const std.process.Environ.Map) ?[]const u8 {
- if (env.get("XDG_STATE_HOME")) |base| if (base.len != 0 and std.Io.Dir.path.isAbsolute(base))
- return std.Io.Dir.path.join(arena, &.{ base, "pardes" }) catch null;
- const home = env.get("HOME") orelse return null;
- if (home.len == 0) return null;
- return std.Io.Dir.path.join(arena, &.{ home, ".local", "state", "pardes" }) catch null;
-}