diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/fixtures/CMakeLists.txt (renamed from test/functional/job/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | test/functional/fixtures/shell-test.c | 25 | ||||
-rw-r--r-- | test/functional/fixtures/tty-test.c (renamed from test/functional/job/tty-test.c) | 0 | ||||
-rw-r--r-- | test/functional/terminal/cursor_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 61 | ||||
-rw-r--r-- | test/functional/terminal/helpers.lua | 2 | ||||
-rw-r--r-- | test/functional/terminal/highlight_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/terminal/scrollback_spec.lua | 2 |
8 files changed, 93 insertions, 5 deletions
diff --git a/test/functional/job/CMakeLists.txt b/test/functional/fixtures/CMakeLists.txt index 14ec287816..70aee6efa9 100644 --- a/test/functional/job/CMakeLists.txt +++ b/test/functional/fixtures/CMakeLists.txt @@ -1,2 +1,4 @@ add_executable(tty-test tty-test.c) target_link_libraries(tty-test ${LIBUV_LIBRARIES}) + +add_executable(shell-test shell-test.c) diff --git a/test/functional/fixtures/shell-test.c b/test/functional/fixtures/shell-test.c new file mode 100644 index 0000000000..5fa8a58049 --- /dev/null +++ b/test/functional/fixtures/shell-test.c @@ -0,0 +1,25 @@ +// A simple implementation of a shell for testing +// `termopen([&sh, &shcf, '{cmd'}])` and `termopen([&sh])`. +// +// If launched with no arguments, prints "ready $ ", otherwise prints +// "ready $ {cmd}\n". + +#include <stdio.h> +#include <string.h> + +int main(int argc, char **argv) +{ + fprintf(stderr, "ready $ "); + + if (argc == 3) { + // argv should be {"terminal-test", "EXE", "prog args..."} + if (strcmp(argv[1], "EXE") != 0) { + fprintf(stderr, "first argument must be 'EXE'\n"); + return 2; + } + + fprintf(stderr, "%s\n", argv[2]); + } + + return 0; +} diff --git a/test/functional/job/tty-test.c b/test/functional/fixtures/tty-test.c index 40ba131003..40ba131003 100644 --- a/test/functional/job/tty-test.c +++ b/test/functional/fixtures/tty-test.c diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index cecb33de7c..29225f968f 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -144,7 +144,7 @@ describe('cursor with customized highlighting', function() [6] = {foreground = 130}, }) screen:attach(false) - execute('term "' ..nvim_dir.. '/tty-test"') + execute('call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') end) it('overrides the default highlighting', function() diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua new file mode 100644 index 0000000000..3855cf4b65 --- /dev/null +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -0,0 +1,61 @@ +local helpers = require('test.functional.helpers') +local Screen = require('test.functional.ui.screen') +local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim +local nvim_dir = helpers.nvim_dir +local execute, source = helpers.execute, helpers.source +local eq, neq = helpers.eq, helpers.neq + +describe(':terminal', function() + local screen + + before_each(function() + clear() + screen = Screen.new(50, 7) + screen:attach(false) + nvim('set_option', 'shell', nvim_dir..'/shell-test') + nvim('set_option', 'shellcmdflag', 'EXE') + + end) + + it('with no argument, acts like termopen()', function() + execute('terminal') + wait() + screen:expect([[ + ready $ | + [Program exited, press any key to close] | + | + | + | + | + -- TERMINAL -- | + ]]) + end) + + it('executes a given command through the shell', function() + execute('terminal echo hi') + wait() + screen:expect([[ + ready $ echo hi | + | + [Program exited, press any key to close] | + | + | + | + -- TERMINAL -- | + ]]) + end) + + it('allows quotes and slashes', function() + execute([[terminal echo 'hello' \ "world"]]) + wait() + screen:expect([[ + ready $ echo 'hello' \ "world" | + | + [Program exited, press any key to close] | + | + | + | + -- TERMINAL -- | + ]]) + end) +end) diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua index 1bc6057a0b..e488495139 100644 --- a/test/functional/terminal/helpers.lua +++ b/test/functional/terminal/helpers.lua @@ -56,7 +56,7 @@ local function screen_setup(extra_height) -- 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('term ' ..nvim_dir.. '/tty-test') + execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') -- wait for "tty ready" to be printed before each test or the terminal may -- still be in canonical mode(will echo characters for example) -- diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 59b0d2c19d..b72527e7b6 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -27,7 +27,7 @@ describe('terminal window highlighting', function() [8] = {background = 11} }) screen:attach(false) - execute('term "' ..nvim_dir.. '/tty-test"') + execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') screen:expect([[ tty ready | | @@ -133,7 +133,7 @@ describe('terminal window highlighting with custom palette', function() }) screen:attach(true) nvim('set_var', 'terminal_color_3', '#123456') - execute('term "' ..nvim_dir.. '/tty-test"') + execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') screen:expect([[ tty ready | | diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index d9b7534fac..f2381631a9 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -332,7 +332,7 @@ describe('terminal prints more lines than the screen height and exits', function clear() local screen = Screen.new(50, 7) screen:attach(false) - execute('term ' ..nvim_dir.. '/tty-test 10') + execute('call termopen(["'..nvim_dir..'/tty-test", "10"]) | startinsert') wait() screen:expect([[ line6 | |