From 74aef8972048c3288a3cbd6a8dadf17a8df3c08c Mon Sep 17 00:00:00 2001 From: Scott Prager Date: Mon, 13 Apr 2015 23:53:16 -0400 Subject: term: use an argument vector for termopen(). Old behaviour: termopen('cmd') would run `&shell &shcf "cmd"`, which caused the functional tests to fail on some systems due to the process not "owning" the terminal. Also, it is inconsistent with jobstart(). Modify termopen() so that &shell is not invoked, but maintain the old behaviour with :terminal. Factor the common code for building the argument vector from jobstart() and modify the functional tests to call termopen() instead of :terminal (fixes #2354). Also: * Add a 'name' option for termopen() so that `:terminal {cmd}` produces a buffer named "term//{cwd}/{cmd}" and termopen() users can customize the name. * Update the documentation. * Add functional tests for `:terminal` sinse its behaviour now differs from termopen(). Add "test/functional/fixtures/shell-test.c" and move "test/functional/job/tty-test.c" there, too. Helped-by: Justin M. Keyes <@justinmk> --- CMakeLists.txt | 2 +- runtime/doc/eval.txt | 20 ++-- runtime/doc/various.txt | 15 ++- src/nvim/eval.c | 82 ++++++++------ src/nvim/ex_docmd.c | 25 ++++- test/functional/fixtures/CMakeLists.txt | 4 + test/functional/fixtures/shell-test.c | 25 +++++ test/functional/fixtures/tty-test.c | 150 ++++++++++++++++++++++++++ test/functional/job/CMakeLists.txt | 2 - test/functional/job/tty-test.c | 150 -------------------------- test/functional/terminal/cursor_spec.lua | 2 +- test/functional/terminal/ex_terminal_spec.lua | 61 +++++++++++ test/functional/terminal/helpers.lua | 2 +- test/functional/terminal/highlight_spec.lua | 4 +- test/functional/terminal/scrollback_spec.lua | 2 +- 15 files changed, 339 insertions(+), 207 deletions(-) create mode 100644 test/functional/fixtures/CMakeLists.txt create mode 100644 test/functional/fixtures/shell-test.c create mode 100644 test/functional/fixtures/tty-test.c delete mode 100644 test/functional/job/CMakeLists.txt delete mode 100644 test/functional/job/tty-test.c create mode 100644 test/functional/terminal/ex_terminal_spec.lua diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e176a540d..345d7b8ff6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,7 +296,7 @@ get_compile_flags(NVIM_VERSION_CFLAGS) add_subdirectory(test/includes) add_subdirectory(config) -add_subdirectory(test/functional/job) # compile pty test program +add_subdirectory(test/functional/fixtures) # compile pty/shell test programs # Setup some test-related bits. We do this after going down the tree because we diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 0284e6cab8..f151fd84ba 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -6299,15 +6299,17 @@ tempname() *tempname()* *temp-file-name* For MS-Windows forward slashes are used when the 'shellslash' option is set or when 'shellcmdflag' starts with '-'. -termopen({command}[, {opts}]) {Nvim} *termopen()* - Spawns {command} using the shell in a new pseudo-terminal - session connected to the current buffer. This function fails - if the current buffer is modified (all buffer contents are - destroyed). The {opts} dict is similar to the one passed to - |jobstart()|, but the `pty`, `width`, `height`, and `TERM` fields are - ignored: `height`/`width` are taken from the current window and - $TERM is set to "xterm-256color". Returns the same values as - |jobstart()|. +termopen({argv}[, {opts}]) {Nvim} *termopen()* + Spawns {argv}(list) in a new pseudo-terminal session connected + to the current buffer. This function fails if the current + buffer is modified (all buffer contents are destroyed). + + The {opts} dict is similar to the one passed to |jobstart()|, + but the `pty`, `width`, `height`, and `TERM` fields are + ignored: `height`/`width` are taken from the current window + and `$TERM` is set to "xterm-256color". An additional option, + `name`, can be used to give the terminal a specific name. + Returns the same values as |jobstart()|. See |nvim-terminal-emulator| for more information. diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 8ddfdf272f..13bc089824 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -223,11 +223,18 @@ g8 Print the hex values of the bytes used in the :sh[ell] Removed. |vim-differences| {Nvim} *:term* *:terminal* -:term[inal][!] {cmd} Spawns {command} using the current value of 'shell' - in a new terminal buffer. This is equivalent to: > - - :enew | call termopen('{cmd}') | startinsert +:term[inal][!] {cmd} Spawns {cmd} using the current value of 'shell' and + 'shellcmdflag' in a new terminal buffer. This is + equivalent to: > + + :enew + :call termopen([&sh, &shcf, '{cmd}'], + \{'name':'{cmd}'}) + :startinsert < + If no {cmd} is given, 'shellcmdflag' will not be sent + to |termopen()|. + Like |:enew|, it will fail if the current buffer is modified, but can be forced with "!". See |termopen()| and |nvim-terminal-emulator| for more information. diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 1065f1caf9..ea5dbc8a3f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10779,47 +10779,62 @@ static void f_jobresize(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = 1; } -// "jobstart()" function -static void f_jobstart(typval_T *argvars, typval_T *rettv) +static char **list_to_argv(list_T *args) { - rettv->v_type = VAR_NUMBER; - rettv->vval.v_number = 0; - - if (check_restricted() || check_secure()) { - return; - } - - if (argvars[0].v_type != VAR_LIST - || (argvars[1].v_type != VAR_DICT && argvars[1].v_type != VAR_UNKNOWN)) { - // Wrong argument types - EMSG(_(e_invarg)); - return; - } - - list_T *args = argvars[0].vval.v_list; - // Assert that all list items are strings for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { if (arg->li_tv.v_type != VAR_STRING) { EMSG(_(e_invarg)); - return; + return NULL; } } int argc = args->lv_len; if (!argc) { EMSG(_("Argument vector must have at least one item")); - return; + return NULL; } assert(args->lv_first); - + const char_u *exe = get_tv_string(&args->lv_first->li_tv); if (!os_can_exe(exe, NULL)) { // String is not executable EMSG2(e_jobexe, exe); + return NULL; + } + + // Build the argument vector + int i = 0; + char **argv = xcalloc(argc + 1, sizeof(char *)); + for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { + argv[i++] = xstrdup((char *) get_tv_string(&arg->li_tv)); + } + + return argv; +} + +// "jobstart()" function +static void f_jobstart(typval_T *argvars, typval_T *rettv) +{ + rettv->v_type = VAR_NUMBER; + rettv->vval.v_number = 0; + + if (check_restricted() || check_secure()) { + return; + } + + if (argvars[0].v_type != VAR_LIST + || (argvars[1].v_type != VAR_DICT && argvars[1].v_type != VAR_UNKNOWN)) { + // Wrong argument types + EMSG(_(e_invarg)); return; } + char **argv = list_to_argv(argvars[0].vval.v_list); + if (!argv) { + return; // Did error message in list_to_argv. + } + dict_T *job_opts = NULL; ufunc_T *on_stdout = NULL, *on_stderr = NULL, *on_exit = NULL; if (argvars[1].v_type == VAR_DICT) { @@ -10829,13 +10844,6 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv) } } - // Build the argument vector - int i = 0; - char **argv = xcalloc(argc + 1, sizeof(char *)); - for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - argv[i++] = xstrdup((char *) get_tv_string(&arg->li_tv)); - } - JobOptions opts = common_job_options(argv, on_stdout, on_stderr, on_exit, job_opts); @@ -15155,13 +15163,18 @@ static void f_termopen(typval_T *argvars, typval_T *rettv) return; } - if (argvars[0].v_type != VAR_STRING + if (argvars[0].v_type != VAR_LIST || (argvars[1].v_type != VAR_DICT && argvars[1].v_type != VAR_UNKNOWN)) { // Wrong argument types EMSG(_(e_invarg)); return; } + char **argv = list_to_argv(argvars[0].vval.v_list); + if (!argv) { + return; // Did error message in list_to_argv. + } + ufunc_T *on_stdout = NULL, *on_stderr = NULL, *on_exit = NULL; dict_T *job_opts = NULL; if (argvars[1].v_type == VAR_DICT) { @@ -15171,7 +15184,6 @@ static void f_termopen(typval_T *argvars, typval_T *rettv) } } - char **argv = shell_build_argv((char *)argvars[0].vval.v_string, NULL); JobOptions opts = common_job_options(argv, on_stdout, on_stderr, on_exit, job_opts); opts.pty = true; @@ -15197,10 +15209,16 @@ static void f_termopen(typval_T *argvars, typval_T *rettv) cwd = (char *)argvars[1].vval.v_string; } int pid = job_pid(job); + + // Get the desired name of the buffer. + char *name = job_opts ? + (char *)get_dict_string(job_opts, (char_u *)"name", false) : NULL; + if (!name) { + name = argv[0]; + } char buf[1024]; // format the title with the pid to conform with the term:// URI - snprintf(buf, sizeof(buf), "term://%s//%d:%s", cwd, pid, - (char *)argvars[0].vval.v_string); + snprintf(buf, sizeof(buf), "term://%s//%d:%s", cwd, pid, name); // at this point the buffer has no terminal instance associated yet, so unset // the 'swapfile' option to ensure no swap file will be created curbuf->b_p_swf = false; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index e81f99ccea..656311ae14 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9410,9 +9410,26 @@ static void ex_folddo(exarg_T *eap) static void ex_terminal(exarg_T *eap) { + char *name = NULL; char cmd[512]; - snprintf(cmd, sizeof(cmd), ":enew%s | call termopen('%s') | startinsert", - eap->forceit==TRUE ? "!" : "", - strcmp((char *)eap->arg, "") ? (char *)eap->arg : (char *)p_sh); - do_cmdline_cmd((uint8_t *)cmd); + if (strcmp((char *)eap->arg, "") == 0) { + snprintf(cmd, sizeof(cmd), "['%s']", (char *)p_sh); + name = (char *)p_sh; + } else { + // Escape quotes and slashes so they get sent literally. + name = (char *)vim_strsave_escaped(eap->arg, (char_u *)"\"\\"); + snprintf(cmd, sizeof(cmd), "['%s','%s',\"%s\"]", + (char *)p_sh, (char *)p_shcf, name); + } + + char ex_cmd[512]; + snprintf(ex_cmd, sizeof(ex_cmd), + ":enew%s | call termopen(%s, {'name':\"%s\"}) | startinsert", + eap->forceit==TRUE ? "!" : "", cmd, name); + + do_cmdline_cmd((uint8_t *)ex_cmd); + + if (name != (char *)p_sh) { + xfree(name); + } } diff --git a/test/functional/fixtures/CMakeLists.txt b/test/functional/fixtures/CMakeLists.txt new file mode 100644 index 0000000000..70aee6efa9 --- /dev/null +++ b/test/functional/fixtures/CMakeLists.txt @@ -0,0 +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 +#include + +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/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c new file mode 100644 index 0000000000..40ba131003 --- /dev/null +++ b/test/functional/fixtures/tty-test.c @@ -0,0 +1,150 @@ +#include +#include +#include +#include + +uv_tty_t tty; + +#ifdef _WIN32 +#include +bool owns_tty(void) +{ + HWND consoleWnd = GetConsoleWindow(); + DWORD dwProcessId; + GetWindowThreadProcessId(consoleWnd, &dwProcessId); + return GetCurrentProcessId() == dwProcessId; +} +#else +#include +bool owns_tty(void) +{ + return getsid(0) == getpid(); +} +#endif + +#define is_terminal(stream) (uv_guess_handle(fileno(stream)) == UV_TTY) +#define BUF_SIZE 0xfff + +static void walk_cb(uv_handle_t *handle, void *arg) { + if (!uv_is_closing(handle)) { + uv_close(handle, NULL); + } +} + +static void sigwinch_handler(int signum) +{ + int width, height; + uv_tty_get_winsize(&tty, &width, &height); + fprintf(stderr, "rows: %d, cols: %d\n", height, width); +} + +// static void sigwinch_cb(uv_signal_t *handle, int signum) +// { +// int width, height; +// uv_tty_t *tty = handle->data; +// uv_tty_get_winsize(tty, &width, &height); +// fprintf(stderr, "rows: %d, cols: %d\n", height, width); +// } + +static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf) +{ + buf->len = BUF_SIZE; + buf->base = malloc(BUF_SIZE); +} + +static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) +{ + if (cnt <= 0) { + uv_read_stop(stream); + return; + } + + int *interrupted = stream->data; + + for (int i = 0; i < cnt; i++) { + if (buf->base[i] == 3) { + (*interrupted)++; + } + } + + uv_loop_t write_loop; + uv_loop_init(&write_loop); + uv_tty_t out; + uv_tty_init(&write_loop, &out, 1, 0); + uv_write_t req; + uv_buf_t b = {.base = buf->base, .len = (size_t)cnt}; + uv_write(&req, (uv_stream_t *)&out, &b, 1, NULL); + uv_run(&write_loop, UV_RUN_DEFAULT); + uv_close((uv_handle_t *)&out, NULL); + uv_run(&write_loop, UV_RUN_DEFAULT); + if (uv_loop_close(&write_loop)) { + abort(); + } + free(buf->base); + + if (*interrupted >= 2) { + uv_walk(uv_default_loop(), walk_cb, NULL); + } else if (*interrupted == 1) { + fprintf(stderr, "interrupt received, press again to exit\n"); + } +} + +static void prepare_cb(uv_prepare_t *handle) +{ + fprintf(stderr, "tty ready\n"); + uv_prepare_stop(handle); +} + +int main(int argc, char **argv) +{ + if (!owns_tty()) { + fprintf(stderr, "process does not own the terminal\n"); + exit(2); + } + + if (!is_terminal(stdin)) { + fprintf(stderr, "stdin is not a terminal\n"); + exit(2); + } + + if (!is_terminal(stdout)) { + fprintf(stderr, "stdout is not a terminal\n"); + exit(2); + } + + if (!is_terminal(stderr)) { + fprintf(stderr, "stderr is not a terminal\n"); + exit(2); + } + + if (argc > 1) { + int count = atoi(argv[1]); + for (int i = 0; i < count; ++i) { + printf("line%d\n", i); + } + fflush(stdout); + return 0; + } + + int interrupted = 0; + uv_prepare_t prepare; + uv_prepare_init(uv_default_loop(), &prepare); + uv_prepare_start(&prepare, prepare_cb); + // uv_tty_t tty; + uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1); + uv_tty_set_mode(&tty, UV_TTY_MODE_RAW); + tty.data = &interrupted; + uv_read_start((uv_stream_t *)&tty, alloc_cb, read_cb); + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = sigwinch_handler; + sigaction(SIGWINCH, &sa, NULL); + // uv_signal_t sigwinch_watcher; + // uv_signal_init(uv_default_loop(), &sigwinch_watcher); + // sigwinch_watcher.data = &tty; + // uv_signal_start(&sigwinch_watcher, sigwinch_cb, SIGWINCH); + uv_run(uv_default_loop(), UV_RUN_DEFAULT); + + return 0; +} diff --git a/test/functional/job/CMakeLists.txt b/test/functional/job/CMakeLists.txt deleted file mode 100644 index 14ec287816..0000000000 --- a/test/functional/job/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(tty-test tty-test.c) -target_link_libraries(tty-test ${LIBUV_LIBRARIES}) diff --git a/test/functional/job/tty-test.c b/test/functional/job/tty-test.c deleted file mode 100644 index 40ba131003..0000000000 --- a/test/functional/job/tty-test.c +++ /dev/null @@ -1,150 +0,0 @@ -#include -#include -#include -#include - -uv_tty_t tty; - -#ifdef _WIN32 -#include -bool owns_tty(void) -{ - HWND consoleWnd = GetConsoleWindow(); - DWORD dwProcessId; - GetWindowThreadProcessId(consoleWnd, &dwProcessId); - return GetCurrentProcessId() == dwProcessId; -} -#else -#include -bool owns_tty(void) -{ - return getsid(0) == getpid(); -} -#endif - -#define is_terminal(stream) (uv_guess_handle(fileno(stream)) == UV_TTY) -#define BUF_SIZE 0xfff - -static void walk_cb(uv_handle_t *handle, void *arg) { - if (!uv_is_closing(handle)) { - uv_close(handle, NULL); - } -} - -static void sigwinch_handler(int signum) -{ - int width, height; - uv_tty_get_winsize(&tty, &width, &height); - fprintf(stderr, "rows: %d, cols: %d\n", height, width); -} - -// static void sigwinch_cb(uv_signal_t *handle, int signum) -// { -// int width, height; -// uv_tty_t *tty = handle->data; -// uv_tty_get_winsize(tty, &width, &height); -// fprintf(stderr, "rows: %d, cols: %d\n", height, width); -// } - -static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf) -{ - buf->len = BUF_SIZE; - buf->base = malloc(BUF_SIZE); -} - -static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) -{ - if (cnt <= 0) { - uv_read_stop(stream); - return; - } - - int *interrupted = stream->data; - - for (int i = 0; i < cnt; i++) { - if (buf->base[i] == 3) { - (*interrupted)++; - } - } - - uv_loop_t write_loop; - uv_loop_init(&write_loop); - uv_tty_t out; - uv_tty_init(&write_loop, &out, 1, 0); - uv_write_t req; - uv_buf_t b = {.base = buf->base, .len = (size_t)cnt}; - uv_write(&req, (uv_stream_t *)&out, &b, 1, NULL); - uv_run(&write_loop, UV_RUN_DEFAULT); - uv_close((uv_handle_t *)&out, NULL); - uv_run(&write_loop, UV_RUN_DEFAULT); - if (uv_loop_close(&write_loop)) { - abort(); - } - free(buf->base); - - if (*interrupted >= 2) { - uv_walk(uv_default_loop(), walk_cb, NULL); - } else if (*interrupted == 1) { - fprintf(stderr, "interrupt received, press again to exit\n"); - } -} - -static void prepare_cb(uv_prepare_t *handle) -{ - fprintf(stderr, "tty ready\n"); - uv_prepare_stop(handle); -} - -int main(int argc, char **argv) -{ - if (!owns_tty()) { - fprintf(stderr, "process does not own the terminal\n"); - exit(2); - } - - if (!is_terminal(stdin)) { - fprintf(stderr, "stdin is not a terminal\n"); - exit(2); - } - - if (!is_terminal(stdout)) { - fprintf(stderr, "stdout is not a terminal\n"); - exit(2); - } - - if (!is_terminal(stderr)) { - fprintf(stderr, "stderr is not a terminal\n"); - exit(2); - } - - if (argc > 1) { - int count = atoi(argv[1]); - for (int i = 0; i < count; ++i) { - printf("line%d\n", i); - } - fflush(stdout); - return 0; - } - - int interrupted = 0; - uv_prepare_t prepare; - uv_prepare_init(uv_default_loop(), &prepare); - uv_prepare_start(&prepare, prepare_cb); - // uv_tty_t tty; - uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1); - uv_tty_set_mode(&tty, UV_TTY_MODE_RAW); - tty.data = &interrupted; - uv_read_start((uv_stream_t *)&tty, alloc_cb, read_cb); - struct sigaction sa; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sa.sa_handler = sigwinch_handler; - sigaction(SIGWINCH, &sa, NULL); - // uv_signal_t sigwinch_watcher; - // uv_signal_init(uv_default_loop(), &sigwinch_watcher); - // sigwinch_watcher.data = &tty; - // uv_signal_start(&sigwinch_watcher, sigwinch_cb, SIGWINCH); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - - return 0; -} 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 | -- cgit