diff options
Diffstat (limited to 'test/fs.py')
| -rw-r--r-- | test/fs.py | 56 |
1 files changed, 54 insertions, 2 deletions
@@ -622,11 +622,11 @@ def workflow_canary(binary): rows = client.read(f'/pane/{grep}/body').decode() assert 'a.txt:2' in rows and 'b.txt:2' in rows, rows client.remove(f'/pane/{grep}') - execute_refused(client, a, 'Grep zzqqnomatch', 'grep: no match') + execute_refused(client, a, 'Grep zzqqnomatch', 'grep: pattern not found') found = made_by(a, b'Find b.txt\n') assert 'b.txt' in client.read(f'/pane/{found}/body').decode() client.remove(f'/pane/{found}') - execute_refused(client, a, 'Find zzqqnomatch', 'find: no match') + execute_refused(client, a, 'Find zzqqnomatch', 'find: name not found') # A plain word looked at is found in the pane, after its dot. client.write(f'/pane/{a}/dot', b' 0 0 ') @@ -814,6 +814,56 @@ def signal_cleans_up(binary): assert not address.exists() and not detached.exists(), (sig, list(root.iterdir())) +def odd_paths(binary): + """Long and odd paths written where a path goes -- name, look, DumpDir, + Dump, Save -- are refused or said, never a crash: a part over 255 bytes + (ENAMETOOLONG), a loop of links (ELOOP), a file taken for a directory + (ENOTDIR), one not ours (EACCES).""" + with tempfile.TemporaryDirectory(prefix='pardes-odd-') as directory: + root = Path(directory) + (root / 'loop').symlink_to(root / 'loop') + (root / 'plain').write_bytes(b'x\n') + odd = ['/tmp/' + 'x' * 300 + '/f.txt', str(root / ('y' * 300)), str(root / 'loop' / 'f'), + str(root / 'plain' / 'f'), '/root/nope/f', str(root / 'a' / '..' / 'b.txt')] + with session(binary, root, 'odd') as (client, _): + serial = new_pane(client, b'text\n') + for path in odd: + for where, line in ((f'/pane/{serial}/name', path), ('/look', path), + ('/ctl', f'DumpDir {path}'), ('/ctl', 'Dump'), (f'/pane/{serial}/ctl', 'Save')): + try: + client.write(where, (line + '\n').encode()) + except OSError: + pass + assert client.read('/index'), (where, line) + client.write('/ctl', b'DumpDir\n') + # A theme file that is not there, or no theme, fails the write. + (root / 'bad.zon').write_bytes(b'.{ .nonsense = 1 }') + for line, why in ((f'ThemeFile {root}/missing.zon', 'theme file'), (f'ThemeFile {root}/bad.zon', 'theme file'), + ('ThemeFile notes.txt', 'a theme file is a .zon')): + try: + client.write('/ctl', (line + '\n').encode()) + raise AssertionError(f'{line} was taken') + except OSError as refused: + assert why in str(refused), (line, refused) + + +def delcol_last_keeps_window(binary): + """Delcol on the last column leaves the window, empty but for the + workspace tag, as acme does; Newcol and New start again from there.""" + with tempfile.TemporaryDirectory(prefix='pardes-delcol-') as directory: + with session(binary, Path(directory), 'delcol') as (client, _): + def columns(): + return [l for l in client.read('/layout').decode().splitlines() if l and not l.startswith('active')] + while columns(): + client.write(f'/col/{columns()[0].split()[0]}/ctl', b'Delcol\n') + # Still here, empty. + assert client.read('/index') == b'', client.read('/index') + client.write('/ctl', b'Newcol\n') + assert len(columns()) == 1, columns() + serial = new_pane(client, b'back\n') + assert str(serial).encode() in client.read('/index'), client.read('/index') + + def cut_writes(binary): """A write bigger than a 9P message comes as several, cut anywhere: each command line runs once, whole, an Edit block once it ends, and a last @@ -846,6 +896,8 @@ def cut_writes(binary): def test(binary, quic=False): started = time.monotonic() cut_writes(binary) + odd_paths(binary) + delcol_last_keeps_window(binary) run_file(binary) exit_answers(binary) unattended_messages_expire(binary) |
