Skip to content

Commit 077ff43

Browse files
committed
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)
1 parent efae76a commit 077ff43

5 files changed

Lines changed: 31 additions & 41 deletions

File tree

src/testdir/test_normal.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ func Test_normal10_expand()
408408

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

415414
" Test expand(`=...`) i.e. backticks expression expansion

src/testdir/test_system.vim

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,24 @@ func Test_System()
1818
call assert_equal(["as\r", "df\r"], systemlist('more', ["as\<NL>df"]))
1919
endif
2020

21-
if !executable('cat') || !executable('wc')
22-
return
23-
endif
24-
25-
let out = 'echo 123'->system()
26-
" On Windows we may get a trailing space.
27-
if out != "123 \n"
28-
call assert_equal("123\n", out)
29-
endif
30-
31-
let out = 'echo 123'->systemlist()
32-
if !has('win32')
33-
call assert_equal(["123"], out)
34-
else
35-
call assert_equal(["123\r"], out)
36-
endif
37-
38-
if executable('cat')
39-
call assert_equal('123', system('cat', '123'))
40-
call assert_equal(['123'], systemlist('cat', '123'))
41-
call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"]))
42-
endif
43-
4421
new Xdummy
4522
call setline(1, ['asdf', "pw\<NL>er", 'xxxx'])
46-
let out = system('wc -l', bufnr('%'))
47-
" On OS/X we get leading spaces
48-
let out = substitute(out, '^ *', '', '')
49-
call assert_equal("3\n", out)
50-
51-
let out = systemlist('wc -l', bufnr('%'))
52-
" On Windows we may get a trailing CR.
53-
if out != ["3\r"]
23+
24+
if executable('wc')
25+
let out = system('wc -l', bufnr('%'))
5426
" On OS/X we get leading spaces
55-
if type(out) == v:t_list
56-
let out[0] = substitute(out[0], '^ *', '', '')
27+
let out = substitute(out, '^ *', '', '')
28+
call assert_equal("3\n", out)
29+
30+
let out = systemlist('wc -l', bufnr('%'))
31+
" On Windows we may get a trailing CR.
32+
if out != ["3\r"]
33+
" On OS/X we get leading spaces
34+
if type(out) == v:t_list
35+
let out[0] = substitute(out[0], '^ *', '', '')
36+
endif
37+
call assert_equal(['3'], out)
5738
endif
58-
call assert_equal(['3'], out)
5939
endif
6040

6141
if !has('win32')

src/testdir/test_terminal.vim

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,14 @@ func Test_terminal_finish_open_close()
563563
endfunc
564564

565565
func Test_terminal_cwd()
566-
if !executable('pwd')
567-
return
566+
if has('win32')
567+
let cmd = 'cmd /c cd'
568+
else
569+
CheckExecutable pwd
570+
let cmd = 'pwd'
568571
endif
569572
call mkdir('Xdir')
570-
let buf = term_start('pwd', {'cwd': 'Xdir'})
573+
let buf = term_start(cmd, {'cwd': 'Xdir'})
571574
call WaitForAssert({-> assert_equal('Xdir', fnamemodify(getline(1), ":t"))})
572575

573576
exe buf . 'bwipe'
@@ -2031,7 +2034,13 @@ func Test_terminal_does_not_truncate_last_newlines()
20312034
endfunc
20322035

20332036
func Test_terminal_no_job()
2034-
let term = term_start('false', {'term_finish': 'close'})
2037+
if has('win32')
2038+
let cmd = 'cmd /c ""'
2039+
else
2040+
CheckExecutable false
2041+
let cmd = 'false'
2042+
endif
2043+
let term = term_start(cmd, {'term_finish': 'close'})
20352044
call WaitForAssert({-> assert_equal(v:null, term_getjob(term)) })
20362045
endfunc
20372046

src/testdir/test_undo.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ funct Test_undofile()
458458
" Test undofile() with 'undodir' set to a non-existing directory.
459459
call assert_equal('', 'Xundofoo'->undofile())
460460

461-
if isdirectory('/tmp')
461+
if !has('win32') && isdirectory('/tmp')
462462
set undodir=/tmp
463463
if has('osx')
464464
call assert_equal('/tmp/%private%tmp%file', undofile('///tmp/file'))

src/version.c

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

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
2230,
744746
/**/
745747
2229,
746748
/**/

0 commit comments

Comments
 (0)