Skip to content

Commit 3a93838

Browse files
committed
patch 7.4.2178
Problem: No test for reading from stdin. Solution: Add a test.
1 parent ba98bef commit 3a93838

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

src/testdir/shared.vim

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,15 @@ func WaitFor(expr)
122122
endfunc
123123

124124
" Run Vim, using the "vimcmd" file and "-u NORC".
125-
" "before" is a list of commands to be executed before loading plugins.
126-
" "after" is a list of commands to be executed after loading plugins.
125+
" "before" is a list of Vim commands to be executed before loading plugins.
126+
" "after" is a list of Vim commands to be executed after loading plugins.
127127
" Plugins are not loaded, unless 'loadplugins' is set in "before".
128128
" Return 1 if Vim could be executed.
129129
func RunVim(before, after, arguments)
130+
call RunVimPiped(a:before, a:after, a:arguments, '')
131+
endfunc
132+
133+
func RunVimPiped(before, after, arguments, pipecmd)
130134
if !filereadable('vimcmd')
131135
return 0
132136
endif
@@ -145,7 +149,13 @@ func RunVim(before, after, arguments)
145149
if cmd !~ '-u NONE'
146150
let cmd = cmd . ' -u NONE'
147151
endif
148-
exe "silent !" . cmd . args . ' ' . a:arguments
152+
153+
" With pipecmd we can't set VIMRUNTIME.
154+
if a:pipecmd != ''
155+
let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '')
156+
endif
157+
158+
exe "silent !" . a:pipecmd . cmd . args . ' ' . a:arguments
149159

150160
if len(a:before) > 0
151161
call delete('Xbefore.vim')

src/testdir/test_startup.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,15 @@ func Test_startuptime()
169169
endif
170170
call delete('Xtestout')
171171
endfunc
172+
173+
func Test_read_stdin()
174+
let after = [
175+
\ 'write Xtestout',
176+
\ 'quit!',
177+
\ ]
178+
if RunVimPiped([], after, '-', 'echo something | ')
179+
let lines = readfile('Xtestout')
180+
call assert_equal('something', lines[0])
181+
endif
182+
call delete('Xtestout')
183+
endfunc

src/version.c

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

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2178,
766768
/**/
767769
2177,
768770
/**/

0 commit comments

Comments
 (0)