From 554181b73fd53b898841203066382e4287b83e89 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 06:05:08 -0300 Subject: One rule for failing builtins: the write fails, one err, no msg A builtin that failed through a ctl failed the write and logged its err, but through look, exec, tagexec or a column's exec it only said so on the message row, logged as a msg, and the write succeeded. Now every click write runs its builtin as a ctl line does (ctl.captured): a failure fails the write, with its words (EINVAL for malformed input, else EIO or what the words name), logs one err and no msg or announcement. get's Modified and a look miss are shown but logged once, as their err. A control character's refusal names its reason, a failed click reads back nothing, and look never reads back a pane closed since. The special case for a cut-short Edit through exec goes (the rule covers it); fs.md's table of exceptions becomes the one rule, as does the skill. Co-Authored-By: Claude Opus 5.5 --- test/fs.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/fs.py b/test/fs.py index b7e8adcc..8d16d718 100644 --- a/test/fs.py +++ b/test/fs.py @@ -133,6 +133,16 @@ def execute(client, serial, command): client.write(f'/pane/{serial}/exec', f'{command}\n'.encode()) +def execute_refused(client, serial, command, words): + """A middle click on a builtin that fails: the write fails, saying why.""" + try: + execute(client, serial, command) + except OSError as why: + assert words in str(why), (command, why) + return + raise AssertionError(f'{command!r} was taken') + + def walk_tree(client, path='/', skip=('/log', '/os', '/screen')): """Stat every entry below `path`, as `find` does, without opening anything.""" seen = [] @@ -725,8 +735,9 @@ def test(binary, quic=False): execute(remote, control, 'Mount peer ' + str(address)) opened = look(remote, '/n/peer/pane/1/body', source=control) assert remote.read(f'/pane/{opened}/body') == client.read('/pane/1/body') - execute(remote, control, 'Mount peer ' + str(own_address)) - execute(remote, control, 'Unmount peer') + # A builtin that fails through exec fails the write (one rule). + execute_refused(remote, control, 'Mount peer ' + str(own_address), 'already mounted') + execute_refused(remote, control, 'Unmount peer', 'mount in use') # a pane is open on it remote.write(f'/pane/{opened}/body', b'runtime mounted Save\n', truncate=True) remote.write(f'/pane/{opened}/exec', b'Save\n') assert client.read('/pane/1/body') == b'runtime mounted Save\n' @@ -753,7 +764,7 @@ def test(binary, quic=False): with session(binary, root, name, tty=tty) as (old, address): old.write('/pane/1/body', b'dumped state\n', truncate=True) control = new_pane(old, b'') - execute(old, control, 'Restore ' + str(root / 'missing dump.zon')) + execute_refused(old, control, 'Restore ' + str(root / 'missing dump.zon'), 'no such file') assert old.read('/pane/1/body') == b'dumped state\n' execute(old, control, 'Mount own ' + str(address)) execute(old, control, 'Dump') -- cgit v1.3