Skip to content

Commit 4f5681d

Browse files
Millychrisbra
authored andcommitted
patch 9.1.0794: tests: tests may fail on Windows environment
Problem: tests: tests may fail on Windows environment Solution: use shellcmdflag=/D to skip executing autorun from the registry (Milly) closes: #15900 Signed-off-by: Milly <milly.ca@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 539349c commit 4f5681d

11 files changed

Lines changed: 21 additions & 19 deletions

src/testdir/dos.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set shell=c:\COMMAND.COM shellquote= shellxquote= shellcmdflag=/c shellredir=>
44
" This is used only when the +eval feature is available.
55
if executable("cmd.exe")
6-
set shell=cmd.exe
6+
set shell=cmd.exe shellcmdflag=/D\ /c
77
endif
88

99
source setup.vim

src/testdir/shared.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func RunCommand(cmd)
5959
let job = job_start(a:cmd, {"stoponexit": "hup"})
6060
call job_setoptions(job, {"stoponexit": "kill"})
6161
elseif has('win32')
62-
exe 'silent !start cmd /c start "test_channel" ' . a:cmd
62+
exe 'silent !start cmd /D /c start "test_channel" ' . a:cmd
6363
else
6464
exe 'silent !' . a:cmd . '&'
6565
endif

src/testdir/term_util.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ endfunc
174174
" number.
175175
func Run_shell_in_terminal(options)
176176
if has('win32')
177-
let buf = term_start([&shell, '/k'], a:options)
177+
let buf = term_start([&shell, '/D', '/k'], a:options)
178178
else
179179
let buf = term_start(&shell, a:options)
180180
endif

src/testdir/test_autocmd.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if has('timers')
8989
let g:triggered = 0
9090
au CursorHoldI * let g:triggered += 1
9191
set updatetime=100
92-
call job_start(has('win32') ? 'cmd /c echo:' : 'echo',
92+
call job_start(has('win32') ? 'cmd /D /c echo:' : 'echo',
9393
\ {'exit_cb': {-> timer_start(200, 'ExitInsertMode')}})
9494
call feedkeys('a', 'x!')
9595
call assert_equal(1, g:triggered)

src/testdir/test_channel.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ func Test_exit_cb_wipes_buf()
14291429
new
14301430
let g:wipe_buf = bufnr('')
14311431

1432-
let job = job_start(has('win32') ? 'cmd /c echo:' : ['true'],
1432+
let job = job_start(has('win32') ? 'cmd /D /c echo:' : ['true'],
14331433
\ {'exit_cb': 'ExitCbWipe'})
14341434
let timer = timer_start(300, {-> feedkeys("\<Esc>", 'nt')}, {'repeat': 5})
14351435
call feedkeys(repeat('g', 1000) . 'o', 'ntx!')
@@ -1770,7 +1770,7 @@ func Test_job_start_fails()
17701770
call assert_fails("call job_start('ls',
17711771
\ {'err_io' : 'buffer', 'err_buf' : -1})", 'E475:')
17721772

1773-
let cmd = has('win32') ? "cmd /c dir" : "ls"
1773+
let cmd = has('win32') ? "cmd /D /c dir" : "ls"
17741774

17751775
set nomodifiable
17761776
call assert_fails("call job_start(cmd,
@@ -2308,7 +2308,7 @@ endfunc
23082308

23092309
func Test_issue_5150()
23102310
if has('win32')
2311-
let cmd = 'cmd /c pause'
2311+
let cmd = 'cmd /D /c pause'
23122312
else
23132313
let cmd = 'grep foo'
23142314
endif
@@ -2438,7 +2438,7 @@ func Test_cb_with_input()
24382438
let g:wait_exit_cb = 1
24392439

24402440
if has('win32')
2441-
let cmd = 'cmd /c echo "Vim''s test"'
2441+
let cmd = 'cmd /D /c echo "Vim''s test"'
24422442
else
24432443
let cmd = 'echo "Vim''s test"'
24442444
endif

src/testdir/test_functions.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3416,7 +3416,7 @@ func Test_range()
34163416
call assert_fails('call term_start(range(3, 4))', 'E474:')
34173417
let g:terminal_ansi_colors = range(16)
34183418
if has('win32')
3419-
let cmd = "cmd /c dir"
3419+
let cmd = "cmd /D /c dir"
34203420
else
34213421
let cmd = "ls"
34223422
endif

src/testdir/test_swap.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func s:get_unused_pid(base)
420420
if has('job')
421421
" Execute 'echo' as a temporary job, and return its pid as an unused pid.
422422
if has('win32')
423-
let cmd = 'cmd /c echo'
423+
let cmd = 'cmd /D /c echo'
424424
else
425425
let cmd = 'echo'
426426
endif

src/testdir/test_terminal.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ endfunc
320320
func Get_cat_123_cmd()
321321
if has('win32')
322322
if !has('conpty')
323-
return 'cmd /c "cls && color 2 && echo 123"'
323+
return 'cmd /D /c "cls && color 2 && echo 123"'
324324
else
325325
" When clearing twice, extra sequence is not output.
326-
return 'cmd /c "cls && cls && color 2 && echo 123"'
326+
return 'cmd /D /c "cls && cls && color 2 && echo 123"'
327327
endif
328328
else
329329
call writefile(["\<Esc>[32m123"], 'Xtext')
@@ -410,7 +410,7 @@ func Test_terminal_scrape_multibyte()
410410
if has('win32')
411411
" Run cmd with UTF-8 codepage to make the type command print the expected
412412
" multibyte characters.
413-
let buf = term_start("cmd /K chcp 65001")
413+
let buf = term_start("cmd /D /K chcp 65001")
414414
call term_sendkeys(buf, "type Xtext\<CR>")
415415
eval buf->term_sendkeys("exit\<CR>")
416416
let line = 4
@@ -457,7 +457,7 @@ endfunc
457457
func Test_terminal_scroll()
458458
call writefile(range(1, 200), 'Xtext', 'D')
459459
if has('win32')
460-
let cmd = 'cmd /c "type Xtext"'
460+
let cmd = 'cmd /D /c "type Xtext"'
461461
else
462462
let cmd = "cat Xtext"
463463
endif
@@ -765,7 +765,7 @@ endfunc
765765

766766
func Test_terminal_cwd()
767767
if has('win32')
768-
let cmd = 'cmd /c cd'
768+
let cmd = 'cmd /D /c cd'
769769
else
770770
CheckExecutable pwd
771771
let cmd = 'pwd'
@@ -1111,7 +1111,7 @@ func Test_terminal_composing_unicode()
11111111
set encoding=utf-8
11121112

11131113
if has('win32')
1114-
let cmd = "cmd /K chcp 65001"
1114+
let cmd = "cmd /D /K chcp 65001"
11151115
let lnum = [3, 6, 9]
11161116
else
11171117
let cmd = &shell

src/testdir/test_terminal2.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ func Test_terminal_does_not_truncate_last_newlines()
450450
for c in contents
451451
call writefile(c, 'Xdntfile', 'D')
452452
if has('win32')
453-
term cmd /c type Xdntfile
453+
term cmd /D /c type Xdntfile
454454
else
455455
term cat Xdntfile
456456
endif
@@ -465,7 +465,7 @@ endfunc
465465

466466
func GetDummyCmd()
467467
if has('win32')
468-
return 'cmd /c ""'
468+
return 'cmd /D /c ""'
469469
else
470470
CheckExecutable false
471471
return 'false'

src/testdir/test_windows_home.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func Test_WindowsHome()
105105
RestoreEnv
106106
let $HOME = save_home
107107
let env = ''
108-
let job = job_start('cmd /c set', {'out_cb': {ch,x->[env,execute('let env=x')]}})
108+
let job = job_start('cmd /D /c set', {'out_cb': {ch,x->[env,execute('let env=x')]}})
109109
sleep 1
110110
let env = filter(split(env, "\n"), 'v:val=="HOME"')
111111
let home = len(env) == 0 ? "" : env[0]

0 commit comments

Comments
 (0)