summaryrefslogtreecommitdiff
path: root/test/fs.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/fs.py')
-rw-r--r--test/fs.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/fs.py b/test/fs.py
index 59668c57..b593981c 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -1085,6 +1085,37 @@ def edit_commands(binary):
assert time.monotonic() - began < .5 and not done.is_set(), 'the editor waited on the command'
worker.join(timeout=15)
assert done.is_set()
+ # On the same connection: the Edit's write is held, and a read sent
+ # after it is answered first; a Tflush of it stops it, changes
+ # nothing, and frees the way for the next Edit.
+ def send(kind, tag, payload):
+ client.socket.sendall(struct.pack('<IBH', 7 + len(payload), kind, tag) + payload)
+
+ def answer():
+ size, kind, tag = struct.unpack('<IBH', client.receive(7))
+ return kind, tag, client.receive(size - 7)
+ ctl = client.open(f'/pane/{a}/ctl', 1)
+ status = client.open('/status', 0)
+ line = b'Edit , | sleep 1; cat\n'
+ began = time.monotonic()
+ send(118, 900, struct.pack('<IQI', ctl, 0, len(line)) + line)
+ send(116, 901, struct.pack('<IQI', status, 0, 4096))
+ first = answer()
+ assert first[1] == 901 and first[0] == 117 and time.monotonic() - began < .5, (first[:2], time.monotonic() - began)
+ second = answer()
+ assert second[1] == 900 and second[0] == 119, second
+ line = b'Edit , | sleep 5; tr a-z A-Z\n'
+ send(118, 902, struct.pack('<IQI', ctl, 0, len(line)) + line)
+ time.sleep(.3)
+ send(108, 903, struct.pack('<H', 902))
+ tags = sorted(answer()[1] for _ in range(2))
+ assert tags == [902, 903], tags
+ client.close(ctl)
+ client.close(status)
+ time.sleep(1)
+ client.write(f'/pane/{a}/ctl', b'Edit , | cat\n')
+ time.sleep(4.5)
+ assert client.read(f'/pane/{a}/body') == b'APPLE\nFIG\nPEAR\n', client.read(f'/pane/{a}/body')
# X: each open file whose line matches; w writes it.
client.write(f'/pane/{a}/ctl', b'Edit X/b\\.txt$/ ,s/apple/APPLE/\n')
assert client.read(f'/pane/{b}/body') == b'APPLE pie\n'