To: vim_dev@googlegroups.com Subject: Patch 8.0.0361 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0361 Problem: GUI initialisation is not sufficiently tested. Solution: Add the gui_init test. (Kazuki Kuriyama) Files: 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, src/testdir/setup_gui.vim, src/testdir/test_gui.vim, src/testdir/test_gui_init.vim, Filelist *** ../vim-8.0.0360/src/Makefile 2017-02-23 19:00:28.508904228 +0100 --- src/Makefile 2017-02-23 19:13:12.408028718 +0100 *************** *** 2133,2138 **** --- 2133,2139 ---- test_gn \ test_goto \ test_gui \ + test_gui_init \ test_hardcopy \ test_help \ test_help_tagjump \ *** ../vim-8.0.0360/src/testdir/Make_all.mak 2017-02-23 19:00:28.512904202 +0100 --- src/testdir/Make_all.mak 2017-02-23 19:16:26.794787125 +0100 *************** *** 2,8 **** # Common Makefile, defines the list of tests to run. # ! NO_PLUGIN = -U NONE --noplugin --not-a-term # The first script creates small.vim. SCRIPTS_FIRST = \ --- 2,11 ---- # Common Makefile, defines the list of tests to run. # ! # 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,157 **** --- 155,161 ---- test_gf.res \ test_gn.res \ test_gui.res \ + test_gui_init.res \ test_hardcopy.res \ test_help.res \ test_hide.res \ *** ../vim-8.0.0360/src/testdir/Make_dos.mak 2017-01-06 17:59:54.735385599 +0100 --- src/testdir/Make_dos.mak 2017-02-23 19:19:53.693465487 +0100 *************** *** 38,44 **** $(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 # For each input file dostmp/test99.in run the tests. # This moves test99.in to test99.in.bak temporarily. --- 38,44 ---- $(DOSTMP_INFILES): $(*B).in if not exist $(DOSTMP)\NUL md $(DOSTMP) if exist $@ del $@ ! $(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,53 **** 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 -@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 --- 47,53 ---- 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_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,61 **** -@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" \ $(DOSTMP)\$(*B).out @diff test.out $*.ok & if errorlevel 1 \ ( move /y test.out $*.failed > nul \ --- 55,61 ---- -@if exist Xfind rd /s /q Xfind -@del X* -@if exist viminfo del viminfo ! $(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,110 **** bench_re_freeze.out: bench_re_freeze.vim -if exist benchmark.out del benchmark.out ! $(VIMPROG) -u dos.vim $(NO_PLUGIN) $*.in @IF EXIST benchmark.out ( type benchmark.out ) # New style of tests uses Vim script with assert calls. These are easier --- 104,110 ---- bench_re_freeze.out: bench_re_freeze.vim -if exist benchmark.out del benchmark.out ! $(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,119 **** .vim.res: @echo "$(VIMPROG)" > vimcmd ! $(VIMPROG) -u NONE $(NO_PLUGIN) -S runtest.vim $*.vim @del vimcmd --- 115,129 ---- .vim.res: @echo "$(VIMPROG)" > vimcmd ! $(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 *** ../vim-8.0.0360/src/testdir/Make_ming.mak 2016-11-07 22:13:29.171894387 +0100 --- src/testdir/Make_ming.mak 2017-02-23 19:18:56.485830934 +0100 *************** *** 66,73 **** # 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 \ dotest.in test60.ok test_listchars.ok \ test_getcwd.ok test_wordcount.ok --- 66,73 ---- # TODO: find a way to avoid changing the distributed files. fixff: ! -$(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,97 **** .in.out: -@if exist $*.ok $(CP) $*.ok test.ok ! $(VIMPROG) -u dos.vim $(NO_PLUGIN) -s dotest.in $*.in @diff test.out $*.ok -@if exist $*.out $(DEL) $*.out @$(MV) test.out $*.out --- 91,97 ---- .in.out: -@if exist $*.ok $(CP) $*.ok test.ok ! $(VIMPROG) -u dos.vim $(NO_INITS) -s dotest.in $*.in @diff test.out $*.ok -@if exist $*.out $(DEL) $*.out @$(MV) test.out $*.out *************** *** 107,113 **** bench_re_freeze.out: bench_re_freeze.vim -$(DEL) benchmark.out ! $(VIMPROG) -u dos.vim $(NO_PLUGIN) $*.in $(CAT) benchmark.out # New style of tests uses Vim script with assert calls. These are easier --- 107,113 ---- bench_re_freeze.out: bench_re_freeze.vim -$(DEL) benchmark.out ! $(VIMPROG) -u dos.vim $(NO_INITS) $*.in $(CAT) benchmark.out # New style of tests uses Vim script with assert calls. These are easier *************** *** 118,123 **** .vim.res: @echo "$(VIMPROG)" > vimcmd ! $(VIMPROG) -u NONE $(NO_PLUGIN) -S runtest.vim $*.vim @$(DEL) vimcmd --- 118,133 ---- .vim.res: @echo "$(VIMPROG)" > vimcmd ! $(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 *** ../vim-8.0.0360/src/testdir/Makefile 2017-01-30 22:00:56.621028503 +0100 --- src/testdir/Makefile 2017-02-23 19:22:31.588456794 +0100 *************** *** 52,58 **** 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 clean: -rm -rf *.out *.failed *.res *.rej *.orig test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.* --- 52,58 ---- 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_INITS) -s dotest.in clean: -rm -rf *.out *.failed *.res *.rej *.orig test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.* *************** *** 118,124 **** # 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) 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" --- 118,124 ---- # 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 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,132 **** .vim.res: @echo "$(RUN_VIMTEST)" > vimcmd ! $(RUN_VIMTEST) -U NONE -S runtest.vim $*.vim @rm vimcmd --- 128,142 ---- .vim.res: @echo "$(RUN_VIMTEST)" > vimcmd ! $(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 *** ../vim-8.0.0360/src/testdir/gui_init.vim 2017-02-23 19:26:34.190906826 +0100 --- src/testdir/gui_init.vim 2017-02-23 19:13:12.408028718 +0100 *************** *** 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 *** ../vim-8.0.0360/src/testdir/setup_gui.vim 2017-02-23 19:26:34.194906800 +0100 --- src/testdir/setup_gui.vim 2017-02-23 19:13:12.408028718 +0100 *************** *** 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 *** ../vim-8.0.0360/src/testdir/test_gui.vim 2017-02-17 13:44:44.299321045 +0100 --- src/testdir/test_gui.vim 2017-02-23 19:13:12.408028718 +0100 *************** *** 4,35 **** 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 ! ! " 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 TearDown() ! call delete('Xhome', 'rf') endfunc " Test for resetting "secure" flag after GUI has started. --- 4,17 ---- finish endif ! source setup_gui.vim ! func Setup() ! call GUISetUpCommon() endfunc func TearDown() ! call GUITearDownCommon() endfunc " Test for resetting "secure" flag after GUI has started. *************** *** 43,50 **** func Test_getfontname_with_arg() let skipped = '' ! if !s:x11_based_gui ! let skipped = s:not_implemented elseif has('gui_athena') || has('gui_motif') " Invalid font name. The result should be an empty string. call assert_equal('', getfontname('notexist')) --- 25,32 ---- func Test_getfontname_with_arg() let skipped = '' ! 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,79 **** let fname = getfontname() ! if !s:x11_based_gui ! let skipped = s: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) --- 54,61 ---- let fname = getfontname() ! 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,107 **** set guifontset= endif ! if !s:x11_based_gui ! let skipped = s:not_implemented elseif has('gui_athena') || has('gui_motif') " Non-empty font list with invalid font names. " --- 82,89 ---- set guifontset= endif ! 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,159 **** let skipped = '' if !has('xfontset') ! let skipped = s:not_supported . 'xfontset' else let ctype_saved = v:ctype --- 135,141 ---- let skipped = '' if !has('xfontset') ! let skipped = g:not_supported . 'xfontset' else let ctype_saved = v:ctype *************** *** 202,208 **** " Third, give a set of tests if it is found feasible. if !feasible ! let skipped = s:not_hosted else " N.B. 'v:ctype' has already been set to an appropriate value in the " previous loop. --- 184,190 ---- " Third, give a set of tests if it is found feasible. if !feasible ! let skipped = g:not_hosted else " N.B. 'v:ctype' has already been set to an appropriate value in the " previous loop. *************** *** 224,238 **** func Test_set_guifontwide() let skipped = '' ! if !s:x11_based_gui ! let skipped = s: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 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') --- 206,220 ---- func Test_set_guifontwide() let skipped = '' ! 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 = 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,252 **** elseif has('gui_athena') || has('gui_motif') " guifontwide is premised upon the xfontset feature. if !has('xfontset') ! let skipped = s:not_supported . 'xfontset' else let encoding_saved = &encoding let guifont_saved = &guifont --- 228,234 ---- elseif has('gui_athena') || has('gui_motif') " guifontwide is premised upon the xfontset feature. if !has('xfontset') ! let skipped = g:not_supported . 'xfontset' else let encoding_saved = &encoding let guifont_saved = &guifont *************** *** 303,308 **** --- 285,306 ---- 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,323 **** endfunc func Test_windowid_variable() ! if s:x11_based_gui || has('win32') call assert_true(v:windowid > 0) else call assert_equal(0, v:windowid) --- 315,321 ---- endfunc func Test_windowid_variable() ! if g:x11_based_gui || has('win32') call assert_true(v:windowid > 0) else call assert_equal(0, v:windowid) *** ../vim-8.0.0360/src/testdir/test_gui_init.vim 2017-02-23 19:26:34.206906723 +0100 --- src/testdir/test_gui_init.vim 2017-02-23 19:13:12.408028718 +0100 *************** *** 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 *** ../vim-8.0.0360/Filelist 2017-01-28 18:42:52.809791676 +0100 --- Filelist 2017-02-23 19:28:00.654354379 +0100 *************** *** 105,111 **** --- 105,114 ---- 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 \ *** ../vim-8.0.0360/src/version.c 2017-02-23 19:00:28.516904176 +0100 --- src/version.c 2017-02-23 19:09:16.489535424 +0100 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 361, /**/ -- hundred-and-one symptoms of being an internet addict: 12. You turn off your modem and get this awful empty feeling, like you just pulled the plug on a loved one. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///