1
0
forked from aniani/vim

patch 8.1.2230: MS-Windows: testing external commands can be improved

Problem:    MS-Windows: testing external commands can be improved.
Solution:   Adjust tests, remove duplicate test. (closes #4928)
This commit is contained in:
Bram Moolenaar
2019-10-28 00:42:21 +01:00
parent efae76ab1a
commit 077ff436a7
5 changed files with 30 additions and 40 deletions

View File

@@ -18,44 +18,24 @@ func Test_System()
call assert_equal(["as\r", "df\r"], systemlist('more', ["as\<NL>df"]))
endif
if !executable('cat') || !executable('wc')
return
endif
let out = 'echo 123'->system()
" On Windows we may get a trailing space.
if out != "123 \n"
call assert_equal("123\n", out)
endif
let out = 'echo 123'->systemlist()
if !has('win32')
call assert_equal(["123"], out)
else
call assert_equal(["123\r"], out)
endif
if executable('cat')
call assert_equal('123', system('cat', '123'))
call assert_equal(['123'], systemlist('cat', '123'))
call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"]))
endif
new Xdummy
call setline(1, ['asdf', "pw\<NL>er", 'xxxx'])
let out = system('wc -l', bufnr('%'))
" On OS/X we get leading spaces
let out = substitute(out, '^ *', '', '')
call assert_equal("3\n", out)
let out = systemlist('wc -l', bufnr('%'))
" On Windows we may get a trailing CR.
if out != ["3\r"]
if executable('wc')
let out = system('wc -l', bufnr('%'))
" On OS/X we get leading spaces
if type(out) == v:t_list
let out[0] = substitute(out[0], '^ *', '', '')
let out = substitute(out, '^ *', '', '')
call assert_equal("3\n", out)
let out = systemlist('wc -l', bufnr('%'))
" On Windows we may get a trailing CR.
if out != ["3\r"]
" On OS/X we get leading spaces
if type(out) == v:t_list
let out[0] = substitute(out[0], '^ *', '', '')
endif
call assert_equal(['3'], out)
endif
call assert_equal(['3'], out)
endif
if !has('win32')