diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-04-11 09:10:54 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-04-11 09:10:54 -0300 |
commit | 8171fc4cbc9cfe368bca7a7e711e198b976bf4f7 (patch) | |
tree | 47968c16b0092d0a37e73074df2ac127c9934fb2 /test/functional | |
parent | 5bd85fd95442b2eab8d00a291380c52f48097e61 (diff) | |
parent | 484fd734ab6d90f76a93e634d869fdb18ace3f5f (diff) | |
download | rneovim-8171fc4cbc9cfe368bca7a7e711e198b976bf4f7.tar.gz rneovim-8171fc4cbc9cfe368bca7a7e711e198b976bf4f7.tar.bz2 rneovim-8171fc4cbc9cfe368bca7a7e711e198b976bf4f7.zip |
Merge PR #2405 'Job control fixes'
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/job/job_spec.lua | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua index c517ae4c1b..8191b63a1c 100644 --- a/test/functional/job/job_spec.lua +++ b/test/functional/job/job_spec.lua @@ -249,6 +249,52 @@ describe('jobs', function() eq({'notification', 'wait', {{-2}}}, next_msg()) end) + it('can be called recursively', function() + source([[ + let g:opts = {} + let g:counter = 0 + function g:opts.on_stdout(id, msg) + if self.state == 0 + if self.counter < 10 + call Run() + endif + let self.state = 1 + call jobsend(a:id, "line1\n") + elseif self.state == 1 + let self.state = 2 + call jobsend(a:id, "line2\n") + elseif self.state == 2 + let self.state = 3 + call jobsend(a:id, "line3\n") + else + call rpcnotify(g:channel, 'w', printf('job %d closed', self.counter)) + call jobclose(a:id, 'stdin') + endif + endfunction + function g:opts.on_exit() + call rpcnotify(g:channel, 'w', printf('job %d exited', self.counter)) + endfunction + function Run() + let g:counter += 1 + let j = copy(g:opts) + let j.state = 0 + let j.counter = g:counter + call jobwait([ + \ jobstart([&sh, '-c', 'echo ready; cat -'], j), + \ ]) + endfunction + ]]) + execute('call Run()') + local r + for i = 10, 1, -1 do + r = next_msg() + eq('job '..i..' closed', r[3][1]) + r = next_msg() + eq('job '..i..' exited', r[3][1]) + end + eq(10, nvim('eval', 'g:counter')) + end) + describe('with timeout argument', function() it('will return -1 if the wait timed out', function() source([[ @@ -292,7 +338,7 @@ describe('jobs', function() data[i] = data[i]:gsub('\n', '\000') end rv = table.concat(data, '\n') - rv = rv:gsub('\r\n$', '') + rv = rv:gsub('\r\n$', ''):gsub('^\r\n', '') if rv ~= '' then break end |