Skip to content

Commit 8560e6c

Browse files
yegappanchrisbra
authored andcommitted
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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 9a90179 commit 8560e6c

File tree

6 files changed

+60
-134
lines changed

6 files changed

+60
-134
lines changed

src/testdir/dumps/Test_xdg_1.dump

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/testdir/dumps/Test_xdg_2.dump

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/testdir/dumps/Test_xdg_3.dump

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/testdir/dumps/Test_xdg_4.dump

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/testdir/test_xdg.vim

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
" Tests for the XDG feature
22

33
source check.vim
4-
CheckFeature terminal
54

65
source shared.vim
7-
source screendump.vim
86
source mouse.vim
9-
source term_util.vim
107

118
func s:get_rcs()
129
let rcs = {
@@ -77,63 +74,70 @@ func Test_xdg_runtime_files()
7774
call writefile(file3, rc3)
7875
call writefile(file4, rc4)
7976

80-
let rows = 20
81-
let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1})
82-
call TermWait(buf)
83-
call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\<cr>")
84-
call WaitForAssert({-> assert_match('XfakeHOME/\.vimrc', term_getline(buf, rows))})
85-
call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\<cr>")
86-
call TermWait(buf)
87-
call term_sendkeys(buf, ":redraw!\<cr>")
88-
call TermWait(buf)
89-
call term_sendkeys(buf, ":let g:\<cr>")
90-
call VerifyScreenDump(buf, 'Test_xdg_1', {})
91-
call StopVimInTerminal(buf)
77+
" Get the Vim command to run without the '-u NONE' argument
78+
let vimcmd = substitute(GetVimCommand(), '-u NONE', '', '')
79+
80+
" Test for ~/.vimrc
81+
let lines =<< trim END
82+
call assert_match('XfakeHOME/\.vimrc', $MYVIMRC)
83+
call filter(g:, {idx, _ -> idx =~ '^rc'})
84+
call assert_equal(#{rc_one: 'one', rc: '.vimrc'}, g:)
85+
call writefile(v:errors, 'Xresult')
86+
quit
87+
END
88+
call writefile(lines, 'Xscript', 'D')
89+
call system($'{vimcmd} -S Xscript')
90+
call assert_equal([], readfile('Xresult'))
91+
9292
call delete(rc1)
93-
bw
94-
95-
let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1})
96-
call TermWait(buf)
97-
call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\<cr>")
98-
call WaitForAssert({-> assert_match('XfakeHOME/\.vim/vimrc', term_getline(buf, rows))})
99-
call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\<cr>")
100-
call TermWait(buf)
101-
call term_sendkeys(buf, ":redraw!\<cr>")
102-
call TermWait(buf)
103-
call term_sendkeys(buf, ":let g:\<cr>")
104-
call VerifyScreenDump(buf, 'Test_xdg_2', {})
105-
call StopVimInTerminal(buf)
93+
94+
" Test for ~/.vim/vimrc
95+
let lines =<< trim END
96+
call assert_match('XfakeHOME/\.vim/vimrc', $MYVIMRC)
97+
call filter(g:, {idx, _ -> idx =~ '^rc'})
98+
call assert_equal(#{rc_two: 'two', rc: '.vim/vimrc'}, g:)
99+
call writefile(v:errors, 'Xresult')
100+
quit
101+
END
102+
call writefile(lines, 'Xscript', 'D')
103+
call system($'{vimcmd} -S Xscript')
104+
call assert_equal([], readfile('Xresult'))
105+
106106
call delete(rc2)
107-
bw
108-
109-
let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1})
110-
call TermWait(buf)
111-
call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\<cr>")
112-
call WaitForAssert({-> assert_match('XfakeHOME/\.config/vim/vimrc', term_getline(buf, rows))})
113-
call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\<cr>")
114-
call TermWait(buf)
115-
call term_sendkeys(buf, ":redraw!\<cr>")
116-
call TermWait(buf)
117-
call term_sendkeys(buf, ":let g:\<cr>")
118-
call VerifyScreenDump(buf, 'Test_xdg_3', {})
119-
call StopVimInTerminal(buf)
107+
108+
" XDG_CONFIG_HOME is set in Github CI runners
109+
unlet $XDG_CONFIG_HOME
110+
111+
" Test for ~/.config/vim/vimrc
112+
let lines =<< trim END
113+
let msg = $'HOME="{$HOME}", ~="{expand("~")}"'
114+
call assert_match('XfakeHOME/\.config/vim/vimrc', $MYVIMRC, msg)
115+
call filter(g:, {idx, _ -> idx =~ '^rc'})
116+
call assert_equal(#{rc_three: 'three', rc: '.config/vim/vimrc'}, g:)
117+
call writefile(v:errors, 'Xresult')
118+
quit
119+
END
120+
call writefile(lines, 'Xscript', 'D')
121+
call system($'{vimcmd} -S Xscript')
122+
call assert_equal([], readfile('Xresult'))
123+
120124
call delete(rc3)
121-
bw
122125

126+
" Test for ~/xdg/vim/vimrc
123127
let $XDG_CONFIG_HOME=expand('~/xdg/')
124-
let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1})
125-
call TermWait(buf)
126-
call term_sendkeys(buf, ":redraw!\<cr>")
127-
call TermWait(buf)
128-
call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\<cr>")
129-
call WaitForAssert({-> assert_match('XfakeHOME/xdg/vim/vimrc', term_getline(buf, rows))})
130-
call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\<cr>")
131-
call TermWait(buf)
132-
call term_sendkeys(buf, ":let g:\<cr>")
133-
call VerifyScreenDump(buf, 'Test_xdg_4', {})
134-
call StopVimInTerminal(buf)
128+
let lines =<< trim END
129+
let msg = $'HOME="{$HOME}", XDG_CONFIG_HOME="{$XDG_CONFIG_HOME}"'
130+
call assert_match('XfakeHOME/xdg/vim/vimrc', $MYVIMRC, msg)
131+
call filter(g:, {idx, _ -> idx =~ '^rc'})
132+
call assert_equal(#{rc_four: 'four', rc: 'xdg/vim/vimrc'}, g:)
133+
call writefile(v:errors, 'Xresult')
134+
quit
135+
END
136+
call writefile(lines, 'Xscript', 'D')
137+
call system($'{vimcmd} -S Xscript')
138+
call assert_equal([], readfile('Xresult'))
139+
135140
call delete(rc4)
136-
bw
137141
unlet $XDG_CONFIG_HOME
138142
endfunc
139143

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
339,
707709
/**/
708710
338,
709711
/**/

0 commit comments

Comments
 (0)