]> granicus.if.org Git - vim/commitdiff
patch 8.0.1793: no test for "vim -g" v8.0.1793
authorBram Moolenaar <Bram@vim.org>
Sat, 5 May 2018 13:47:19 +0000 (15:47 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 May 2018 13:47:19 +0000 (15:47 +0200)
Problem:    No test for "vim -g".
Solution:   Add a test for "-g" and "-y".

src/testdir/shared.vim
src/testdir/test_gui.vim
src/version.c

index 6f4cbeec0a0b8dd75ca85c4a4ffa5665bace6b4e..69114092aada5a0c7b901d1aa017549f2005da07 100644 (file)
@@ -227,6 +227,8 @@ func GetVimProg()
   return readfile('vimcmd')[0]
 endfunc
 
+let g:valgrind_cnt = 1
+
 " Get the command to run Vim, with -u NONE and --not-a-term arguments.
 " If there is an argument use it instead of "NONE".
 func GetVimCommand(...)
@@ -244,14 +246,26 @@ func GetVimCommand(...)
   " For Unix Makefile writes the command to use in the second line of the
   " "vimcmd" file, including environment options.
   " Other Makefiles just write the executable in the first line, so fall back
-  " to that if there is no second line.
-  let cmd = get(lines, 1, lines[0])
+  " to that if there is no second line or it is empty.
+  if len(lines) > 1 && lines[1] != ''
+    let cmd = lines[1]
+  else
+    let cmd = lines[0]
+  endif
+
   let cmd = substitute(cmd, '-u \f\+', '-u ' . name, '')
   if cmd !~ '-u '. name
     let cmd = cmd . ' -u ' . name
   endif
   let cmd .= ' --not-a-term'
   let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '')
+
+  " If using valgrind, make sure every run uses a different log file.
+  if cmd =~ 'valgrind.*--log-file='
+    let cmd = substitute(cmd, '--log-file=\(^\s*\)', '--log-file=\1.' . g:valgrind_cnt, '')
+    let g:valgrind_cnt += 1
+  endif
+
   return cmd
 endfunc
 
@@ -274,9 +288,6 @@ endfunc
 
 func RunVimPiped(before, after, arguments, pipecmd)
   let cmd = GetVimCommand()
-  if cmd == ''
-    return 0
-  endif
   let args = ''
   if len(a:before) > 0
     call writefile(a:before, 'Xbefore.vim')
index 9d8a36f188bdc9627fadaa69fbb0bfac4b3301bf..60e2bf412e33bb75cca1078fa1c4eb36074243c3 100644 (file)
@@ -706,3 +706,33 @@ func Test_windowid_variable()
     call assert_equal(0, v:windowid)
   endif
 endfunc
+
+" Test "vim -g" and also the GUIEnter autocommand.
+func Test_gui_dash_g()
+  let cmd = GetVimCommand('Xscriptgui')
+  call writefile([""], "Xtestgui")
+  call writefile([
+       \ 'au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui")',
+       \ 'au GUIEnter * qall',
+       \ ], 'Xscriptgui')
+  call system(cmd . ' -g')
+  call WaitForAssert({-> assert_equal(['insertmode: 0'], readfile('Xtestgui'))})
+
+  call delete('Xscriptgui')
+  call delete('Xtestgui')
+endfunc
+
+" Test "vim -7" and also the GUIEnter autocommand.
+func Test_gui_dash_y()
+  let cmd = GetVimCommand('Xscriptgui')
+  call writefile([""], "Xtestgui")
+  call writefile([
+       \ 'au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui")',
+       \ 'au GUIEnter * qall',
+       \ ], 'Xscriptgui')
+  call system(cmd . ' -y')
+  call WaitForAssert({-> assert_equal(['insertmode: 1'], readfile('Xtestgui'))})
+
+  call delete('Xscriptgui')
+  call delete('Xtestgui')
+endfunc
index b0c8ed7c7e2dd159b05cd1c92f5d6fa8b7157e6e..e4fa0c5416c10fd352d4a1cf96c1c730f79ca1f0 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1793,
 /**/
     1792,
 /**/