aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/helpers.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-02-22 19:14:06 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-02-26 13:00:01 +0100
commit152921837e800b9726f5bb5510398f2149541bec (patch)
tree96a7c93ccc35f8953c0fda69d02caf2e44cf0f68 /test/functional/terminal/helpers.lua
parentd90e5f5260a5c2d25d2698eb2a4a442916efc5c5 (diff)
downloadrneovim-152921837e800b9726f5bb5510398f2149541bec.tar.gz
rneovim-152921837e800b9726f5bb5510398f2149541bec.tar.bz2
rneovim-152921837e800b9726f5bb5510398f2149541bec.zip
test: screen_setup(): Detect spawn failures, usage errors.
Diffstat (limited to 'test/functional/terminal/helpers.lua')
-rw-r--r--test/functional/terminal/helpers.lua20
1 files changed, 15 insertions, 5 deletions
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index 91f1942353..934c01e3bf 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(nil)
local Screen = require('test.functional.ui.screen')
local nvim_dir = helpers.nvim_dir
-local execute, nvim, wait = helpers.execute, helpers.nvim, helpers.wait
+local execute, nvim = helpers.execute, helpers.nvim
local function feed_data(data)
nvim('set_var', 'term_data', data)
@@ -57,12 +57,19 @@ local function screen_setup(extra_rows, command, cols)
})
screen:attach({rgb=false})
- -- tty-test puts the terminal into raw mode and echoes all input. tests are
- -- done by feeding it with terminfo codes to control the display and
- -- verifying output with screen:expect.
+
execute('enew | call termopen('..command..')')
+ nvim('input', '<CR>')
+ local vim_errmsg = nvim('eval', 'v:errmsg')
+ if vim_errmsg and "" ~= vim_errmsg then
+ error(vim_errmsg)
+ end
+
execute('setlocal scrollback=10')
execute('startinsert')
+
+ -- tty-test puts the terminal into raw mode and echoes input. Tests work by
+ -- feeding termcodes to control the display and asserting by screen:expect.
if command == default_command then
-- Wait for "tty ready" to be printed before each test or the terminal may
-- still be in canonical mode (will echo characters for example).
@@ -82,7 +89,10 @@ local function screen_setup(extra_rows, command, cols)
table.insert(expected, '{3:-- TERMINAL --}' .. ((' '):rep(cols - 13)))
screen:expect(table.concat(expected, '\n'))
else
- wait()
+ -- This eval also acts as a wait().
+ if 0 == nvim('eval', "exists('b:terminal_job_id')") then
+ error("terminal job failed to start")
+ end
end
return screen
end