summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fs.py56
1 files changed, 35 insertions, 21 deletions
diff --git a/test/fs.py b/test/fs.py
index b69ecf57..e351d295 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -22,8 +22,10 @@ from ninep import Client
@contextlib.contextmanager
def session(binary, root, name, *options, socket_name=None, file=None, tty=False, network=None,
launch=None, inherited=None, terminal=None):
+ # No pager of the caller's (a session's own PAGER, SYSTEMD_PAGER...):
+ # its shells get the session's defaults, the ones under test.
env = {key: value for key, value in os.environ.items()
- if not key.startswith('PARDES_')}
+ if not key.startswith('PARDES_') and 'PAGER' not in key}
env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root),
XDG_CONFIG_HOME=str(root / 'config'), PARDES_NOTIME='1',
PARDES_DUMP=str(root / (name + '.dump.zon')))
@@ -519,8 +521,10 @@ def run_file(binary):
assert b'\x1b' not in client.read(f'/pane/{pager[0]}/body')
client.remove(f'/pane/{pager[0]}')
# systemd's tools page through their own variable: set too, its
- # secure mode off, the path unquoted where it needs none.
- systemd_pager = run(client, term, b'printenv SYSTEMD_PAGER; printenv SYSTEMD_PAGERSECURE\n')
+ # secure mode off, the path unquoted where it needs none. Read
+ # by the shell: coreutils 9.12's printenv quotes a value with a
+ # blank on a terminal.
+ systemd_pager = run(client, term, b'printf "%s\\n" "$SYSTEMD_PAGER" "$SYSTEMD_PAGERSECURE"\n')
assert systemd_pager.startswith(b'exit 0\n') and systemd_pager.rstrip().endswith(b' -\n0'), systemd_pager
if shutil.which('journalctl'):
assert run(client, term, b'journalctl -n 3 --no-hostname\n').startswith(b'exit ')
@@ -1762,34 +1766,43 @@ def test(binary, quic=False):
assert f'\nnew {made_now} {root}/+Pager\n' in '\n' + log_now, log_now[-400:]
assert f'\nrename {made_now} ' not in '\n' + log_now
# Its colours are the pane's, drawn and never read: the body is
- # the plain text, and the screen shows `red` in the theme's red
- # and `rgb` in the colour given, the rest in the pane's ink.
+ # the plain text, and the screen shows `red` in the theme's red,
+ # the rest in the pane's ink. Mapped through the theme, as a
+ # terminal's are; Filter shows them as sent, `rgb` in the colour
+ # given.
+ # Each run is its own +Pager; one there already keeps its page.
fed = subprocess.run([binary, '-'], cwd=root, env=env,
input=b'\x1b]0;title\x07\x1b[31mred\x1b[m \x1b[38;2;1;2;3mrgb\x1b[m plain\n',
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=10)
assert fed.returncode == 0, fed.stderr
- assert client.read(f'/pane/{made_now}/body') == b'red rgb plain\n'
- screen = client.screen()
- for row in range(screen['rows']):
- cells = screen['cells'][row * screen['cols']:(row + 1) * screen['cols']]
- text = ''.join(cell[0] for cell in cells)
- at = text.find('red rgb plain')
- if at >= 0:
- break
- else:
+ coloured, = serials() - before - {made_now}
+ assert client.read(f'/pane/{coloured}/name') == f'{root}/+Pager\n'.encode()
+ assert client.read(f'/pane/{coloured}/body') == b'red rgb plain\n'
+ assert client.read(f'/pane/{made_now}/body') == b'bold text\n'
+ def inks():
+ screen = client.screen()
+ for row in range(screen['rows']):
+ cells = screen['cells'][row * screen['cols']:(row + 1) * screen['cols']]
+ at = ''.join(cell[0] for cell in cells).find('red rgb plain')
+ if at >= 0:
+ return [screen['styles'][cells[at + i][1]]['fg'] for i in (0, 4, 8)]
raise AssertionError(('the paged text is not on the screen', screen))
- ink = [screen['styles'][cells[at + i][1]]['fg'] for i in (0, 4, 8)]
+ ink = inks()
+ assert ink[0] != ink[2] and ink[1] != {'rgb': [1, 2, 3]}, ink
+ client.write(f'/pane/{coloured}/exec', b'Filter\n')
+ ink = inks()
assert ink[1] == {'rgb': [1, 2, 3]}, ink
assert ink[0] != ink[2] and ink[0] != ink[1], ink
- # The directory's one +Pager: the next paged text refills it.
+ # A progress line keeps its last state.
fed = subprocess.run([binary, '-'], cwd=root, env=env, input=b'again\r\nprogress 10%\rprogress 100%\n',
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=10)
assert fed.returncode == 0, fed.stderr
- assert serials() - before == {made_now}, (serials(), before)
- assert client.read(f'/pane/{made_now}/body') == b'again\nprogress 100%\n'
- client.remove(f'/pane/{made_now}')
+ again, = serials() - before - {made_now, coloured}
+ assert client.read(f'/pane/{again}/body') == b'again\nprogress 100%\n'
+ for serial in (made_now, coloured, again):
+ client.remove(f'/pane/{serial}')
# More than one 8 MiB write's worth arrives whole, byte for byte,
- # in the one +Pager (each write once replaced the last).
+ # in its +Pager (each write once replaced the last).
big = b''.join(b'line %08d of the paged text\n' % i for i in range(400000)) # ~11 MiB
assert len(big) > 8 * 1024 * 1024
fed = subprocess.run([binary, '-'], cwd=root, env=env, input=big,
@@ -1804,7 +1817,8 @@ def test(binary, quic=False):
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=600)
huge.wait()
assert fed.returncode == 0, fed.stderr
- assert serials() - before == {big_pane}
+ client.remove(f'/pane/{big_pane}')
+ big_pane, = serials() - before
got = client.read(f'/pane/{big_pane}/body')
note = b'\n[pardes: the rest of stdin is cut: a pane holds at most a file\'s limit]\n'
assert got.endswith(note) and len(got) == cap + len(note), (len(got), got[-120:])