diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/behaviour/addons.zig | 11 | ||||
| -rw-r--r-- | test/behaviour/other_files.zig | 4 | ||||
| -rw-r--r-- | test/process/other_files.zig | 60 |
3 files changed, 71 insertions, 4 deletions
diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index 90f4e383..0b0555c2 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -411,8 +411,10 @@ test "addons: a picker shows a file of an addon's kind through its kind in the p try s.expect(body, "the notes\n"); try std.testing.expectEqualStrings(index, try s.read("/index")); // Enter: the kind's pane where a Look puts it; the reading pane keeps - // its text. - try s.keys(" ffseven\n"); + // its text. (The listing is the next frame's, as for the keyboard.) + try s.keys(" ffseven"); + s.tick(); + try s.keys("\n"); s.tick(); const opened = try paneOf(&s, "fake"); try std.testing.expect(opened != pane); @@ -516,7 +518,10 @@ test "addons: Enter on a picture in a picker opens its kind's pane, never its by defer unload(&s, "image"); const dir = try dirOf(&s, &tmp); const pane = try s.lookFile(s.at("{s}/notes.txt", .{dir})); - try s.keys(" ffpic\n"); + // The listing is the next frame's, as for the keyboard. + try s.keys(" ffpic"); + s.tick(); + try s.keys("\n"); s.tick(); try s.expect(s.at("/pane/{d}/body", .{pane}), "the notes\n"); const image = try paneOf(&s, "image"); diff --git a/test/behaviour/other_files.zig b/test/behaviour/other_files.zig index 8a9016bc..95d4de6d 100644 --- a/test/behaviour/other_files.zig +++ b/test/behaviour/other_files.zig @@ -35,7 +35,9 @@ test "other-files: kbdin's keys are the user's: SPC f f opens Find's picker in t _ = try s.lookFile(s.at("{s}/a.txt", .{buf[0..try tmp.dir.realPath(std.testing.io, &buf)]})); try s.keys(" ff"); try std.testing.expect(std.mem.indexOf(u8, try s.read("/index"), "+Search") == null); - // Its rows under the tag of the pane typed at, the cursor on the first. + // Its rows under the tag of the pane typed at, the cursor on the first, + // the next frame, as the keyboard's: the listing is not the write's. + s.tick(); _ = try s.where("▶ a.txt"); _ = try s.where(" b.txt"); } diff --git a/test/process/other_files.zig b/test/process/other_files.zig index 69f65884..48ba06d0 100644 --- a/test/process/other_files.zig +++ b/test/process/other_files.zig @@ -8,6 +8,8 @@ pub const cases = .{ .{ "other-files: a held connection lists a directory, stats a file, writes and reads, is refused in words and removes a pane", heldConnection }, .{ "other-files: a file opened and closed is in /recent closed, and still is in the next session; Recent's row opens it again", recentSurvivesRestart }, .{ "other-files: two sessions share Recent: a file opened in one is in the other's /recent, a Del'd pane comes back from @p only where it was", recentShared }, + .{ "other-files: kbdin's SPC f f over a work tree of 20,000 files is answered before the listing, which a worker runs as the keyboard's, its rows after", findOnWorker }, + .{ "other-files: kbdin's SPC s s lists the declarations of a file over 64 KB, parsed on a worker as the keyboard's are", symbolsOnWorker }, }; extern "c" fn system(cmd: [*:0]const u8) c_int; @@ -185,3 +187,61 @@ fn recentShared(gpa: std.mem.Allocator, exe: [:0]const u8) !void { } try std.testing.expect(stateExists(root)); } + +/// A kbdin `SPC f f` over a work tree of 20,000 files: the keys handled and +/// the write answered, the listing run on a worker as the keyboard's is, +/// its rows on the screen after. (Before, the listing ran on the loop in the +/// write: over V8's 18,441 files a script's `SPC f g` held the session past +/// its client's timeout.) +fn findOnWorker(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var d = try process.Detached.start(gpa, exe, "kbdfind", .{}); + defer d.deinit(); + const f = &d.files; + const eh = @import("../e2e_harness.zig"); + var buf: [4096]u8 = undefined; + const tree = f.at("{s}/tree", .{d.root()}); + for ([_][]const u8{ "", "/.git" }) |sub| _ = std.c.mkdir(try std.fmt.bufPrintSentinel(&buf, "{s}{s}", .{ tree, sub }, 0), 0o755); + for (0..200) |dir| { + _ = std.c.mkdir(try std.fmt.bufPrintSentinel(&buf, "{s}/d{d:0>3}", .{ tree, dir }, 0), 0o755); + for (0..100) |i| try eh.writeFile(try std.fmt.bufPrintSentinel(&buf, "{s}/d{d:0>3}/f{d:0>3}.txt", .{ tree, dir, i }, 0), ""); + } + try eh.writeFile(try std.fmt.bufPrintSentinel(&buf, "{s}/zzlast.txt", .{tree}, 0), "last\n"); + try eh.writeFile(try std.fmt.bufPrintSentinel(&buf, "{s}/notes.txt", .{tree}, 0), "notes\n"); + try f.write("/look", f.at("{s}/notes.txt\n", .{tree})); + const t0 = process.nowMs(); + try f.keys(" ffzzlast"); + const answered = process.nowMs() - t0; + const listed = while (true) { + if (has(try f.screen(), "zzlast.txt")) break process.nowMs() - t0; + if (process.nowMs() - t0 > 30_000) return error.RowsNeverCame; + process.nap(5); + }; + try process.check(answered * 3 < listed, "kbdin's SPC f f answered after {d} ms, its row there after {d} ms: the listing ran in the write", .{ answered, listed }); + try f.keys("\x1b"); +} + +/// kbdin's `SPC s s` over a file of more than 64 KB: its declarations +/// parsed on a worker, as the keyboard's are, and listed. (Before, the +/// keys ran as a script's write, whose parse has no worker and leaves a +/// text this big unparsed: the picker listed nothing.) +fn symbolsOnWorker(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var d = try process.Detached.start(gpa, exe, "kbdsym", .{}); + defer d.deinit(); + const f = &d.files; + var text: std.ArrayList(u8) = .empty; + defer text.deinit(gpa); + // Two lines each: a declaration on one line is none (syntax.contextSpan). + for (0..4000) |i| try text.print(gpa, "fn f{d:0>4}() void {{\n}}\n", .{i}); + try text.appendSlice(gpa, "fn zzlastfn() void {\n}\n"); + try process.check(text.items.len > 64 << 10, "{d} bytes", .{text.items.len}); + var buf: [4096]u8 = undefined; + try @import("../e2e_harness.zig").writeFile(try std.fmt.bufPrintSentinel(&buf, "{s}/big.zig", .{d.root()}, 0), text.items); + try f.write("/look", f.at("{s}/big.zig\n", .{d.root()})); + try f.keys(" sszzlast"); + const t0 = process.nowMs(); + while (!has(try f.screen(), "zzlastfn")) { + if (process.nowMs() - t0 > 20_000) return process.check(false, "kbdin's SPC s s over big.zig listed nothing", .{}); + process.nap(10); + } + try f.keys("\x1b"); +} |
