From 0cbfb7381e59def3d5e88ba67f6e8e07719b8134 Mon Sep 17 00:00:00 2001 From: Yee Cheng Chin Date: Mon, 1 Jul 2019 23:36:34 -0700 Subject: [PATCH] Fix for scripttest 'test_mapping'/'test_timers' not working in GUI Make sure to force Vim commands to be launched in terminal mode (-v) if they are spawned using term_start(). Otherwise they will do the wrong thing when running GUI tests. --- src/testdir/shared.vim | 7 +++++++ src/testdir/term_util.vim | 5 ++--- src/testdir/test_mapping.vim | 2 +- src/testdir/test_timers.vim | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim index 2c989633f4..ecfcd72eea 100644 --- a/src/testdir/shared.vim +++ b/src/testdir/shared.vim @@ -284,6 +284,13 @@ func GetVimCommandClean() return cmd endfunc +" Get the command to run Vim, with --clean, and force to run in terminal so it +" won't start a new GUI. +func GetVimCommandCleanTerm() + " Add -v to have gvim run in the terminal (if possible) + return GetVimCommandClean() .. ' -v ' +endfunc + " Run Vim, using the "vimcmd" file and "-u NORC". " "before" is a list of Vim commands to be executed before loading plugins. " "after" is a list of Vim commands to be executed after loading plugins. diff --git a/src/testdir/term_util.vim b/src/testdir/term_util.vim index 9bf38b39c2..5171e43292 100644 --- a/src/testdir/term_util.vim +++ b/src/testdir/term_util.vim @@ -59,10 +59,9 @@ func RunVimInTerminal(arguments, options) let cols = get(a:options, 'cols', 75) let statusoff = get(a:options, 'statusoff', 1) - let cmd = GetVimCommandClean() + let cmd = GetVimCommandCleanTerm() - " Add -v to have gvim run in the terminal (if possible) - let cmd .= ' -v ' . a:arguments + let cmd .= a:arguments let buf = term_start(cmd, { \ 'curwin': 1, \ 'term_rows': rows, diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim index 7f90b0385c..2c6aa24976 100644 --- a/src/testdir/test_mapping.vim +++ b/src/testdir/test_mapping.vim @@ -413,7 +413,7 @@ func Test_error_in_map_expr() [CODE] call writefile(lines, 'Xtest.vim') - let buf = term_start(GetVimCommandClean() .. ' -S Xtest.vim', {'term_rows': 8}) + let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8}) let job = term_getjob(buf) call WaitForAssert({-> assert_notequal('', term_getline(buf, 8))}) diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim index 9aa4f4ad9d..a41bb0f7f8 100644 --- a/src/testdir/test_timers.vim +++ b/src/testdir/test_timers.vim @@ -348,7 +348,7 @@ func Test_error_in_timer_callback() [CODE] call writefile(lines, 'Xtest.vim') - let buf = term_start(GetVimCommandClean() .. ' -S Xtest.vim', {'term_rows': 8}) + let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8}) let job = term_getjob(buf) call WaitForAssert({-> assert_notequal('', term_getline(buf, 8))})