From 8560e6cf9797ea1d55ecaea6bf8ee8ec783c291a Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Tue, 16 Apr 2024 22:18:15 +0200 Subject: patch 9.1.0339: tests: xdg test uses screen dumps Problem: tests: xdg test uses screen dumps Solution: Convert screen dump to normal test (Yegappan Lakshmanan) closes: #14564 Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- src/testdir/test_xdg.vim | 112 ++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 54 deletions(-) (limited to 'src/testdir/test_xdg.vim') diff --git a/src/testdir/test_xdg.vim b/src/testdir/test_xdg.vim index da98a2cfa7..557864e257 100644 --- a/src/testdir/test_xdg.vim +++ b/src/testdir/test_xdg.vim @@ -1,12 +1,9 @@ " Tests for the XDG feature source check.vim -CheckFeature terminal source shared.vim -source screendump.vim source mouse.vim -source term_util.vim func s:get_rcs() let rcs = { @@ -77,63 +74,70 @@ func Test_xdg_runtime_files() call writefile(file3, rc3) call writefile(file4, rc4) - let rows = 20 - let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1}) - call TermWait(buf) - call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\") - call WaitForAssert({-> assert_match('XfakeHOME/\.vimrc', term_getline(buf, rows))}) - call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\") - call TermWait(buf) - call term_sendkeys(buf, ":redraw!\") - call TermWait(buf) - call term_sendkeys(buf, ":let g:\") - call VerifyScreenDump(buf, 'Test_xdg_1', {}) - call StopVimInTerminal(buf) + " Get the Vim command to run without the '-u NONE' argument + let vimcmd = substitute(GetVimCommand(), '-u NONE', '', '') + + " Test for ~/.vimrc + let lines =<< trim END + call assert_match('XfakeHOME/\.vimrc', $MYVIMRC) + call filter(g:, {idx, _ -> idx =~ '^rc'}) + call assert_equal(#{rc_one: 'one', rc: '.vimrc'}, g:) + call writefile(v:errors, 'Xresult') + quit + END + call writefile(lines, 'Xscript', 'D') + call system($'{vimcmd} -S Xscript') + call assert_equal([], readfile('Xresult')) + call delete(rc1) - bw - - let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1}) - call TermWait(buf) - call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\") - call WaitForAssert({-> assert_match('XfakeHOME/\.vim/vimrc', term_getline(buf, rows))}) - call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\") - call TermWait(buf) - call term_sendkeys(buf, ":redraw!\") - call TermWait(buf) - call term_sendkeys(buf, ":let g:\") - call VerifyScreenDump(buf, 'Test_xdg_2', {}) - call StopVimInTerminal(buf) + + " Test for ~/.vim/vimrc + let lines =<< trim END + call assert_match('XfakeHOME/\.vim/vimrc', $MYVIMRC) + call filter(g:, {idx, _ -> idx =~ '^rc'}) + call assert_equal(#{rc_two: 'two', rc: '.vim/vimrc'}, g:) + call writefile(v:errors, 'Xresult') + quit + END + call writefile(lines, 'Xscript', 'D') + call system($'{vimcmd} -S Xscript') + call assert_equal([], readfile('Xresult')) + call delete(rc2) - bw - - let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1}) - call TermWait(buf) - call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\") - call WaitForAssert({-> assert_match('XfakeHOME/\.config/vim/vimrc', term_getline(buf, rows))}) - call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\") - call TermWait(buf) - call term_sendkeys(buf, ":redraw!\") - call TermWait(buf) - call term_sendkeys(buf, ":let g:\") - call VerifyScreenDump(buf, 'Test_xdg_3', {}) - call StopVimInTerminal(buf) + + " XDG_CONFIG_HOME is set in Github CI runners + unlet $XDG_CONFIG_HOME + + " Test for ~/.config/vim/vimrc + let lines =<< trim END + let msg = $'HOME="{$HOME}", ~="{expand("~")}"' + call assert_match('XfakeHOME/\.config/vim/vimrc', $MYVIMRC, msg) + call filter(g:, {idx, _ -> idx =~ '^rc'}) + call assert_equal(#{rc_three: 'three', rc: '.config/vim/vimrc'}, g:) + call writefile(v:errors, 'Xresult') + quit + END + call writefile(lines, 'Xscript', 'D') + call system($'{vimcmd} -S Xscript') + call assert_equal([], readfile('Xresult')) + call delete(rc3) - bw + " Test for ~/xdg/vim/vimrc let $XDG_CONFIG_HOME=expand('~/xdg/') - let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1}) - call TermWait(buf) - call term_sendkeys(buf, ":redraw!\") - call TermWait(buf) - call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\") - call WaitForAssert({-> assert_match('XfakeHOME/xdg/vim/vimrc', term_getline(buf, rows))}) - call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\") - call TermWait(buf) - call term_sendkeys(buf, ":let g:\") - call VerifyScreenDump(buf, 'Test_xdg_4', {}) - call StopVimInTerminal(buf) + let lines =<< trim END + let msg = $'HOME="{$HOME}", XDG_CONFIG_HOME="{$XDG_CONFIG_HOME}"' + call assert_match('XfakeHOME/xdg/vim/vimrc', $MYVIMRC, msg) + call filter(g:, {idx, _ -> idx =~ '^rc'}) + call assert_equal(#{rc_four: 'four', rc: 'xdg/vim/vimrc'}, g:) + call writefile(v:errors, 'Xresult') + quit + END + call writefile(lines, 'Xscript', 'D') + call system($'{vimcmd} -S Xscript') + call assert_equal([], readfile('Xresult')) + call delete(rc4) - bw unlet $XDG_CONFIG_HOME endfunc -- cgit v1.2.3