comparison src/testdir/test_channel.vim @ 7957:b74549818500 v7.4.1274

commit https://github.com/vim/vim/commit/835dc636a5350f610b62f110227d2363b5b2880a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 7 14:27:38 2016 +0100 patch 7.4.1274 Problem: Cannot run a job. Solution: Add job_start(), job_status() and job_stop(). Currently only works for Unix.
author Christian Brabandt <cb@256bit.org>
date Sun, 07 Feb 2016 14:30:04 +0100
parents dcc0bd6b1574
children 646d5148fee2
comparison
equal deleted inserted replaced
7956:31dfe91e5016 7957:b74549818500
6 endif 6 endif
7 7
8 " This test requires the Python command to run the test server. 8 " This test requires the Python command to run the test server.
9 " This most likely only works on Unix and Windows. 9 " This most likely only works on Unix and Windows.
10 if has('unix') 10 if has('unix')
11 " We also need the pkill command to make sure the server can be stopped. 11 " We also need the job feature or the pkill command to make sure the server
12 if !executable('python') || !executable('pkill') 12 " can be stopped.
13 if !(executable('python') && (has('job') || executable('pkill')))
13 finish 14 finish
14 endif 15 endif
15 elseif has('win32') 16 elseif has('win32')
16 " Use Python Launcher for Windows (py.exe). 17 " Use Python Launcher for Windows (py.exe).
17 if !executable('py') 18 if !executable('py')
25 26
26 func s:start_server() 27 func s:start_server()
27 " The Python program writes the port number in Xportnr. 28 " The Python program writes the port number in Xportnr.
28 call delete("Xportnr") 29 call delete("Xportnr")
29 30
30 if has('win32') 31 if has('job')
32 let s:job = job_start("python test_channel.py")
33 elseif has('win32')
31 silent !start cmd /c start "test_channel" py test_channel.py 34 silent !start cmd /c start "test_channel" py test_channel.py
32 else 35 else
33 silent !python test_channel.py& 36 silent !python test_channel.py&
34 endif 37 endif
35 38
60 let handle = ch_open('localhost:' . s:port) 63 let handle = ch_open('localhost:' . s:port)
61 return handle 64 return handle
62 endfunc 65 endfunc
63 66
64 func s:kill_server() 67 func s:kill_server()
65 if has('win32') 68 if has('job')
69 call job_stop(s:job)
70 elseif has('win32')
66 call system('taskkill /IM py.exe /T /F /FI "WINDOWTITLE eq test_channel"') 71 call system('taskkill /IM py.exe /T /F /FI "WINDOWTITLE eq test_channel"')
67 else 72 else
68 call system("pkill -f test_channel.py") 73 call system("pkill -f test_channel.py")
69 endif 74 endif
70 endfunc 75 endfunc