Execute ( SpaceVim api: job ): let job = SpaceVim#api#import('job') let sys = SpaceVim#api#import('system') let cmp = SpaceVim#api#import('vim#compatible') if sys.isWindows let cat = fnamemodify(v:progpath, ':h') . '\cat.exe' else let cat = 'cat' endif if !executable(cat) finish endif for line in cmp.systemlist(shellescape(cat) . ' --version') Log line endfor let argv = [cat] let g:stdout = '' let stderr = '' let exit_data = 1 function! s:on_stdout(id, data, event) abort if a:event ==# 'stdout' let g:stdout = join(a:data, "\n") elseif a:event ==# 'exit' let g:exit_data = a:data else let g:stderr = a:data endif endfunction let opt = { \ 'on_stdout' : function('s:on_stdout'), \ 'on_stderr' : function('s:on_stdout'), \ 'on_exit' : function('s:on_stdout'), \ } if job.vim_job || job.nvim_job let jobid = job.start(argv,opt) call job.send(jobid, 'foo') sleep 2000m AssertEqual stdout, 'foo' AssertEqual job.status(jobid), 'run' call job.stop(jobid) AssertEqual exit_data, 1 else let jobid = job.start(['echo', 'foo'],opt) AssertEqual stdout, 'foo' AssertEqual exit_data, 0 endif