diff options
Diffstat (limited to 'test/session.zig')
| -rw-r--r-- | test/session.zig | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/test/session.zig b/test/session.zig index 13798753..9285c13b 100644 --- a/test/session.zig +++ b/test/session.zig @@ -38,6 +38,8 @@ pub const Session = struct { /// What the language words' questions are asked of their servers /// through (initLanguage); none, and they go unanswered. languages: ?std.Io = null, + /// The server start a file's opening asks for (`languages`'s). + opener: pardes.host_io.Lsp.Opener = .{}, /// Kinds' jobs taken as a host's worker takes them and held, not run, /// until `releaseJobs`: a job under way across what a test does /// meanwhile (a reload). @@ -62,12 +64,19 @@ pub const Session = struct { } /// A session showing one scratch pane that asks language servers as a - /// host does, a `.rs` file's the scripted one (test/lspmock.zig, which - /// answers over a main.rs and the lib.rs beside it). + /// host does, a `.rs` and a `.zig` file's the scripted one + /// (test/lspmock.zig, which answers over a main.rs and the lib.rs beside + /// it), every other language's none: no test starts a server of this + /// machine's. pub fn initLanguage(gpa: std.mem.Allocator) !Session { var s = try initFile(gpa, "x\n"); const mock = try std.Io.Dir.cwd().realPathFileAlloc(std.testing.io, @import("session_options").lspmock, s.arena.allocator()); _ = setenv("PARDES_LSP_RS", mock, 1); + _ = setenv("PARDES_LSP_ZIG", mock, 1); + for ([_][*:0]const u8{ "PARDES_LSP_C", "PARDES_LSP_GO", "PARDES_LSP_TS", "PARDES_LSP_PY" }) |v| _ = setenv(v, "", 1); + // A test binary's opened files start their servers where it says + // so (lsp_client.open): here, the mock. + _ = setenv("PARDES_LSP_OPEN", "on", 1); s.languages = std.testing.io; return s; } @@ -295,6 +304,12 @@ pub const Session = struct { // held while a test holds them (`hold_jobs`). .job => |j| if (!s.hold_jobs) pardesOf(s).perform(e) else if (pardes.host_io.KindJob.take(pardesOf(s), j.pane.index(), j.serial, j.token)) |taken| s.held.append(pardesOf(s).gpa, taken) catch taken.drop(), .lsp => |q| if (s.languages) |io| s.askServer(io, .{ .id = q.id, .kind = q.kind, .pane = q.pane, .offset = q.offset, .arg = q.arg.slice() }), + // A file's server started as a host starts it, and waited for. + .lsp_open => |o| if (s.languages) |io| { + pardes.host_io.Lsp.open(io, pardesOf(s).gpa, pardesOf(s), &s.opener, o.pane); + if (s.opener.future) |*f| f.await(io); + s.opener.future = null; + }, .watch => |w| { if (s.watch_fd < 0) s.watch_fd = pardes.file_watch.init(true); if (s.watch_fd >= 0) _ = pardes.file_watch.applyEffect(pardesOf(s), std.Io.Threaded.global_single_threaded.io(), s.watch_fd, &s.watches, w.pane.index(), w.on, w.mode); |
