aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir/runnvim.vim
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2023-03-07 04:13:04 +0100
committerGitHub <noreply@github.com>2023-03-07 11:13:04 +0800
commitaf23d173883f47fd02a9a380c719e4428370b484 (patch)
treed5da436c1539905528254225dd8f817f1577fb84 /test/old/testdir/runnvim.vim
parentbf4eada2c83f5402fc56370fd22af11029a4a3aa (diff)
downloadrneovim-af23d173883f47fd02a9a380c719e4428370b484.tar.gz
rneovim-af23d173883f47fd02a9a380c719e4428370b484.tar.bz2
rneovim-af23d173883f47fd02a9a380c719e4428370b484.zip
test: move oldtests to test directory (#22536)
The new oldtest directory is in test/old/testdir. The reason for this is that many tests have hardcoded the parent directory name to be 'testdir'.
Diffstat (limited to 'test/old/testdir/runnvim.vim')
-rw-r--r--test/old/testdir/runnvim.vim58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/old/testdir/runnvim.vim b/test/old/testdir/runnvim.vim
new file mode 100644
index 0000000000..a46e2d3fc0
--- /dev/null
+++ b/test/old/testdir/runnvim.vim
@@ -0,0 +1,58 @@
+let s:logger = {'d_events': []}
+function s:logger.on_stdout(id, data, event)
+ call add(self.d_events, [a:event, a:data])
+endfunction
+let s:logger.on_stderr = s:logger.on_stdout
+function s:logger.on_exit(id, data, event)
+ call add(self.d_events, [a:event, ['']])
+endfunction
+
+" Replace non-printable chars by special sequence, or "<%x>".
+let s:escaped_char = {"\n": '\n', "\r": '\r', "\t": '\t'}
+function! s:escape_non_printable(char) abort
+ let r = get(s:escaped_char, a:char)
+ return r is 0 ? printf('<%x>', char2nr(a:char)) : r
+endfunction
+
+function Main()
+ let argc = +$NVIM_TEST_ARGC
+ let args = []
+ for i in range(argc)
+ call add(args, eval("$NVIM_TEST_ARG" . i))
+ endfor
+ set lines=25
+ set columns=80
+ enew
+ let job = termopen(args, s:logger)
+ let results = jobwait([job], 5 * 60 * 1000)
+ " TODO(ZyX-I): Get colors
+ let screen = getline(1, '$')
+ bwipeout! " kills the job always.
+ let stringified_events = map(s:logger.d_events,
+ \'v:val[0] . ": " . ' .
+ \'join(map(v:val[1], '.
+ \ '''substitute(v:val, '.
+ \ '"\\v\\C(\\p@!.|\\<)", '.
+ \ '"\\=s:escape_non_printable(submatch(0))", '.
+ \ '"g")''), '.
+ \ '''\n'')')
+ call setline(1, [
+ \ 'Job exited with code ' . results[0],
+ \ printf('Screen (%u lines)', len(screen)),
+ \ repeat('=', 80),
+ \] + screen + [
+ \ repeat('=', 80),
+ \ printf('Events (%u lines):', len(stringified_events)),
+ \ repeat('=', 80),
+ \] + stringified_events + [
+ \ repeat('=', 80),
+ \])
+ write
+ if results[0] != 0
+ cquit
+ else
+ qall
+ endif
+endfunction
+
+call Main()