summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/behaviour/panes.zig1
-rw-r--r--test/behaviour/settings.zig2
-rw-r--r--test/consumer/bench.zig (renamed from test/lib/bench.zig)0
-rw-r--r--test/consumer/build.zig42
-rw-r--r--test/consumer/build.zig.zon16
-rw-r--r--test/consumer/editor.zig (renamed from test/lib/editor.zig)0
-rw-r--r--test/consumer/lib.zig (renamed from test/lib/lib.zig)0
-rw-r--r--test/daemon.py365
-rw-r--r--test/delay_relay.py10
-rw-r--r--test/fs_namespace.zig3
-rw-r--r--test/lib/build.zig34
-rw-r--r--test/lib/build.zig.zon10
-rw-r--r--test/output.zig11
-rw-r--r--test/panes.zig12
-rw-r--r--test/process.zig3
-rw-r--r--test/process/terminals.zig9
-rw-r--r--test/process/tty_terminals.zig4
-rw-r--r--test/terminal.zig2
18 files changed, 425 insertions, 99 deletions
diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig
index dcde9c4d..4d4c812c 100644
--- a/test/behaviour/panes.zig
+++ b/test/behaviour/panes.zig
@@ -888,7 +888,6 @@ test "panes: truncating body empties it, and a stat says the length after" {
}
test "panes: a rename colours a source its new name's language names, its text unchanged" {
- if (@import("pardes_options").grammars == .disabled) return error.SkipZigTest;
var s = try Session.initFile(std.testing.allocator, "fn check() void {}\n");
defer s.deinit();
const n = try s.focused();
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig
index cacee701..a6e09f35 100644
--- a/test/behaviour/settings.zig
+++ b/test/behaviour/settings.zig
@@ -158,7 +158,6 @@ test "settings: Back and Forward written to exec keep to the focused file" {
});
}
-const syntax = @import("pardes_options").grammars != .disabled;
/// The style /screen draws the cell `into` cells into the first place
/// `text` is drawn.
@@ -190,7 +189,6 @@ fn keywordsIn(s: *Session, want: []const u8) !usize {
}
test "settings: keywords stay coloured in every row a pane grows into" {
- if (!syntax) return error.SkipZigTest;
var s = try Session.initFile(std.testing.allocator, std.mem.asBytes(&@as([100][33]u8, @splat("pub fn f() void { if (true) {} }\n".*))));
defer s.deinit();
try s.write(s.at("/pane/{d}/name", .{try s.focused()}), "/resize.zig\n");
diff --git a/test/lib/bench.zig b/test/consumer/bench.zig
index 7e945064..7e945064 100644
--- a/test/lib/bench.zig
+++ b/test/consumer/bench.zig
diff --git a/test/consumer/build.zig b/test/consumer/build.zig
new file mode 100644
index 00000000..ca63bb6e
--- /dev/null
+++ b/test/consumer/build.zig
@@ -0,0 +1,42 @@
+//! A package that depends on pardes, as a program would (build.zig's head
+//! comment has its lines): pardes's `lib-test`, which `unit-test` runs,
+//! runs `zig build test` here. `pardes-syntax` with the minimal grammars,
+//! as a program that draws source text itself takes it; and
+//! `pardes-editor` with no grammar of pardes's and one of its own, C's,
+//! compiled here from the package pardes pins and handed in at run time,
+//! as sketchbook's `examples/live` takes it.
+const std = @import("std");
+
+pub fn build(b: *std.Build) void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+ const syntax = b.dependency("pardes", .{ .target = target, .optimize = optimize, .grammars = .minimal });
+ const editor = b.dependency("pardes", .{ .target = target, .optimize = optimize, .grammars = .none, .editor = true });
+ // The grammar of its own: C's, from the package pardes's manifest pins
+ // (so `--pkg-dir` at pardes's zig-pkg has it), as that package builds it.
+ const grammar = b.dependency("ts_c", .{ .target = target, .optimize = .ReleaseFast, .@"build-shared" = false }).artifact("tree-sitter-c");
+ const step = b.step("test", "colour, outline and walk a C and a Zig source through pardes's syntax, and edit a text with its editor and a grammar of this package's");
+ // A file belongs to one module: the syntax alone, and the editor (which
+ // has it as `.syntax`), each a test of its own.
+ for ([_]struct { []const u8, []const u8, *std.Build.Dependency }{ .{ "lib.zig", "pardes-syntax", syntax }, .{ "editor.zig", "pardes-editor", editor } }) |t| {
+ const mod = b.createModule(.{
+ .target = target,
+ .optimize = optimize,
+ .root_source_file = b.path(t[0]),
+ .imports = &.{.{ .name = t[1], .module = t[2].module(t[1]) }},
+ });
+ if (t[2] == editor) mod.linkLibrary(grammar);
+ step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mod })).step);
+ }
+ // What a key costs, a page count and a parse: `zig build bench -- <KiB> <keys>`.
+ const bench = b.addExecutable(.{ .name = "bench", .root_module = b.createModule(.{
+ .target = target,
+ .optimize = optimize,
+ .root_source_file = b.path("bench.zig"),
+ .imports = &.{.{ .name = "pardes-editor", .module = editor.module("pardes-editor") }},
+ }) });
+ bench.root_module.linkLibrary(grammar);
+ const run_bench = b.addRunArtifact(bench);
+ run_bench.addPassthruArgs();
+ b.step("bench", "a key typed into the library's editor at a size, its pages and a parse").dependOn(&run_bench.step);
+}
diff --git a/test/consumer/build.zig.zon b/test/consumer/build.zig.zon
new file mode 100644
index 00000000..c367775b
--- /dev/null
+++ b/test/consumer/build.zig.zon
@@ -0,0 +1,16 @@
+.{
+ .name = .pardes_consumer,
+ .version = "0.0.0",
+ .dependencies = .{
+ .pardes = .{ .path = "../.." },
+ // The grammar this package hands pardes's editor: the one pardes's
+ // own manifest pins, so `--pkg-dir` at its zig-pkg has it.
+ .ts_c = .{
+ .url = "git+https://github.com/pierrelgol/tree-sitter-c#67949e4c8dc630c18a522919f2bde2e025a0d025",
+ .hash = "tree_sitter_c-0.24.2-y5boS-htQACe3pz6jHq4tpS8dB6WIo4-zk_ct7lAjvQT",
+ },
+ },
+ .minimum_zig_version = "0.17.1",
+ .paths = .{""},
+ .fingerprint = 0xb5ce4ba417a79812,
+}
diff --git a/test/lib/editor.zig b/test/consumer/editor.zig
index 22690915..22690915 100644
--- a/test/lib/editor.zig
+++ b/test/consumer/editor.zig
diff --git a/test/lib/lib.zig b/test/consumer/lib.zig
index 7e297920..7e297920 100644
--- a/test/lib/lib.zig
+++ b/test/consumer/lib.zig
diff --git a/test/daemon.py b/test/daemon.py
index d134732b..f8402af2 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -25,8 +25,13 @@ private HOME and runtime directory:
`ssh -L` forwards, say), timed
python3 -B test/daemon.py --clients <pardes>
the replica clients alone
+ python3 -B test/daemon.py --launch <pardes>
+ `pardes new --detach` returns once its session runs
+ python3 -B test/daemon.py --pair <pardes>
+ PARDES_PAIR: a terminal's session and its first client
python3 -B test/daemon.py --relink <pardes>
- the daemon killed: its sessions register again with the next
+ the daemon killed: its sessions register again with the next; and
+ one stopped: an Adopt waits for its answer to the hello
python3 -B test/daemon.py --far <pardes>
the far clients and their blob cache alone, and a file by its hash
python3 -B test/daemon.py --games <pardes> <lib> [seconds]
@@ -265,8 +270,11 @@ class Replica:
is read, whole. A daemon of another replica protocol (an older
build's, across an Upgrade) is dialled again in its own."""
name = session.encode()
- self.send(0x01, struct.pack('<HQH', wire or self.WIRE, build, len(name)) + name + b'\xff')
- self.send(0x06, b'\x00')
+ # Its first word (not far) in the same write, as a client's join
+ # sends it (core/replica.zig joinOn): a refused hello's connection
+ # is closed, and a second write after it would meet that.
+ hello = struct.pack('<HQH', wire or self.WIRE, build, len(name)) + name + b'\xff'
+ self.s.sendall(struct.pack('<BI', 0x01, len(hello)) + hello + struct.pack('<BIB', 0x06, 1, 0))
tag, body = self.read()
if tag == 0x01:
pid, n = struct.unpack_from('<IH', body)
@@ -479,10 +487,10 @@ def clients(binary):
wait_for('client A out of insert mode', lambda: normal_again(ta))
wait_for('client A agrees again', lambda: agreed(root / 'a.check', seen))
assert sess.poll() is None
- # Detach typed in it: it alone goes.
+ # Detach typed in it: it alone goes, and says so (exit 0).
os.write(ta.master, b' sD')
wait_for('client A let go', lambda: a.poll() is not None, timeout=10)
- assert b'let this client go' in ta.text(), ta.text()[-300:]
+ assert a.returncode == 0 and b"detached from 'files', which is still running" in ta.text(), ta.text()[-300:]
# A third client, a shell: its keys wait for the session (a pty
# write), its output comes back in units, the same on both sides.
nine.write(f'/pane/{pane}/exec', b'Term\n')
@@ -526,6 +534,234 @@ def clients(binary):
shutil.rmtree(root, ignore_errors=True)
+def launch(binary):
+ """`pardes new --detach=NAME` returns once its session is registered
+ and listening: exit 0, the name on stdout, the session a process of its
+ own in a session of its own, listed by `ps` and answering 9P at once;
+ bare `--detach`, its pid is its name; a name taken is refused in words,
+ exit 1; `pardes --detach=NAME` (no `new`) is still the session itself;
+ nothing left behind."""
+ scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn'
+ scratch.mkdir(parents=True, exist_ok=True)
+ root = Path(tempfile.mkdtemp(prefix='rl-', dir=scratch))
+ env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k}
+ env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'),
+ TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1')
+ (root / 'config' / 'pardes').mkdir(parents=True)
+ (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n')
+ (root / 'notes.txt').write_text('notes\n')
+
+ def cli(*args, timeout=30):
+ return subprocess.run([binary, *args], env=env, cwd=root, capture_output=True, timeout=timeout,
+ stdin=subprocess.DEVNULL)
+
+ def status_pid(name):
+ with Client(root / f'pardes-9p-{name}.sock') as c:
+ return int(dict(line.split(maxsplit=1) for line in c.read('/status').decode().splitlines())['pid'])
+
+ try:
+ t0 = time.monotonic()
+ try:
+ out = cli('new', '--detach=work', 'notes.txt', timeout=15)
+ except subprocess.TimeoutExpired:
+ raise AssertionError(f'launch: `new --detach=work` had not returned after {time.monotonic() - t0:.1f} s')
+ took = time.monotonic() - t0
+ assert out.returncode == 0 and out.stdout == b'work\n', out
+ # Registered and listening when it returned: no wait here.
+ assert (root / 'pardes-9p-work.sock').exists(), list(root.iterdir())
+ pid = status_pid('work')
+ listed = cli('ps').stdout.decode()
+ assert f'session work {pid} (tty, detached)' in listed, listed
+ assert alive(pid) and os.getsid(pid) == pid, (pid, os.getsid(pid))
+ out = cli('new', '--detach')
+ assert out.returncode == 0 and out.stdout.strip().isdigit(), out
+ unnamed = int(out.stdout)
+ assert status_pid(str(unnamed)) == unnamed and f'session {unnamed} {unnamed} (tty, detached)' in cli('ps').stdout.decode()
+ taken = cli('new', '--detach=work')
+ assert taken.returncode == 1 and taken.stderr == b'pardes: a session named work is already running\n', taken
+ # The flag alone runs the session in this process, as a supervisor
+ # or a harness wants it.
+ fg = subprocess.Popen([binary, '--detach=fg'], env=env, cwd=root, stdin=subprocess.DEVNULL,
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True)
+ wait_for('the foreground session\'s socket', (root / 'pardes-9p-fg.sock').exists)
+ assert status_pid('fg') == fg.pid and fg.poll() is None
+ print(f'launch: `new --detach=work` returned 0 in {took:.2f} s with its name, session {pid} listed and listening '
+ f'in a session of its own; unnamed it said {unnamed}; a taken name refused; `--detach=fg` is its own session')
+ for name in ('work', str(unnamed), 'fg'):
+ assert cli('kill', name).returncode == 0
+ fg.wait(timeout=10)
+ wait_for('nothing left', lambda: not [p for p in processes(root) if alive(p)], timeout=10)
+ print('launch: nothing left behind')
+ finally:
+ for p in processes(root):
+ try:
+ os.kill(p, signal.SIGKILL)
+ except OSError:
+ pass
+ shutil.rmtree(root, ignore_errors=True)
+
+
+def pair(binary):
+ """PARDES_PAIR: `pardes FILE` in a terminal is a session forked off for
+ it with this terminal its first client (the last step's design, 1.1):
+ the job the client, the terminal its own; the session its child, in a
+ session of its own, registered (`ps`: detached, the client listed),
+ the file drawn, keys in, the digests agreed once quiet; the session's
+ Exit ends both. With no daemon the client killed outright ends the
+ session (its last link). Nothing left behind."""
+ scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn'
+ scratch.mkdir(parents=True, exist_ok=True)
+ root = Path(tempfile.mkdtemp(prefix='rp-', dir=scratch))
+ env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k}
+ env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'),
+ TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_PAIR='1')
+ (root / 'config' / 'pardes').mkdir(parents=True)
+ (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n')
+ notes = root / 'notes.txt'
+ notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30)))
+ terms = []
+
+ def session_of(name):
+ sock = root / f'pardes-9p-{name}.sock'
+ wait_for(f'session {name}\'s 9P socket', sock.exists)
+ nine = Client(sock)
+ return nine, int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid'])
+
+ try:
+ t = Term(30, 100)
+ terms.append(t)
+ c = t.spawn([binary, '--9p=pair', str(notes)], dict(env, PARDES_REPLICA_CHECK=str(root / 'pair.check')))
+ nine, session = session_of('pair')
+ assert session != c.pid and ppid(session) == c.pid and os.getsid(session) == session, (session, c.pid)
+ wait_for('the file drawn on the terminal', lambda: b'line 3 of the notes' in t.text(), timeout=30)
+ listed = lambda: subprocess.run([binary, 'ps'], env=env, capture_output=True).stdout.decode()
+ wait_for('the client listed', lambda: f'session pair {session} (tty, detached)' in listed()
+ and f'client {c.pid} ' in listed())
+ pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text')
+ os.write(t.master, b'Ofrom-the-pair\x1b')
+ wait_for('its keys in the session\'s text', lambda: b'from-the-pair' in nine.read(f'/pane/{pane}/body'))
+ wait_for('out of insert mode', lambda: normal_again(t))
+ wait_for('the client agrees once quiet', lambda: agreed(root / 'pair.check', 0))
+ exit_session(nine, pane)
+ code = c.wait(timeout=60)
+ assert code == 0 and not alive(session), (code, alive(session))
+ print(f'pair: client {c.pid} (the job) and session {session} (its child, setsid, listed detached with the client); '
+ f'drawn, typed, agreed; Exit ended both (the client exit {code})')
+ nine.socket.close()
+ lone = Term(24, 80)
+ terms.append(lone)
+ c2 = lone.spawn([binary, '--9p=lone', str(notes)], dict(env, PARDES_DAEMON='off'))
+ nine2, session2 = session_of('lone')
+ wait_for('the lone pair drawn', lambda: b'line 3 of the notes' in lone.text(), timeout=30)
+ nine2.socket.close()
+ os.kill(c2.pid, signal.SIGKILL)
+ c2.wait(timeout=10)
+ wait_for('the lone session ended with its last link', lambda: not alive(session2), timeout=20)
+ wait_for('nothing left', lambda: not [p for p in processes(root) if alive(p)], timeout=20)
+ print(f'pair: with no daemon, client {c2.pid} killed outright, its session {session2} ended; nothing left behind')
+ finally:
+ for p in processes(root):
+ try:
+ os.kill(p, signal.SIGKILL)
+ except OSError:
+ pass
+ for t in terms:
+ t.close()
+ shutil.rmtree(root, ignore_errors=True)
+
+
+def pair_rows(binary):
+ """PARDES_PAIR, the shell's view (the last step's design, 1.1) and a
+ session's lifetime (2.2 B), one row a step. With a daemon: a Detach in
+ the pair's client says so and exits 0, the session runs on (listed); an
+ attach is a client again; TERM to the client puts its terminal back and
+ the session runs on; so does a KILL, and a closed terminal (HUP): each a
+ loss, not a close. With none: a Detach refused (nothing could attach),
+ the client on; its terminal closed, the session ends with its last link."""
+ scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn'
+ scratch.mkdir(parents=True, exist_ok=True)
+ root = Path(tempfile.mkdtemp(prefix='rq-', dir=scratch))
+ env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k}
+ env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'),
+ TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_PAIR='1')
+ (root / 'config' / 'pardes').mkdir(parents=True)
+ (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n')
+ notes = root / 'notes.txt'
+ notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30)))
+ terms = []
+
+ def listed():
+ return subprocess.run([binary, 'ps'], env=env, capture_output=True).stdout.decode()
+
+ def drawn(t):
+ wait_for('drawn', lambda: b'line 3 of the notes' in t.text(), timeout=30)
+
+ def typed_detach(t, nine, pane):
+ # Its view the live one (it typed last), then the word.
+ os.write(t.master, b'j')
+ time.sleep(.3)
+ nine.write(f'/pane/{pane}/exec', b'Detach\n')
+
+ def started(name, e):
+ t = Term(30, 100)
+ terms.append(t)
+ c = t.spawn([binary, f'--9p={name}', str(notes)], e)
+ wait_for('the socket', (root / f'pardes-9p-{name}.sock').exists)
+ nine = Client(root / f'pardes-9p-{name}.sock')
+ session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid'])
+ pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text')
+ drawn(t)
+ return t, c, nine, session, pane
+
+ try:
+ t, c, nine, session, pane = started('rows', env)
+ typed_detach(t, nine, pane)
+ assert c.wait(timeout=20) == 0, c.returncode
+ wait_for('the detach said', lambda: b"pardes: detached from 'rows', which is still running; come back with `pardes attach rows`" in t.text())
+ assert alive(session) and f'session rows {session} (tty, detached)' in listed()
+ print('pair rows: Detach in the client: said, exit 0; the session runs on, listed')
+ for how in ('TERM', 'KILL', 'HUP'):
+ tt = Term(30, 100)
+ terms.append(tt)
+ a = tt.spawn([binary, 'attach', 'rows'], env)
+ drawn(tt)
+ wait_for('the client listed', lambda: f'client {a.pid} ' in listed())
+ if how == 'HUP':
+ tt.close()
+ terms.remove(tt)
+ else:
+ os.kill(a.pid, getattr(signal, 'SIG' + how))
+ a.wait(timeout=20)
+ if how == 'TERM':
+ wait_for('its terminal put back', lambda: tt.text().rfind(b'\x1b[?1049l') > tt.text().rfind(b'\x1b[?1049h'))
+ wait_for('the client unlisted', lambda: f'client {a.pid} ' not in listed())
+ assert alive(session), how
+ print(f'pair rows: a client ended by {how}: the session runs on')
+ nine.socket.close()
+ assert subprocess.run([binary, 'kill', 'rows'], env=env, capture_output=True, timeout=30).returncode == 0
+ wait_for('the session ended', lambda: not alive(session), timeout=30)
+ t, c, nine, session, pane = started('lone', dict(env, PARDES_DAEMON='off'))
+ typed_detach(t, nine, pane)
+ time.sleep(1)
+ assert c.poll() is None and alive(session), 'a Detach with no daemon is refused'
+ nine.socket.close()
+ t.close()
+ terms.remove(t)
+ c.wait(timeout=20)
+ wait_for('the lone session ended with its last link', lambda: not alive(session), timeout=20)
+ wait_for('nothing left', lambda: not [p for p in processes(root) if alive(p)], timeout=20)
+ print('pair rows: no daemon: a Detach refused, the client on; its terminal closed, the session ended; nothing left')
+ finally:
+ for p in processes(root):
+ try:
+ os.kill(p, signal.SIGKILL)
+ except OSError:
+ pass
+ for t in terms:
+ t.close()
+ shutil.rmtree(root, ignore_errors=True)
+
+
def manage(binary):
"""`pardes --ps`, `--kill=NAME` and `--kill-all`: two detached sessions
and their shells listed, one session killed outright and its shell
@@ -736,6 +972,78 @@ def relink(binary):
shutil.rmtree(root, ignore_errors=True)
+def answer_late(binary):
+ """A session's Adopt asked at once, while its daemon has not answered
+ its hello (stopped 3 s, as a loaded machine can keep it), and before
+ the session's reader of the daemon has run: answered when the daemon
+ answers, never refused on a clock (daemon.zig `kept`)."""
+ scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn'
+ scratch.mkdir(parents=True, exist_ok=True)
+ root = Path(tempfile.mkdtemp(prefix='ra-', dir=scratch))
+ env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k}
+ env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'),
+ TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1')
+ (root / 'config' / 'pardes').mkdir(parents=True)
+ (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n')
+ started = []
+ terms = []
+ wake = None
+ try:
+ term = Term()
+ terms.append(term)
+ stub = term.spawn([binary, '--tty', '--9p=one'], env)
+ started.append(stub.pid)
+ wait_for('the first session', (root / 'pardes-9p-one.sock').exists)
+ one = Client(root / 'pardes-9p-one.sock')
+ session = int(dict(line.split(maxsplit=1) for line in one.read('/status').decode().splitlines())['pid'])
+ started.append(session)
+ shell_pid = int(run(one, terminals(one)[0], b'echo $$\n').split(b'\n')[1])
+ started.append(shell_pid)
+ daemon = [p for p in processes(root) if cmdline(p)[1:2] == [b'--daemon']][0]
+ started.append(daemon)
+ wait_for('its shell listed', lambda: f'shell {shell_pid}' in subprocess.run(
+ [binary, '--ps'], env=env, capture_output=True, timeout=30).stdout.decode())
+ os.kill(session, signal.SIGKILL)
+ one.socket.close()
+ wait_for('the killed session gone', lambda: not alive(session))
+ os.kill(daemon, signal.SIGSTOP)
+ wake = threading.Timer(3, lambda: os.kill(daemon, signal.SIGCONT))
+ wake.start()
+ term = Term()
+ terms.append(term)
+ stub = term.spawn([binary, '--tty', '--9p=two'], env)
+ started.append(stub.pid)
+ wait_for('the next session', (root / 'pardes-9p-two.sock').exists)
+ two = Client(root / 'pardes-9p-two.sock', timeout=30)
+ started.append(int(dict(line.split(maxsplit=1) for line in two.read('/status').decode().splitlines())['pid']))
+ before = set(terminals(two))
+ asked = time.monotonic()
+ two.write(f'/pane/{min(before)}/exec', b'Adopt\n')
+ took = time.monotonic() - asked
+ pane = wait_for('the adopted pane', lambda: set(terminals(two)) - before).pop()
+ assert run(two, pane, b'echo $$\n').split(b'\n')[1] == str(shell_pid).encode()
+ print(f'answer late: an Adopt asked while the daemon was stopped waited {took:.1f} s for its answer, '
+ f'and shell {shell_pid} was adopted')
+ exit_session(two, pane)
+ two.socket.close()
+ wait_for('the shells hung up', lambda: not alive(shell_pid))
+ wait_for('the daemon gone once idle', lambda: not alive(daemon), timeout=5)
+ finally:
+ if wake:
+ wake.cancel()
+ for t in terms:
+ try:
+ t.close()
+ except OSError:
+ pass
+ for pid in started + processes(root):
+ try:
+ os.kill(pid, signal.SIGKILL)
+ except (ProcessLookupError, PermissionError):
+ pass
+ shutil.rmtree(root, ignore_errors=True)
+
+
class Window:
"""A pardes-gui in test mode, its window offscreen and hidden, its keys
written to its stdin (the test feed: Escape as `CSI 27 u`, which a
@@ -966,10 +1274,10 @@ def window_clients(binary, gui_binary):
wait_for('the window\'s keys after the upgrade', lambda: b'after-upgrade-W' in body(), timeout=30)
wait_for('the window client agrees after the upgrade', lambda: agreed(dcheck, seen), timeout=30)
assert wd.p.poll() is None
- # Detach typed in it: it alone goes, and says why.
+ # Detach typed in it: it alone goes, and says so (exit 0).
wd.keys(b' sD')
wait_for('the window client let go', lambda: wd.p.poll() is not None, timeout=15)
- assert 'let this client go' in wd.said(), wd.said()[-500:]
+ assert wd.p.returncode == 0 and "detached from 'files', which is still running" in wd.said(), wd.said()[-500:]
# A link a line: the first join sent every blob, its rejoins held them.
links = joins(root / 'wd.stats')
assert len(links) == 3 and links[0]['blobs'] > 0 and links[0]['from_memory'] + links[0]['from_disk'] == 0, links
@@ -1183,12 +1491,13 @@ def far(binary):
f_join = joins(root / 'f.stats')[0]
assert f_join['from_disk'] > 0 and cached(cache) <= (1 << 20) + (64 << 10), (f_join, cached(cache))
far_joins(root / 'pardes-replica.sock', 'files', binary, 200)
- # Through ssh (a stand-in forwarding as `ssh -L` does): a client
- # refused and one detached each end their ssh and its socket (one
- # refused left both, 2026-10-30).
+ # Through ssh (a stand-in forwarding as `ssh -L` does, its socket
+ # bound 0.5 s before it listens: the client dials until it answers):
+ # a client refused and one detached each end their ssh and its
+ # socket (one refused left both, 2026-10-30).
fake = root / 'ssh'
fake.write_text('#!/bin/sh\nwhile [ $# -gt 0 ]; do case $1 in -L) fwd=$2; shift;; esac; shift; done\n'
- f'exec {sys.executable} -B {Path(__file__).parent / "delay_relay.py"} "${{fwd%%:*}}" "${{fwd#*:}}" --delay 0\n')
+ f'exec {sys.executable} -B {Path(__file__).parent / "delay_relay.py"} "${{fwd%%:*}}" "${{fwd#*:}}" --delay 0 --bound 500\n')
fake.chmod(0o755)
senv = dict(env, PARDES_SSH=str(fake), PARDES_REMOTE_RUNTIME=str(root), TMPDIR=str(root))
@@ -1272,7 +1581,10 @@ def by_hash(binary):
started.append(sess.pid)
wait_for('the replica socket', (root / 'pardes-replica.sock').exists)
wait_for('the session\'s 9P socket', (root / 'pardes-9p-files.sock').exists)
- nine = Client(root / 'pardes-9p-files.sock')
+ # Each reply waited for as long as the opens it answers take: the
+ # 17 MiB file's Look took 1.6-6.6 s in a Debug build at a load of
+ # 35 (ninep.py's 5 s is a reply's whole wait).
+ nine = Client(root / 'pardes-9p-files.sock', timeout=60)
pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text')
(ta, a), (tf, f) = client('a', False), client('f', True)
seen = {n: len(checks(root / f'{n}.check')) for n in 'af'}
@@ -1521,8 +1833,12 @@ def main(binary, cycles):
clients(binary)
far(binary)
by_hash(binary)
+ launch(binary)
+ pair(binary)
+ pair_rows(binary)
manage(binary)
relink(binary)
+ answer_late(binary)
shell = terminals(client)[0]
shell_pid = int(run(client, shell, b'echo $$\n').split(b'\n')[1])
started.append(shell_pid)
@@ -1557,8 +1873,8 @@ def main(binary, cycles):
terminal closed: it ends; the session and its shell run on."""
if how == 'detach':
client.write(f'/pane/{shell}/exec', b'Detach\n')
- assert c.wait(timeout=10) == 1, c.returncode
- wait_for('the client says it was let go', lambda: b'let this client go' in term.text())
+ assert c.wait(timeout=10) == 0, c.returncode
+ wait_for('the client says it detached', lambda: b"detached from 'work', which is still running" in term.text())
else:
term.close()
c.wait(timeout=10)
@@ -1686,8 +2002,8 @@ def main(binary, cycles):
# The end: the session quits, its shells hang up, its client and
# the daemon go.
exit_session(client, pane)
- assert stub.wait(timeout=10) == 1, stub.returncode
- wait_for('the client says it was let go', lambda: b'let this client go' in term.text())
+ assert stub.wait(timeout=10) == 0, stub.returncode
+ assert b'let this client go' not in term.text(), term.text()[-300:]
client.socket.close()
term.close()
wait_for('the adopted shell hung up', lambda: not alive(shell_pid))
@@ -2106,10 +2422,15 @@ def upgrades(old, new):
sock = root / 'pardes-9p-again.sock'
wait_for('the next session', sock.exists)
client = Client(sock)
- started.append(int(dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines())['pid']))
- # Its reader of the daemon starts after its first frame: an Adopt
- # before that waits for an `ok` nobody reads, and is refused.
+ again = int(dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines())['pid'])
+ started.append(again)
+ # A build before daemon.zig's `kept` waited for the hello's answer
+ # (the new-to-old run) refused an Adopt before its reader of the
+ # daemon ran (after its first frame), or within 2 s of a slow `ok`:
+ # it is asked once the daemon lists it (answer_late tests the wait).
wait_for('the next session\'s first frame', lambda: b'\x1b[?1049h' in term.text())
+ wait_for('the next session listed by the daemon', lambda: f'session again {again} ' in subprocess.run(
+ [str(binary), '--ps'], env=env, capture_output=True, timeout=30).stdout.decode())
before = set(terminals(client))
client.write(f'/pane/{min(before)}/exec', b'Adopt\n')
pane = wait_for('the adopted pane', lambda: set(terminals(client)) - before).pop()
@@ -2231,8 +2552,14 @@ if __name__ == '__main__':
clients(sys.argv[2])
elif sys.argv[1:2] == ['--manage']:
manage(sys.argv[2])
+ elif sys.argv[1:2] == ['--launch']:
+ launch(sys.argv[2])
+ elif sys.argv[1:2] == ['--pair']:
+ pair(sys.argv[2])
+ pair_rows(sys.argv[2])
elif sys.argv[1:2] == ['--relink']:
relink(sys.argv[2])
+ answer_late(sys.argv[2])
elif sys.argv[1:2] == ['--games']:
games(sys.argv[2], sys.argv[3], float(sys.argv[4]) if len(sys.argv) > 4 else 10)
elif sys.argv[1:2] == ['--far']:
diff --git a/test/delay_relay.py b/test/delay_relay.py
index c600a3aa..b0d48e38 100644
--- a/test/delay_relay.py
+++ b/test/delay_relay.py
@@ -8,7 +8,7 @@ the ones before it have crossed at that rate, then waits out the delay. An
optional jitter adds up to that many ms more to each chunk's delay, at
random, its order kept (a chunk never overtakes the one before it).
- python3 -B test/delay_relay.py LISTEN TARGET --delay MS [--rate MB/s] [--jitter MS]
+ python3 -B test/delay_relay.py LISTEN TARGET --delay MS [--rate MB/s] [--jitter MS] [--bound MS]
python3 -B test/delay_relay.py --self-check
An address is a path (a Unix socket) or host:port (TCP). The one-way
@@ -46,7 +46,9 @@ def dial(address):
return s
-def listen(address):
+def listen(address, bound=0.0):
+ """Bound, then listening `bound` s later (an ssh -L's socket file is
+ there a moment before it answers)."""
family, addr = parse(address)
s = socket.socket(family)
if family == socket.AF_UNIX:
@@ -57,6 +59,7 @@ def listen(address):
else:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(addr)
+ time.sleep(bound)
s.listen(64)
return s
@@ -260,8 +263,9 @@ def main():
ap.add_argument('--delay', type=float, required=True, help='one-way delay, ms')
ap.add_argument('--rate', type=float, help='a bandwidth cap, MB/s')
ap.add_argument('--jitter', type=float, default=0, help='up to this many ms more a chunk, at random')
+ ap.add_argument('--bound', type=float, default=0, help='ms between the bind and the listen')
a = ap.parse_args()
- listener = listen(a.listen)
+ listener = listen(a.listen, a.bound / 1000)
print(f'relaying {a.listen} -> {a.target}, {a.delay} ms each way'
+ (f', {a.rate} MB/s' if a.rate else '') + (f', jitter {a.jitter} ms' if a.jitter else ''), flush=True)
try:
diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig
index ceda8158..90b610a9 100644
--- a/test/fs_namespace.zig
+++ b/test/fs_namespace.zig
@@ -118,7 +118,6 @@ test "transactional restore preserves host capabilities and advances pane identi
}
test "filesystem resolves OS first then virtual with explicit mounts and parent paths" {
- if (!filesystem.platform_has_fs) return error.SkipZigTest;
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
@@ -185,7 +184,6 @@ test "filesystem resolves OS first then virtual with explicit mounts and parent
}
test "explicit OS file opens and restores keep their names and request watches" {
- if (!filesystem.platform_has_fs) return error.SkipZigTest;
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
@@ -286,7 +284,6 @@ test "owned cwd failed file opens never publish a pane or retain a reservation"
}
test "images decode through explicit filesystem mounts, and a dump's pane reads its file again through the same mount" {
- if (!filesystem.platform_has_fs) return error.SkipZigTest;
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
diff --git a/test/lib/build.zig b/test/lib/build.zig
deleted file mode 100644
index 436517d4..00000000
--- a/test/lib/build.zig
+++ /dev/null
@@ -1,34 +0,0 @@
-//! A package that depends on pardes for its library, as a program that draws
-//! source text itself would: pardes's `lib-test` step runs `zig build test`
-//! here, so the `pardes-syntax` module is built the way such a package
-//! builds it (build.zig's `library`), with the minimal grammars, and
-//! `pardes-editor`, the text pane as a library, which it asks for.
-const std = @import("std");
-
-pub fn build(b: *std.Build) void {
- const target = b.standardTargetOptions(.{});
- const optimize = b.standardOptimizeOption(.{});
- const pardes = b.dependency("pardes", .{ .target = target, .optimize = optimize, .@"tree-sitter" = .minimal, .editor = true });
- const step = b.step("test", "colour, outline and walk a C and a Zig source through pardes's library, and edit a text with its editor");
- // A file belongs to one module: the syntax alone, and the editor (which
- // has it as `.syntax`), each a test of its own.
- for ([_][2][]const u8{ .{ "lib.zig", "pardes-syntax" }, .{ "editor.zig", "pardes-editor" } }) |t| {
- const tests = b.addTest(.{ .root_module = b.createModule(.{
- .target = target,
- .optimize = optimize,
- .root_source_file = b.path(t[0]),
- .imports = &.{.{ .name = t[1], .module = pardes.module(t[1]) }},
- }) });
- step.dependOn(&b.addRunArtifact(tests).step);
- }
- // What a key costs, a page count and a parse: `zig build bench -- <KiB> <keys>`.
- const bench = b.addExecutable(.{ .name = "bench", .root_module = b.createModule(.{
- .target = target,
- .optimize = optimize,
- .root_source_file = b.path("bench.zig"),
- .imports = &.{.{ .name = "pardes-editor", .module = pardes.module("pardes-editor") }},
- }) });
- const run_bench = b.addRunArtifact(bench);
- run_bench.addPassthruArgs();
- b.step("bench", "a key typed into the library's editor at a size, its pages and a parse").dependOn(&run_bench.step);
-}
diff --git a/test/lib/build.zig.zon b/test/lib/build.zig.zon
deleted file mode 100644
index d8c31c3f..00000000
--- a/test/lib/build.zig.zon
+++ /dev/null
@@ -1,10 +0,0 @@
-.{
- .name = .pardes_lib_test,
- .version = "0.0.0",
- .dependencies = .{
- .pardes = .{ .path = "../.." },
- },
- .minimum_zig_version = "0.17.1",
- .paths = .{""},
- .fingerprint = 0x3f9948734dd377c7,
-}
diff --git a/test/output.zig b/test/output.zig
index c5ddddd5..77de7649 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -138,7 +138,7 @@ test "location producers retain rendered location match and diagnostic styles" {
} else if (origin == .search or origin == .cmd) {
try std.testing.expectEqual(pardes.Color{ .rgb = chrome.search_bg }, first.style.bg);
}
- if (!diagnostic and pardes.syntax.enabled) {
+ if (!diagnostic) {
const number = start + std.mem.indexOf(u8, code, "42").?;
try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().num }, outputCell(p, surface, id, number).style.fg);
}
@@ -428,7 +428,6 @@ test "Mini dump preserves its exact virtual snapshot and body writes detach colo
}
test "Mini syntax colors survive themes and rendering without source access" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "demo.zig", .data = "pub fn main() void {\n if (true) return;\n}\n" });
@@ -619,7 +618,6 @@ fn selectedOutputText(pane: *const pardes.Pane) ?[]const u8 {
}
test "LookNext/LookPrev skips formatted context and selects comment match locations" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| {
for ([_]bool{ false, true }) |tslocations| {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
@@ -786,7 +784,7 @@ test "identical result refresh keeps warm content caches without allocation" {
const index = try panes.File.lineIndex(p.gpa, file);
const styles = try std.testing.allocator.dupe(u8, file.highlights);
defer std.testing.allocator.free(styles);
- if (@import("pardes_options").grammars != .disabled) try std.testing.expect(styles.len > 0);
+ try std.testing.expect(styles.len > 0);
const revision = file.revision;
const saved_revision = file.saved_revision;
const body_ptr = file.content.ptr;
@@ -1048,7 +1046,6 @@ test "result alignment chunks assign boundary context to nearest match with prev
}
test "declaration context ellipses mark only final header lines before omitted source" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
const text = "const Outer = struct {\n" ++
"\n" ++
" pub fn run(\n" ++
@@ -1161,7 +1158,6 @@ test "LSP occurrence tint follows the supplied source span through context" {
}
test "result context upper bound stops at earliest enclosing declaration" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
const text = "// unrelated prelude\n" ++
"const unrelated = 1;\n" ++
"\n" ++
@@ -1227,7 +1223,6 @@ test "result context upper bound stops at earliest enclosing declaration" {
}
test "stacked search and LSP results retain source tint navigation and dump ownership" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
const first = "\tfoo + 界 + foo;";
const second = " return foo;";
const source_text = "const Box = struct {\n fn run() void {\n" ++ first ++ "\n const neighbor = 42;\n" ++ second ++ "\n }\n};\n";
@@ -1348,7 +1343,6 @@ test "stacked search and LSP results retain source tint navigation and dump owne
}
test "location analysis cache refreshes unsaved ancestry and query context" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
const before = "const Outer = struct {\n" ++
" fn first() void {\n" ++
" marker();\n" ++
@@ -1429,7 +1423,6 @@ test "location analysis cache refreshes unsaved ancestry and query context" {
}
test "location cache eviction retains early colors and honors disk and unsaved replacements" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
var dir_buf: [4096]u8 = undefined;
diff --git a/test/panes.zig b/test/panes.zig
index dbdbec2f..6bda3519 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -152,7 +152,6 @@ const BodyHitTests = struct {
}
test "compact TreeContext mouse follows source rows in reclaimed space" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
@@ -201,7 +200,6 @@ const BodyHitTests = struct {
const LineNumberLookTests = struct {
test "right-click on a line number looks at that line, sticky context headers included" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
@@ -259,7 +257,6 @@ const TreeContextTests = struct {
}
test "TreeContext separators mark source gaps without splitting multiline signatures" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
const pane = try setZigFile(p, "const Box = struct {\n\n // omitted member comment\n\n pub fn work(\n value: usize,\n ) void {\n" ++ std.mem.asBytes(&@as([30][16]u8, @splat(" // body\n".*))) ++ " }\n};\n");
@@ -291,7 +288,6 @@ const TreeContextTests = struct {
test "TreeContext Look to an open file discards the old viewport extent" {
for ([_]bool{ false, true }) |context| {
- if (context and !syntax.enabled) continue;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
const pane = try setZigFile(p, "pub fn work() void {\n" ++ std.mem.asBytes(&@as([100][12]u8, @splat(" // body\n".*))) ++ "}\n");
@@ -316,7 +312,6 @@ const TreeContextTests = struct {
}
test "TreeContext sticky declarations preserve the body while clicked and edited" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
const pane = try setZigFile(p, source);
@@ -368,7 +363,6 @@ const TreeContextTests = struct {
}
test "TreeContext unwrapped headers map Unicode and survive source replacement" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 48, .rows = 14 });
defer p.deinit();
const pane = try setZigFile(p, "pub fn @\"界name\"(\n\tvalue: usize,\n) void {\n" ++ std.mem.asBytes(&@as([12][15]u8, @splat(" _ = value;\n".*))) ++ "}\n");
@@ -407,7 +401,6 @@ const TreeContextTests = struct {
}
test "TreeContext clipped headers leave wrapped body cursor coordinates intact" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 24, .rows = 12 });
defer p.deinit();
const body = " // 012345678901234567890123456789界tail";
@@ -1717,7 +1710,6 @@ const OutputTests = struct {
}
test "Callstack aligns source below locations and keeps exact emphasis and navigation" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 30 });
defer p.deinit();
const source = " pub fn caller(\n value: u32,\n ) void {\n work(value);\n }\n";
@@ -1759,7 +1751,6 @@ const OutputTests = struct {
}
test "Callstack signatures share unsaved tree context and keep guides out of Look selections" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 110, .rows = 30 });
defer p.deinit();
const source = "const Box = struct {\n" ++
@@ -1853,7 +1844,6 @@ const OutputTests = struct {
}
test "Locations context uses unsaved sources and navigation visits only matches" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
p.locations_config.layout = .@"inline";
@@ -1968,7 +1958,6 @@ const OutputTests = struct {
}
test "Locations visible declarations are muted and stars count scopes rather than signature lines" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 });
defer p.deinit();
p.locations_config.layout = .@"inline";
@@ -3541,7 +3530,6 @@ test "cancelled normal gestures leave no count or subprefix through raw tty mode
}
test "Zig keywords keep every rendered byte colored across line-number widths" {
- if (!syntax.enabled) return error.SkipZigTest;
const gpa = std.testing.allocator;
const samples = [_][]const u8{
"pub fn main() void { if (true) {} }\n",
diff --git a/test/process.zig b/test/process.zig
index 8bcbddeb..e2a4f592 100644
--- a/test/process.zig
+++ b/test/process.zig
@@ -916,7 +916,8 @@ pub const Child = struct {
while (environ[i]) |kv| {
const entry = std.mem.span(kv);
const eq = std.mem.indexOfScalar(u8, entry, '=') orelse entry.len;
- if (std.mem.startsWith(u8, entry, "PARDES_") or std.mem.indexOf(u8, entry[0..eq], "PAGER") != null) {
+ // PARDES_PAIR kept: the suite run as pairs (main.zig `pair`).
+ if ((std.mem.startsWith(u8, entry, "PARDES_") and !std.mem.startsWith(u8, entry, "PARDES_PAIR=")) or std.mem.indexOf(u8, entry[0..eq], "PAGER") != null) {
var name: [256]u8 = undefined;
const n = std.fmt.bufPrintSentinel(&name, "{s}", .{entry[0..@min(eq, 255)]}, 0) catch _exit(126);
_ = unsetenv(n);
diff --git a/test/process/terminals.zig b/test/process/terminals.zig
index 24772ced..d9c3bcca 100644
--- a/test/process/terminals.zig
+++ b/test/process/terminals.zig
@@ -262,7 +262,9 @@ fn rawKey(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
/// thousand: nothing printed is nothing kept), then a probe typed and
/// taken back with ^U.
fn drive(gpa: std.mem.Allocator, exe: [:0]const u8, script: []const u8, key: ?u8, rows: usize) !void {
- var d = try process.Detached.start(gpa, exe, "agent", .{});
+ // No builtin announces itself: Term's name would linger on the screen
+ // (MessageLinger, 800 ms) and go between `before` and ^U's answer.
+ var d = try process.Detached.start(gpa, exe, "agent", .{ .init = "Verbose off\n" });
defer d.deinit();
const f = &d.files;
try d.put("command.sh", f.at("exec /bin/sh -c '{s}'\n", .{script}));
@@ -300,7 +302,10 @@ fn drive(gpa: std.mem.Allocator, exe: [:0]const u8, script: []const u8, key: ?u8
try f.write(data, "\x15");
const back_by = eh.nowMs() + 10_000;
while (!std.mem.eql(u8, try f.screen(), before)) {
- if (eh.nowMs() > back_by) return error.ScreenNotRestored;
+ if (eh.nowMs() > back_by) {
+ std.debug.print("before:\n{s}\nafter ^U:\n{s}\n", .{ before, try f.screen() });
+ return error.ScreenNotRestored;
+ }
sleepMs(10);
}
}
diff --git a/test/process/tty_terminals.zig b/test/process/tty_terminals.zig
index d5540818..dfb027e2 100644
--- a/test/process/tty_terminals.zig
+++ b/test/process/tty_terminals.zig
@@ -844,7 +844,9 @@ fn exec_bigdrag(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
try t.drag("middle", "150", 31);
try t.drag("middle", "198", 59);
try t.release("middle", "198", 59);
- try t.stable(500, 8000);
+ // Bash fails each swept chunk as a command, one by one: under load
+ // that runs well past 8 s, so the quiet is waited for once, with the
+ // cap the sweep's other waits have.
try t.stable(800, 30000);
// still alive: type and execute a marker command
try t.press("left", "105", 41);
diff --git a/test/terminal.zig b/test/terminal.zig
index b7b9cd33..ec050c7a 100644
--- a/test/terminal.zig
+++ b/test/terminal.zig
@@ -203,7 +203,6 @@ test "a terminal's dump restores the cells it drew, its history and where its vi
}
test "a restored command pane comes back finished, its command not run again" {
- if (comptime pardes.isolated) return error.SkipZigTest;
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 16 });
defer p.deinit();
@@ -233,7 +232,6 @@ test "a restored command pane comes back finished, its command not run again" {
}
test "a restored terminal keeps its history above a marker and gets a shell where it was" {
- if (comptime pardes.isolated) return error.SkipZigTest;
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 });
defer p.deinit();