diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/fs.py | 20 | ||||
| -rw-r--r-- | test/selfmount.py | 14 | ||||
| -rw-r--r-- | test/snapshots/pagercolor.golden | 120 | ||||
| -rw-r--r-- | test/snapshots/pagercolor.snap | 24 |
4 files changed, 178 insertions, 0 deletions
@@ -1529,6 +1529,26 @@ def test(binary, quic=False): log_now = client.read('/log').decode() 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. + 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: + 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)] + 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. 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) diff --git a/test/selfmount.py b/test/selfmount.py index ddfb77dc..57dfffa8 100644 --- a/test/selfmount.py +++ b/test/selfmount.py @@ -182,6 +182,20 @@ def run(binary): log = client.read('/log').decode() check(log.count('over 1 MiB') == 1 and 'unknown control message' not in log and 'after-long' in log, 'a 1.1 MiB line is refused once, its tail never a line, the next line runs') + # `pardes -` by hand through the mount: the directory, then a + # program's output, escapes and all, on one open of /pager; the + # +Pager reads back the plain text. + got = run(f"{{ pwd; printf '\\033[31mred\\033[m\\n'; }} > {mount}/pager\n".encode()) + rows = [row.rsplit(maxsplit=1)[0].split(maxsplit=3) for row in client.read('/index').decode().splitlines()] + paged = [row[0] for row in rows if len(row) == 4 and row[3].endswith('/+Pager')] + check(got == '0' and len(paged) == 1, f'a +Pager made through the mount ({got!r}, {paged!r})') + if paged: + # The text goes in at the open's close, and a mount's close + # (FUSE's release) comes after close(2) has returned. + deadline = time.monotonic() + 5 + while (said := client.read(f'/pane/{paged[0]}/body')) != b'red\n' and time.monotonic() < deadline: + time.sleep(.05) + check(said == b'red\n', f'its body is the plain text ({said!r})') # Forty event reads held through the mount, a follower each, and # the mount still answers the rest: 9ns keeps workers past what # the editor holds (128), so `cat layout` is not queued behind diff --git a/test/snapshots/pagercolor.golden b/test/snapshots/pagercolor.golden new file mode 100644 index 00000000..811d3d96 --- /dev/null +++ b/test/snapshots/pagercolor.golden @@ -0,0 +1,120 @@ +== snap pager grid=100x50 cursor=4,5 +|Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit +| New Tty Find Grep Joincol Delcol +|$ /tmp/pardes-snap/pagercolor/cwd Tty+bash Save Mode Filter Collapse Del +| $ printf '\033]0;title\007\033[31mred\033[m \033[1;32mbold green\033[m \033[38;2;200;100;0mrgb\033 +| [m \033[4mul\033[m N\bNA\bAM\bME\bE _\bu_\bs plain\n' | $(readlink /proc/$PPID/exe) - +| $ +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| /tmp/pardes-snap/pagercolor/cwd/+New Save Tty Collapse Del +| 1 +| +| +| +| +| +| +| /tmp/pardes-snap/pagercolor/cwd/+Pager Save Tty Collapse Del +| 1 red bold green rgb ul NAME us plain +| 2 +== style pager-colours grid=100x50 +|0: 0-99 #b2c3b8,#1d2824, +|1: 0-1 d,#887455, 2-2 d,#314738, 3-99 #becfc4,#314738, +|2: 0-1 #000000,#add38a, 2-2 #000000,#314738, 3-34 #becfc4,#314738, 35-43 #dfbce5,#314738, 44-99 #becfc4,#314738, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|6: 0-0 d,#608269, 1-99 d,#0d1410, +|7: 0-0 d,#608269, 1-99 d,#0d1410, +|8: 0-0 d,#608269, 1-99 d,#0d1410, +|9: 0-0 d,#608269, 1-99 d,#0d1410, +|10: 0-0 d,#608269, 1-99 d,#0d1410, +|11: 0-0 d,#608269, 1-99 d,#0d1410, +|12: 0-0 d,#608269, 1-99 d,#0d1410, +|13: 0-0 d,#608269, 1-99 d,#0d1410, +|14: 0-0 d,#608269, 1-99 d,#0d1410, +|15: 0-0 d,#608269, 1-99 d,#0d1410, +|16: 0-0 d,#608269, 1-99 d,#0d1410, +|17: 0-0 d,#608269, 1-99 d,#0d1410, +|18: 0-0 d,#608269, 1-99 d,#0d1410, +|19: 0-0 d,#608269, 1-99 d,#0d1410, +|20: 0-0 d,#608269, 1-99 d,#0d1410, +|21: 0-0 d,#608269, 1-99 d,#0d1410, +|22: 0-0 d,#608269, 1-99 d,#0d1410, +|23: 0-0 d,#608269, 1-99 d,#0d1410, +|24: 0-0 d,#608269, 1-99 d,#0d1410, +|25: 0-0 d,#608269, 1-99 d,#0d1410, +|26: 0-0 d,#608269, 1-99 d,#0d1410, +|27: 0-0 d,#608269, 1-99 d,#0d1410, +|28: 0-0 d,#608269, 1-99 d,#0d1410, +|29: 0-0 d,#608269, 1-99 d,#0d1410, +|30: 0-0 d,#608269, 1-99 d,#0d1410, +|31: 0-0 d,#608269, 1-99 d,#0d1410, +|32: 0-0 d,#608269, 1-99 d,#0d1410, +|33: 0-0 d,#608269, 1-99 d,#0d1410, +|34: 0-1 d,#496656, 2-2 d,#1d2824, 3-34 #b2c3b8,#1d2824, 35-39 #d3b0d9,#1d2824, 40-99 #b2c3b8,#1d2824, +|35: 0-0 d,#608269, 1-4 d,#0d1410, 5-99 #59675c,#0d1410, +|36: 0-0 d,#608269, 1-99 d,#0d1410, +|37: 0-0 d,#608269, 1-99 d,#0d1410, +|38: 0-0 d,#608269, 1-99 d,#0d1410, +|39: 0-0 d,#608269, 1-99 d,#0d1410, +|40: 0-0 d,#608269, 1-99 d,#0d1410, +|41: 0-0 d,#608269, 1-99 d,#0d1410, +|42: 0-1 d,#496656, 2-2 d,#1d2824, 3-34 #b2c3b8,#1d2824, 35-41 #d3b0d9,#1d2824, 42-99 #b2c3b8,#1d2824, +|43: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #f1a39b,#0d1410, 11-20 #b6ce94,#0d1410,b 21-21 #b6ce94,#0d1410, 22-25 #c86400,#0d1410, 26-27 #e5eee5,#0d1410,u 28-28 #e5eee5,#0d1410, 29-32 #e5eee5,#0d1410,b 33-33 #e5eee5,#0d1410, 34-35 #e5eee5,#0d1410,u 36-99 #e5eee5,#0d1410, +|44: 0-0 d,#608269, 1-4 d,#0d1410, 5-99 #59675c,#0d1410, +|45: 0-0 d,#608269, 1-99 d,#0d1410, +|46: 0-0 d,#608269, 1-99 d,#0d1410, +|47: 0-0 d,#608269, 1-99 d,#0d1410, +|48: 0-0 d,#608269, 1-99 d,#0d1410, +|49: 0-0 d,#608269, 1-99 d,#0d1410, +== snap pager-diff grid=100x50 cursor=4,8 +|5: $ printf '\033[33mcommit 0123\033[33mabc\033[m\n\033[1mdiff --git a/x b/x\033[m\n\033[1m--- a/x\03 +|6: 3[m\n\033[1m+++ b/x\033[m\n\033[36m@@ -1 +1 @@\033[m\n\033[31m-old\033[m\n\033[32m+new\033[m\n' | +|7: $(readlink /proc/$PPID/exe) - +|8: $ +|43: 1 commit 0123abc +|44: 2 diff --git a/x b/x +|45: 3 --- a/x +|46: 4 +++ b/x +|47: 5 @@ -1 +1 @@ +|48: 6 -old +|49: 7 +new +== style pager-diff-colours grid=100x50 +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|43: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-99 #e9c680,#0d1410, +|44: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-24 #b9f480,#0d1410,b 25-99 #b9f480,#0d1410, +|45: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-13 #b9f480,#0d1410,b 14-99 #b9f480,#0d1410, +|46: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-13 #b9f480,#0d1410,b 14-99 #b9f480,#0d1410, +|47: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-99 #b6c59e,#0d1410, +|48: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-7 #f1a39b,#302b25,b 8-99 #f8c082,#302b25, +|49: 0-0 d,#152019, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-7 #b6ce94,#263025,b 8-99 #b8d88a,#263025, diff --git a/test/snapshots/pagercolor.snap b/test/snapshots/pagercolor.snap new file mode 100644 index 00000000..650792b3 --- /dev/null +++ b/test/snapshots/pagercolor.snap @@ -0,0 +1,24 @@ +# `pardes -` keeps a program's colours (PagerColor, on by default): its SGR +# becomes the +Pager's own colours over the plain text (red through the +# theme's palette, truecolor as given, bold and underline, a man page's +# overstrike), and every other escape (the OSC title) is dropped. The +# needles waited for are split by escapes in the typed line, so only the +# paged text holds them. +start 50 100 +wait 8000 $ +stable 700 20000 +text printf '\033]0;title\007\033[31mred\033[m \033[1;32mbold green\033[m \033[38;2;200;100;0mrgb\033[m \033[4mul\033[m N\bNA\bAM\bME\bE _\bu_\bs plain\n' | $(readlink /proc/$PPID/exe) - +key enter +wait 20000 red bold green +stable 700 20000 +snap pager +snapstyle pager-colours +# A coloured diff: the rows pardes tints as added or removed are drawn as +# its own diff, and git's colours stay on the rest (the bold header, the +# cyan hunk line, the yellow commit line). +text printf '\033[33mcommit 0123\033[33mabc\033[m\n\033[1mdiff --git a/x b/x\033[m\n\033[1m--- a/x\033[m\n\033[1m+++ b/x\033[m\n\033[36m@@ -1 +1 @@\033[m\n\033[31m-old\033[m\n\033[32m+new\033[m\n' | $(readlink /proc/$PPID/exe) - +key enter +wait 20000 0123abc +stable 700 20000 +snap pager-diff +snapstyle pager-diff-colours |
