Skip to content

Commit 0cbfb73

Browse files
committed
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.
1 parent 8fa50d1 commit 0cbfb73

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/testdir/shared.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@ func GetVimCommandClean()
284284
return cmd
285285
endfunc
286286

287+
" Get the command to run Vim, with --clean, and force to run in terminal so it
288+
" won't start a new GUI.
289+
func GetVimCommandCleanTerm()
290+
" Add -v to have gvim run in the terminal (if possible)
291+
return GetVimCommandClean() .. ' -v '
292+
endfunc
293+
287294
" Run Vim, using the "vimcmd" file and "-u NORC".
288295
" "before" is a list of Vim commands to be executed before loading plugins.
289296
" "after" is a list of Vim commands to be executed after loading plugins.

src/testdir/term_util.vim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ func RunVimInTerminal(arguments, options)
5959
let cols = get(a:options, 'cols', 75)
6060
let statusoff = get(a:options, 'statusoff', 1)
6161

62-
let cmd = GetVimCommandClean()
62+
let cmd = GetVimCommandCleanTerm()
6363

64-
" Add -v to have gvim run in the terminal (if possible)
65-
let cmd .= ' -v ' . a:arguments
64+
let cmd .= a:arguments
6665
let buf = term_start(cmd, {
6766
\ 'curwin': 1,
6867
\ 'term_rows': rows,

src/testdir/test_mapping.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ func Test_error_in_map_expr()
413413
[CODE]
414414
call writefile(lines, 'Xtest.vim')
415415

416-
let buf = term_start(GetVimCommandClean() .. ' -S Xtest.vim', {'term_rows': 8})
416+
let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8})
417417
let job = term_getjob(buf)
418418
call WaitForAssert({-> assert_notequal('', term_getline(buf, 8))})
419419

src/testdir/test_timers.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func Test_error_in_timer_callback()
348348
[CODE]
349349
call writefile(lines, 'Xtest.vim')
350350

351-
let buf = term_start(GetVimCommandClean() .. ' -S Xtest.vim', {'term_rows': 8})
351+
let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8})
352352
let job = term_getjob(buf)
353353
call WaitForAssert({-> assert_notequal('', term_getline(buf, 8))})
354354

0 commit comments

Comments
 (0)