Skip to content

Commit

Permalink
vim-patch:8.1.2230: MS-Windows: testing external commands can be impr…
Browse files Browse the repository at this point in the history
…oved

Problem:    MS-Windows: testing external commands can be improved.
Solution:   Adjust tests, remove duplicate test. (closes vim/vim#4928)
vim/vim@077ff43
  • Loading branch information
zeertzjq committed Jul 11, 2022
1 parent aab94a6 commit 4d3af53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 34 deletions.
3 changes: 1 addition & 2 deletions src/nvim/testdir/test_normal.vim
Expand Up @@ -460,8 +460,7 @@ func Test_normal10_expand()

if executable('echo')
" Test expand(`...`) i.e. backticks command expansion.
" MS-Windows has a trailing space.
call assert_match('^abcde *$', expand('`echo abcde`'))
call assert_equal('abcde', expand('`echo abcde`'))
endif

" Test expand(`=...`) i.e. backticks expression expansion
Expand Down
45 changes: 14 additions & 31 deletions src/nvim/testdir/test_system.vim
Expand Up @@ -18,41 +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()
call assert_equal("123\n", out)

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')
Expand Down
2 changes: 1 addition & 1 deletion src/nvim/testdir/test_undo.vim
Expand Up @@ -492,7 +492,7 @@ funct Test_undofile()
" Test undofile() with 'undodir' set to a non-existing directory.
" call assert_equal('', 'Xundofoo'->undofile())

if isdirectory('/tmp')
if !has('win32') && isdirectory('/tmp')
set undodir=/tmp
if has('osx')
call assert_equal('/tmp/%private%tmp%file', undofile('///tmp/file'))
Expand Down

0 comments on commit 4d3af53

Please sign in to comment.