comparison src/testdir/test_channel.vim @ 8066:1aa8ed4ee48b v7.4.1327

commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 15 22:55:28 2016 +0100 patch 7.4.1327 Problem: Channel test doesn't work if Python executable is python.exe. Solution: Find py.exe or python.exe. (Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Mon, 15 Feb 2016 23:00:05 +0100
parents 19304db153bc
children e4c3f6720b03
comparison
equal deleted inserted replaced
8065:edbf9c5fe379 8066:1aa8ed4ee48b
11 " We also need the job feature or the pkill command to make sure the server 11 " We also need the job feature or the pkill command to make sure the server
12 " can be stopped. 12 " can be stopped.
13 if !(executable('python') && (has('job') || executable('pkill'))) 13 if !(executable('python') && (has('job') || executable('pkill')))
14 finish 14 finish
15 endif 15 endif
16 let s:python = 'python'
16 elseif has('win32') 17 elseif has('win32')
17 " Use Python Launcher for Windows (py.exe). 18 " Use Python Launcher for Windows (py.exe) if available.
18 if !executable('py') 19 if executable('py.exe')
20 let s:python = 'py.exe'
21 elseif executable('python.exe')
22 let s:python = 'python.exe'
23 else
19 finish 24 finish
20 endif 25 endif
21 else 26 else
22 " Can't run this test. 27 " Can't run this test.
23 finish 28 finish
30 " The Python program writes the port number in Xportnr. 35 " The Python program writes the port number in Xportnr.
31 call delete("Xportnr") 36 call delete("Xportnr")
32 37
33 try 38 try
34 if has('job') 39 if has('job')
35 let s:job = job_start("python test_channel.py") 40 let s:job = job_start(s:python . " test_channel.py")
36 elseif has('win32') 41 elseif has('win32')
37 silent !start cmd /c start "test_channel" py test_channel.py 42 exe 'silent !start cmd /c start "test_channel" ' . s:python . ' test_channel.py'
38 else 43 else
39 silent !python test_channel.py& 44 exe 'silent !' . s:python . ' test_channel.py&'
40 endif 45 endif
41 46
42 " Wait for up to 2 seconds for the port number to be there. 47 " Wait for up to 2 seconds for the port number to be there.
43 let cnt = 20 48 let cnt = 20
44 let l = [] 49 let l = []
75 if exists('s:job') 80 if exists('s:job')
76 call job_stop(s:job) 81 call job_stop(s:job)
77 unlet s:job 82 unlet s:job
78 endif 83 endif
79 elseif has('win32') 84 elseif has('win32')
80 call system('taskkill /IM py.exe /T /F /FI "WINDOWTITLE eq test_channel"') 85 call system('taskkill /IM ' . s:python . ' /T /F /FI "WINDOWTITLE eq test_channel"')
81 else 86 else
82 call system("pkill -f test_channel.py") 87 call system("pkill -f test_channel.py")
83 endif 88 endif
84 endfunc 89 endfunc
85 90
281 286
282 func Test_pipe() 287 func Test_pipe()
283 if !has('job') 288 if !has('job')
284 return 289 return
285 endif 290 endif
286 let job = job_start("python test_channel_pipe.py") 291 let job = job_start(s:python . " test_channel_pipe.py")
287 call assert_equal("run", job_status(job)) 292 call assert_equal("run", job_status(job))
288 try 293 try
289 let handle = job_getchannel(job) 294 let handle = job_getchannel(job)
290 call ch_sendraw(handle, "echo something\n", 0) 295 call ch_sendraw(handle, "echo something\n", 0)
291 call assert_equal("something\n", ch_readraw(handle)) 296 call assert_equal("something\n", ch_readraw(handle))