]> granicus.if.org Git - vim/commitdiff
patch 8.0.0361: GUI initialisation is not sufficiently tested v8.0.0361
authorBram Moolenaar <Bram@vim.org>
Thu, 23 Feb 2017 18:32:47 +0000 (19:32 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 23 Feb 2017 18:32:47 +0000 (19:32 +0100)
Problem:    GUI initialisation is not sufficiently tested.
Solution:   Add the gui_init test. (Kazuki Kuriyama)

Filelist
src/Makefile
src/testdir/Make_all.mak
src/testdir/Make_dos.mak
src/testdir/Make_ming.mak
src/testdir/Makefile
src/testdir/gui_init.vim [new file with mode: 0644]
src/testdir/setup_gui.vim [new file with mode: 0644]
src/testdir/test_gui.vim
src/testdir/test_gui_init.vim [new file with mode: 0644]
src/version.c

index a3c8f5494289e8bd655234c3bfab6629ad52a467..316a40312725f0ff17f6c39a1503b9b88331df82 100644 (file)
--- a/Filelist
+++ b/Filelist
@@ -105,7 +105,10 @@ SRC_ALL =  \
                src/testdir/sautest/autoload/*.vim \
                src/testdir/runtest.vim \
                src/testdir/shared.vim \
+               src/testdir/view_util.vim \
                src/testdir/setup.vim \
+               src/testdir/gui_init.vim \
+               src/testdir/setup_gui.vim \
                src/testdir/test[0-9]*.ok \
                src/testdir/test[0-9]*a.ok \
                src/testdir/test_[a-z]*.ok \
index bcfb8cd1355986bfeb8c58c8e038d426db91ad90..227e1df4eb5e0596e47b12639e9c6c493822bf40 100644 (file)
@@ -2133,6 +2133,7 @@ test_arglist \
        test_gn \
        test_goto \
        test_gui \
+       test_gui_init \
        test_hardcopy \
        test_help \
        test_help_tagjump \
index 7e18b11dd358d253cbdb37bbd0c333762baddeda..057e8b13aab4bf8d1d5a3eb3c97c97948bb2d509 100644 (file)
@@ -2,7 +2,10 @@
 # Common Makefile, defines the list of tests to run.
 #
 
-NO_PLUGIN = -U NONE --noplugin --not-a-term
+# Options for protecting the tests against undesirable interaction with the
+# environment
+NO_PLUGINS = --noplugin --not-a-term
+NO_INITS = -U NONE $(NO_PLUGINS)
 
 # The first script creates small.vim.
 SCRIPTS_FIRST = \
@@ -152,6 +155,7 @@ NEW_TESTS = test_arglist.res \
            test_gf.res \
            test_gn.res \
            test_gui.res \
+           test_gui_init.res \
            test_hardcopy.res \
            test_help.res \
            test_hide.res \
index c28b1a4b1b4015f74eccdb81b3f8f9c98087b97f..8d235b58ff9baeaa9307280c9750b487388adbff 100644 (file)
@@ -38,7 +38,7 @@ win32:        nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) newtests report
 $(DOSTMP_INFILES): $(*B).in
        if not exist $(DOSTMP)\NUL md $(DOSTMP)
        if exist $@ del $@
-       $(VIMPROG) -u dos.vim $(NO_PLUGIN) "+set ff=dos|f $@|wq" $(*B).in
+       $(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=dos|f $@|wq" $(*B).in
 
 # For each input file dostmp/test99.in run the tests.
 # This moves test99.in to test99.in.bak temporarily.
@@ -47,7 +47,7 @@ $(TEST_OUTFILES): $(DOSTMP)\$(*B).in
        move $(*B).in $(*B).in.bak > nul
        copy $(DOSTMP)\$(*B).in $(*B).in > nul
        copy $(*B).ok test.ok > nul
-       $(VIMPROG) -u dos.vim $(NO_PLUGIN) -s dotest.in $(*B).in
+       $(VIMPROG) -u dos.vim $(NO_INITS) -s dotest.in $(*B).in
        -@if exist test.out MOVE /y test.out $(DOSTMP)\$(*B).out > nul
        -@if exist $(*B).in.bak move /y $(*B).in.bak $(*B).in > nul
        -@if exist test.ok del test.ok
@@ -55,7 +55,7 @@ $(TEST_OUTFILES): $(DOSTMP)\$(*B).in
        -@if exist Xfind rd /s /q Xfind
        -@del X*
        -@if exist viminfo del viminfo
-       $(VIMPROG) -u dos.vim $(NO_PLUGIN) "+set ff=unix|f test.out|wq" \
+       $(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=unix|f test.out|wq" \
                $(DOSTMP)\$(*B).out
        @diff test.out $*.ok & if errorlevel 1 \
                ( move /y test.out $*.failed > nul \
@@ -104,7 +104,7 @@ benchmark:
 
 bench_re_freeze.out: bench_re_freeze.vim
        -if exist benchmark.out del benchmark.out
-       $(VIMPROG) -u dos.vim $(NO_PLUGIN) $*.in
+       $(VIMPROG) -u dos.vim $(NO_INITS) $*.in
        @IF EXIST benchmark.out ( type benchmark.out )
 
 # New style of tests uses Vim script with assert calls.  These are easier
@@ -115,5 +115,15 @@ newtests: $(NEW_TESTS)
 
 .vim.res:
        @echo "$(VIMPROG)" > vimcmd
-       $(VIMPROG) -u NONE $(NO_PLUGIN) -S runtest.vim $*.vim
+       $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
+       @del vimcmd
+
+test_gui.res: test_gui.vim
+       @echo "$(VIMPROG)" > vimcmd
+       $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $<
+       @del vimcmd
+
+test_gui_init.res: test_gui_init.vim
+       @echo "$(VIMPROG)" > vimcmd
+       $(VIMPROG) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
        @del vimcmd
index ab6a60b9245c655aacc64ec1799a0f8729fd842c..61d77d2f53d9227450a3dbd387be0c21c7986b1d 100644 (file)
@@ -66,8 +66,8 @@ win32:        fixff nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) newtests
 
 # TODO: find a way to avoid changing the distributed files.
 fixff:
-       -$(VIMPROG) -u dos.vim $(NO_PLUGIN) "+argdo set ff=dos|upd" +q *.in *.ok
-       -$(VIMPROG) -u dos.vim $(NO_PLUGIN) "+argdo set ff=unix|upd" +q \
+       -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=dos|upd" +q *.in *.ok
+       -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=unix|upd" +q \
                dotest.in test60.ok test_listchars.ok \
                test_getcwd.ok test_wordcount.ok
 
@@ -91,7 +91,7 @@ clean:
 
 .in.out:
        -@if exist $*.ok $(CP) $*.ok test.ok
-       $(VIMPROG) -u dos.vim $(NO_PLUGIN) -s dotest.in $*.in
+       $(VIMPROG) -u dos.vim $(NO_INITS) -s dotest.in $*.in
        @diff test.out $*.ok
        -@if exist $*.out $(DEL) $*.out
        @$(MV) test.out $*.out
@@ -107,7 +107,7 @@ nolog:
 
 bench_re_freeze.out: bench_re_freeze.vim
        -$(DEL) benchmark.out
-       $(VIMPROG) -u dos.vim $(NO_PLUGIN) $*.in
+       $(VIMPROG) -u dos.vim $(NO_INITS) $*.in
        $(CAT) benchmark.out
 
 # New style of tests uses Vim script with assert calls.  These are easier
@@ -118,6 +118,16 @@ newtests: $(NEW_TESTS)
 
 .vim.res:
        @echo "$(VIMPROG)" > vimcmd
-       $(VIMPROG) -u NONE $(NO_PLUGIN) -S runtest.vim $*.vim
+       $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
+       @$(DEL) vimcmd
+
+test_gui.res: test_gui.vim
+       @echo "$(VIMPROG)" > vimcmd
+       $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $<
+       @$(DEL) vimcmd
+
+test_gui_init.res: test_gui_init.vim
+       @echo "$(VIMPROG)" > vimcmd
+       $(VIMPROG) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
        @$(DEL) vimcmd
 
index bb0249ac7cba053ca9c0f8c4ae0d414a15e38614..ac75e43577c28ad01b1ae509ee859717cd8f4c03 100644 (file)
@@ -52,7 +52,7 @@ $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(SCRIPTS_FIRST)
 
 RM_ON_RUN = test.out X* viminfo
 RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim lua.vim test.ok benchmark.out
-RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_PLUGIN) -s dotest.in
+RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_INITS) -s dotest.in
 
 clean:
        -rm -rf *.out *.failed *.res *.rej *.orig test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.*
@@ -118,7 +118,7 @@ nolog:
 # New style of tests uses Vim script with assert calls.  These are easier
 # to write and a lot easier to read and debug.
 # Limitation: Only works with the +eval feature.
-RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_PLUGIN)
+RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim
 
 newtests: newtestssilent
        @/bin/sh -c "if test -f messages && grep -q 'SKIPPED\|FAILED' messages; then cat messages && if test -f test.log; then cat test.log; fi ; fi"
@@ -128,5 +128,15 @@ newtestssilent: $(NEW_TESTS)
 
 .vim.res:
        @echo "$(RUN_VIMTEST)" > vimcmd
-       $(RUN_VIMTEST) -U NONE -S runtest.vim $*.vim
+       $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim
+       @rm vimcmd
+
+test_gui.res: test_gui.vim
+       @echo "$(RUN_GVIMTEST)" > vimcmd
+       $(RUN_VIMTEST) -u NONE $(NO_INITS) -S runtest.vim $<
+       @rm vimcmd
+
+test_gui_init.res: test_gui_init.vim
+       @echo "$(RUN_GVIMTEST_WITH_GVIMRC)" > vimcmd
+       $(RUN_VIMTEST) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
        @rm vimcmd
diff --git a/src/testdir/gui_init.vim b/src/testdir/gui_init.vim
new file mode 100644 (file)
index 0000000..bc5e33c
--- /dev/null
@@ -0,0 +1,5 @@
+" gvimrc for test_gui_init.vim
+
+if has('gui_athena') || has('gui_motif') || has('gui_gtk2') || has('gui_gtk3')
+  set guiheadroom=0
+endif
diff --git a/src/testdir/setup_gui.vim b/src/testdir/setup_gui.vim
new file mode 100644 (file)
index 0000000..88f538e
--- /dev/null
@@ -0,0 +1,29 @@
+" Common preparations for running GUI tests.
+
+let g:x11_based_gui = has('gui_athena') || has('gui_motif')
+       \ || has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
+
+" Reasons for 'skipped'.
+let g:not_supported   = "Skipped: Feature/Option not supported by this GUI: "
+let g:not_implemented = "Skipped: Test not implemented yet for this GUI"
+let g:not_hosted      = "Skipped: Test not hosted by the system/environment"
+
+" For KDE set a font, empty 'guifont' may cause a hang.
+func GUISetUpCommon()
+  if has("gui_kde")
+    set guifont=Courier\ 10\ Pitch/8/-1/5/50/0/0/0/0/0
+  endif
+
+  " Gnome insists on creating $HOME/.gnome2/, set $HOME to avoid changing the
+  " actual home directory.  But avoid triggering fontconfig by setting the
+  " cache directory.  Only needed for Unix.
+  if $XDG_CACHE_HOME == '' && exists('g:tester_HOME')
+    let $XDG_CACHE_HOME = g:tester_HOME . '/.cache'
+  endif
+  call mkdir('Xhome')
+  let $HOME = fnamemodify('Xhome', ':p')
+endfunc
+
+func GUITearDownCommon()
+  call delete('Xhome', 'rf')
+endfunc
index aad56904152b9bec3618b6f9fa2dfec0f367440d..d9430747de78a49e40659a09e0fb81138d414f0f 100644 (file)
@@ -4,32 +4,14 @@ if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
   finish
 endif
 
-let s:x11_based_gui = has('gui_athena') || has('gui_motif')
-       \ || has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
-
-" Reasons for 'skipped'.
-let s:not_supported   = "Skipped: Feature/Option not supported by this GUI: "
-let s:not_implemented = "Skipped: Test not implemented yet for this GUI"
-let s:not_hosted      = "Skipped: Test not hosted by the system/environment"
-
-" For KDE set a font, empty 'guifont' may cause a hang.
-func SetUp()
-  if has("gui_kde")
-    set guifont=Courier\ 10\ Pitch/8/-1/5/50/0/0/0/0/0
-  endif
+source setup_gui.vim
 
-  " Gnome insists on creating $HOME/.gnome2/, set $HOME to avoid changing the
-  " actual home directory.  But avoid triggering fontconfig by setting the
-  " cache directory.  Only needed for Unix.
-  if $XDG_CACHE_HOME == '' && exists('g:tester_HOME')
-    let $XDG_CACHE_HOME = g:tester_HOME . '/.cache'
-  endif
-  call mkdir('Xhome')
-  let $HOME = fnamemodify('Xhome', ':p')
+func Setup()
+  call GUISetUpCommon()
 endfunc
 
 func TearDown()
-  call delete('Xhome', 'rf')
+  call GUITearDownCommon()
 endfunc
 
 " Test for resetting "secure" flag after GUI has started.
@@ -43,8 +25,8 @@ endfunc
 func Test_getfontname_with_arg()
   let skipped = ''
 
-  if !s:x11_based_gui
-    let skipped = s:not_implemented
+  if !g:x11_based_gui
+    let skipped = g:not_implemented
   elseif has('gui_athena') || has('gui_motif')
     " Invalid font name. The result should be an empty string.
     call assert_equal('', getfontname('notexist'))
@@ -72,8 +54,8 @@ func Test_getfontname_without_arg()
 
   let fname = getfontname()
 
-  if !s:x11_based_gui
-    let skipped = s:not_implemented
+  if !g:x11_based_gui
+    let skipped = g:not_implemented
   elseif has('gui_kde')
     " 'expected' is the value specified by SetUp() above.
     call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname)
@@ -100,8 +82,8 @@ func Test_set_guifont()
     set guifontset=
   endif
 
-  if !s:x11_based_gui
-    let skipped = s:not_implemented
+  if !g:x11_based_gui
+    let skipped = g:not_implemented
   elseif has('gui_athena') || has('gui_motif')
     " Non-empty font list with invalid font names.
     "
@@ -153,7 +135,7 @@ func Test_set_guifontset()
   let skipped = ''
 
   if !has('xfontset')
-    let skipped = s:not_supported . 'xfontset'
+    let skipped = g:not_supported . 'xfontset'
   else
     let ctype_saved = v:ctype
 
@@ -202,7 +184,7 @@ func Test_set_guifontset()
 
     " Third, give a set of tests if it is found feasible.
     if !feasible
-      let skipped = s:not_hosted
+      let skipped = g:not_hosted
     else
       " N.B. 'v:ctype' has already been set to an appropriate value in the
       " previous loop.
@@ -224,15 +206,15 @@ endfunc
 func Test_set_guifontwide()
   let skipped = ''
 
-  if !s:x11_based_gui
-    let skipped = s:not_implemented
+  if !g:x11_based_gui
+    let skipped = g:not_implemented
   elseif has('gui_gtk')
     let guifont_saved = &guifont
     let guifontwide_saved = &guifontwide
 
     let fc_match = exepath('fc-match')
     if empty(fc_match)
-      let skipped = s:not_hosted
+      let skipped = g:not_hosted
     else
       let &guifont = system('fc-match -f "%{family[0]} %{size}" monospace:size=10:lang=en')
       let wide = system('fc-match -f "%{family[0]} %{size}" monospace:size=10:lang=ja')
@@ -246,7 +228,7 @@ func Test_set_guifontwide()
   elseif has('gui_athena') || has('gui_motif')
     " guifontwide is premised upon the xfontset feature.
     if !has('xfontset')
-      let skipped = s:not_supported . 'xfontset'
+      let skipped = g:not_supported . 'xfontset'
     else
       let encoding_saved    = &encoding
       let guifont_saved     = &guifont
@@ -303,6 +285,22 @@ func Test_set_guifontwide()
   endif
 endfunc
 
+func Test_set_guiheadroom()
+  let skipped = ''
+
+  if !g:x11_based_gui
+    let skipped = g:not_supported . 'guiheadroom'
+  else
+    " Since this script is to be read together with '-U NONE', the default
+    " value must be preserved.
+    call assert_equal(50, &guiheadroom)
+  endif
+
+  if !empty(skipped)
+    throw skipped
+  endif
+endfunc
+
 func Test_getwinpos()
   call assert_match('Window position: X \d\+, Y \d\+', execute('winpos'))
   call assert_true(getwinposx() >= 0)
@@ -317,7 +315,7 @@ func Test_shell_command()
 endfunc
 
 func Test_windowid_variable()
-  if s:x11_based_gui || has('win32')
+  if g:x11_based_gui || has('win32')
     call assert_true(v:windowid > 0)
   else
     call assert_equal(0, v:windowid)
diff --git a/src/testdir/test_gui_init.vim b/src/testdir/test_gui_init.vim
new file mode 100644 (file)
index 0000000..a092299
--- /dev/null
@@ -0,0 +1,35 @@
+" Tests specifically for the GUI features/options that need to be set up at
+" startup to take effect at runtime.
+
+if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
+  finish
+endif
+
+source setup_gui.vim
+
+func Setup()
+  call GUISetUpCommon()
+endfunc
+
+func TearDown()
+  call GUITearDownCommon()
+endfunc
+
+" Make sure that the tests will be done with the GUI activated.
+gui -f
+
+func Test_set_guiheadroom()
+  let skipped = ''
+
+  if !g:x11_based_gui
+    let skipped = g:not_supported . 'guiheadroom'
+  else
+    " The 'expected' value must be consistent with the value specified with
+    " gui_init.vim.
+    call assert_equal(0, &guiheadroom)
+  endif
+
+  if !empty(skipped)
+    throw skipped
+  endif
+endfunc
index a282a5f8594bc7a65a3dbe8ee0572e36e6de6385..bd2ddb18f87b23c79f3b2029aeed4ff125cc3c9e 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    361,
 /**/
     360,
 /**/